• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Views.VPort类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中HomeOS.Hub.Platform.Views.VPort的典型用法代码示例。如果您正苦于以下问题:C# VPort类的具体用法?C# VPort怎么用?C# VPort使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



VPort类属于HomeOS.Hub.Platform.Views命名空间,在下文中一共展示了VPort类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: OnNotification

        public override void OnNotification(string roleName, string opName, IList<VParamType> retVals, VPort senderPort)
        {
            string message;
            string sensorData;
            string sensorTag = senderPort.GetInfo().GetFriendlyName() + roleName;

            lock (this)
            {
                if (roleName.Contains(RoleSensor.RoleName) && opName.Equals(RoleSensor.OpGetName))
                {
                        byte rcvdNum = (byte) (int) retVals[0].Value();
                        sensorData = rcvdNum.ToString();

                }
                else if (roleName.Contains(RoleSensorMultiLevel.RoleName) && opName.Equals(RoleSensorMultiLevel.OpGetName))
                {
                    double rcvdNum = (double) retVals[0].Value();
                    sensorData = rcvdNum.ToString();
                }
                else
                {
                    sensorData = String.Format("Invalid role->op {0}->{1} from {2}", roleName, opName, sensorTag);
                }
            }

            //Write to the stream
            WriteToStream(sensorTag, sensorData);
            //Create local list of alerts for display
            message = String.Format("{0} {1},{2}", DateTime.Now, sensorTag, sensorData);
            this.receivedMessageList.Add(message);
            //Log
            logger.Log("{0},{1}", this.ToString(), message);
        }
开发者ID:smosgin,项目名称:labofthings,代码行数:33,代码来源:Sensor.cs


示例2: PortRegistered

        public override void PortRegistered(VPort port)
        {
            lock (this)
            {
                if (Role.ContainsRole(port, RoleSensor.RoleName))
                {
                    VCapability capability = GetCapability(port, Constants.UserSystem);

                    if (registeredSensors.ContainsKey(port))
                        registeredSensors[port] = capability;
                    else
                        registeredSensors.Add(port, capability);

                    if (capability != null)
                    {
                        port.Subscribe(RoleSensor.RoleName, RoleSensor.OpGetName,
                               this.ControlPort, capability, this.ControlPortCapability);
                    }
                }
                if (Role.ContainsRole(port, RoleActuator.RoleName))
                {
                    VCapability capability = GetCapability(port, Constants.UserSystem);

                    if (registeredActuators.ContainsKey(port))
                        registeredActuators[port] = capability;
                    else
                        registeredActuators.Add(port, capability);

                    if (capability != null)
                    {
                        port.Subscribe(RoleActuator.RoleName, RoleActuator.OpPutName, this.ControlPort, capability, this.ControlPortCapability);
                    }
                }
            }
        }
开发者ID:smosgin,项目名称:labofthings,代码行数:35,代码来源:AppThermometer.cs


示例3: ContainsRole

        /// <summary>
        /// Does the given port contain the given role
        /// </summary>
        /// <param name="port"></param>
        /// <param name="roleName"></param>
        /// <returns></returns>
        public static bool ContainsRole(VPort port, string roleName)
        {
            foreach (VRole role in port.GetInfo().GetRoles())
            {
                if (ContainsRole(role.Name(), roleName))
                    return true;
            }

            return false;
        }
开发者ID:donnaknew,项目名称:programmingProject,代码行数:16,代码来源:Role.cs


示例4: PortDeregistered

 public override void PortDeregistered(VPort port)
 {
     lock (this)
     {
         if (accessibleDummyPorts.Contains(port))
         {
             accessibleDummyPorts.Remove(port);
             logger.Log("{0} deregistered port {1}", this.ToString(), port.GetInfo().ModuleFacingName());
         }
     }
 }
开发者ID:smosgin,项目名称:labofthings,代码行数:11,代码来源:Dummy2.cs


示例5: OnNotification

 public override void OnNotification(string roleName, string opName, IList<VParamType> retVals, VPort senderPort)
 {
     logger.Log("Notitification from {0} for {0}", roleName, opName);
     if (retVals.Count >= 1)
     {
         this.Temperature = (int)retVals[0].Value();
     }
     else
     {
         logger.Log("{0}: got unexpected retvals [{1}] from {2}", ToString(), retVals.Count.ToString(), senderPort.ToString());
     }
 }
开发者ID:smosgin,项目名称:labofthings,代码行数:12,代码来源:AppThermometer.cs


示例6: PortDeregistered

 public override void PortDeregistered(VPort port)
 {
     lock (this)
     {
         if (Role.ContainsRole(port, RoleSensor.RoleName))
         {
             if (registeredValves.ContainsKey(port))
             {
                 registeredValves.Remove(port);
                 logger.Log("{0} removed valve port {1}", this.ToString(), port.ToString());
             }
         }
     }
 }
开发者ID:donnaknew,项目名称:programmingProject,代码行数:14,代码来源:AppValveController.cs


示例7: PortRegistered

        /// <summary>
        ///  Called when a new port is registered with the platform
        /// </summary>
        public override void PortRegistered(VPort port)
        {

            logger.Log("{0} got registeration notification for {1}", ToString(), port.ToString());

            lock (this)
            {
                if (!accessibleWeatherPorts.Contains(port) && 
                    Role.ContainsRole(port, RoleWeather.RoleName) && 
                    GetCapabilityFromPlatform(port) != null)
                {
                    accessibleWeatherPorts.Add(port);

                    logger.Log("{0} added port {1}", this.ToString(), port.ToString());
                }
            }
        }
开发者ID:donnaknew,项目名称:programmingProject,代码行数:20,代码来源:Weather.cs


示例8: V2C

        internal static IPort V2C(VPort view)
        {
            if (view == null)
            {
                return null;
            }

            if (!System.Runtime.Remoting.RemotingServices.IsObjectOutOfAppDomain(view) &&
                (view.GetType().Equals(typeof(PortC2V))))
            {
                return ((PortC2V)(view)).GetSourceContract();
            }
            else
            {
                return new PortV2C(view);
            }
        }
开发者ID:smosgin,项目名称:labofthings,代码行数:17,代码来源:APort.cs


示例9: OnNotification

        public override void OnNotification(string roleName, string opName, IList<VParamType> retVals, VPort senderPort)
        {
            string message;
            lock (this)
            {
                switch (opName.ToLower())
                {
                    case RoleDummy2.OpEchoSubName:
                        int rcvdNum = (int)retVals[0].Value();

                        message = String.Format("async echo response from {0}. rcvd = {1}", senderPort.ToString(), rcvdNum.ToString());
                        this.receivedMessageList.Add(message);
                        break;
                    default:
                        message = String.Format("Invalid async operation return {0} from {1}", opName.ToLower(), senderPort.ToString());
                        break;
                }
            }
            logger.Log("{0} {1}", this.ToString(), message);
        }
开发者ID:smosgin,项目名称:labofthings,代码行数:20,代码来源:Dummy2.cs


示例10: OnNotification

 public override void OnNotification(string roleName, string opName, IList<VParamType> retVals, VPort senderPort)
 {
     string message;
     lock (this)
     {
         switch (opName.ToLower())
         {
             case "echosub":
                 string rcvdData = (string)retVals[0].Value();
                 irDataList.Add(rcvdData);
                 //ProcessData(rcvdData);
                 message = String.Format("async echo response from {0}. rcvd = {1}", senderPort.ToString(), rcvdData.ToString());
                 this.receivedMessageList.Add(message);
                 break;
             default:
                 message = String.Format("Invalid async operation return {0} from {1}", opName.ToLower(), senderPort.ToString());
                 break;
         }
     }
     //logger.Log("{0} {1}", this.ToString(), message);
 }
开发者ID:smosgin,项目名称:labofthings,代码行数:21,代码来源:Doorjamb.cs


示例11: PortRegistered

        /// <summary>
        ///  Called when a new port is registered with the platform
        /// </summary>
        public override void PortRegistered(VPort port)
        {
            logger.Log("{0} got registeration notification for {1}", ToString(), port.ToString());

            lock (this)
            {
                if (!accessibleDummyPorts.Contains(port) &&
                    Role.ContainsRole(port, RoleDummy2.RoleName) &&
                    GetCapabilityFromPlatform(port) != null)
                {
                    accessibleDummyPorts.Add(port);

                    logger.Log("{0} added port {1}", this.ToString(), port.ToString());

                    if (Subscribe(port, RoleDummy2.Instance, RoleDummy2.OpEchoSubName))
                        logger.Log("{0} subscribed to port {1}", this.ToString(), port.ToString());
                    else
                        logger.Log("failed to subscribe to port {1}", this.ToString(), port.ToString());
                }
            }
        }
开发者ID:smosgin,项目名称:labofthings,代码行数:24,代码来源:Dummy2.cs


示例12: WriteObjectImage

        private void WriteObjectImage(VPort cameraPort, Bitmap image, Rectangle rectSrc, bool center)
        {
            Rectangle rectTarget = rectSrc;
            int srcPixelShiftX = 0;
            int srcPixelShiftY = 0;

            if (rectSrc.Width == 0 && rectSrc.Height == 0)
            {
                logger.Log("Write Object Image Called with Rect with zero height and width!");
                return;
            }

            if (center)
            {
                rectTarget.X = (int)((image.Width - rectSrc.Width) / 2.0);
                rectTarget.Y = (int)((image.Height - rectSrc.Height) / 2.0);
                srcPixelShiftX = rectTarget.X - rectSrc.X;
                srcPixelShiftY = rectTarget.Y - rectSrc.Y;
            }

            // create the destination based upon layer one
            BitmapData bmpData = image.LockBits(new Rectangle(0, 0, image.Width, image.Height), ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb);
            int stride = bmpData.Stride;
            image.UnlockBits(bmpData);

            WriteableBitmap composite = new WriteableBitmap(image.Width, image.Height, 96, 96, System.Windows.Media.PixelFormats.Rgb24, null);
            Int32Rect sourceRect = new Int32Rect(0, 0, (int)image.Width, (int)image.Height);
            byte[] pixels = new byte[stride * image.Height];

            for (int x = 0; x < image.Width; ++x)
            {
                for (int y = 0; y < image.Height; ++y)
                {
                    if (rectSrc.Contains(x, y))
                    {
                        Color clr = image.GetPixel(x, y);
                        pixels[stride * (y + srcPixelShiftY) + 3 * (x + srcPixelShiftX)] = clr.R;
                        pixels[stride * (y + srcPixelShiftY) + 3 * (x + srcPixelShiftX) + 1] = clr.G;
                        pixels[stride * (y + srcPixelShiftY) + 3 * (x + srcPixelShiftX) + 2] = clr.B;
                    }
                    else if (!rectTarget.Contains(x, y))
                    {
                        pixels[stride * y + 3 * x] = 0x00;
                        pixels[stride * y + 3 * x + 1] = 0x00;
                        pixels[stride * y + 3 * x + 2] = 0x00;
                    }
                }
            }
            composite.WritePixels(sourceRect, pixels, stride, 0);

            // encode the bitmap to the output file
            JpegBitmapEncoder encoder = new JpegBitmapEncoder();
            encoder.Frames.Add(BitmapFrame.Create(composite));
            string filepath = GetMediaFileName(cameraPort.GetInfo().GetFriendlyName(), MediaType.MediaType_Image_JPEG);

            if (null == filepath)
            {
                logger.Log("GetMediaFileName failed to get a file name, are there more than 10 files of the same name?");
                return;
            }

            using (var stream = new FileStream(filepath, FileMode.Create, FileAccess.ReadWrite, FileShare.Read))
            {
                encoder.Save(stream);
            }
        }
开发者ID:donnaknew,项目名称:programmingProject,代码行数:66,代码来源:AppSmartCam.cs


示例13: Subscribe

 public override bool Subscribe(string roleName, string opName, VPort fromPort, VCapability reqCap, VCapability respCap)
 {
     return _contract.Subscribe(roleName, opName, PortAdapter.V2C(fromPort), CapabilityAdapter.V2C(reqCap), CapabilityAdapter.V2C(respCap));
 }
开发者ID:smosgin,项目名称:labofthings,代码行数:4,代码来源:APort.cs


示例14: PortDeregisteredWithHooks

 public virtual void PortDeregisteredWithHooks(VPort port) { }
开发者ID:donnaknew,项目名称:programmingProject,代码行数:1,代码来源:VModule.cs


示例15: AddFrameToVideo

        private void AddFrameToVideo(Bitmap image, VPort cameraPort, long sampleTime)
        {
            // Lock the bitmap's bits.  
            Rectangle rect = new Rectangle(0, 0, image.Width, image.Height);
            BitmapData bmpData = image.LockBits(rect, ImageLockMode.ReadOnly, image.PixelFormat);

            // Get the address of the first line.
            IntPtr ptr = bmpData.Scan0;

            int result;

            unsafe
            {
                result = registeredCameras[cameraPort].VideoWriter.AddFrame((byte*)ptr, 3 * image.Width * image.Height, image.Width, image.Height, sampleTime);
            }

            image.UnlockBits(bmpData);

            if (result != 0)
            {
                string message = String.Format("Failed to add frame for {0}. ResultCode: {1:x}", cameraPort.GetInfo().GetFriendlyName(), ((uint)result));
                logger.Log(message);

            }
        }
开发者ID:donnaknew,项目名称:programmingProject,代码行数:25,代码来源:AppSmartCam.cs


示例16: PortDeregistered

 public abstract void PortDeregistered(VPort port);
开发者ID:donnaknew,项目名称:programmingProject,代码行数:1,代码来源:VModule.cs


示例17: InstallCapability

 public abstract int InstallCapability(VCapability capability, VPort targetPort);
开发者ID:donnaknew,项目名称:programmingProject,代码行数:1,代码来源:VModule.cs


示例18: InstallCapability

 public override int InstallCapability(VCapability capability, VPort targetPort)
 {
     return _contract.InstallCapability(CapabilityAdapter.V2C(capability), PortAdapter.V2C(targetPort));
 }
开发者ID:smosgin,项目名称:labofthings,代码行数:4,代码来源:AModule.cs


示例19: OnNotification

        public override void OnNotification(string roleName, string opName, IList<VParamType> retVals, VPort senderPort)
        {
            string message;
            string sensorData;
            string sensorTag = senderPort.GetInfo().GetFriendlyName() + roleName;

            lock (this)
            {
                if (roleName.Contains(RoleSensor.RoleName) && opName.Equals(RoleSensor.OpGetName))
                {
                    byte rcvdNum = (byte)(int)retVals[0].Value();
                    sensorData = rcvdNum.ToString();

                }
                else if (roleName.Contains(RoleSensorMultiLevel.RoleName) && opName.Equals(RoleSensorMultiLevel.OpGetName))
                {
                    double rcvdNum = (double)retVals[0].Value();
                    sensorData = rcvdNum.ToString();
                }
                else
                {
                    sensorData = String.Format("Sensor: Invalid role->op {0}->{1} from {2}", roleName, opName, sensorTag);
                }

                try
                {
                    //Write to the stream
                    WriteToStream(sensorTag, sensorData);
                }
                catch (Exception exp)
                {
                    logger.Log("Sensor:{0}: WriteToStream failed. Exception caught.");
                    logger.Log(exp.ToString());
                }
            }

            //Create local list of alerts for display
            message = String.Format("{0}\t{1}\t{2}", DateTime.Now, sensorTag, sensorData);
            this.receivedMessageList.Enqueue(message);
            if (this.receivedMessageList.Count > gNumStringstoShow)
                this.receivedMessageList.Dequeue();
            logger.Log("Sensor\t{0}", message);

            //if applicable write the information to a local file.
            if (this.writingToLocalFile)
                WriteToLocalFile(message);

            //record latest data in our monitoring dictionary
            if (monitorDataValues.ContainsKey(sensorTag))
            {
                (monitorDataValues[sensorTag]).UpdateDataVal(sensorData);
            }
            else
            {
                monitorDataValues.Add(sensorTag, new MonitorDataVal(sensorData));
            }
        }
开发者ID:donnaknew,项目名称:programmingProject,代码行数:57,代码来源:Sensor.cs


示例20: Unsubscribe

 /// <summary>
 /// Unsubscribe from an operation exported by this port. Somebody else cannot unsubscribe 
 /// you unless they have the same response capability that was used to create the subscription.
 /// </summary>
 /// <param name="roleName">The name of the role that contains the operation</param>
 /// <param name="opName">The name of the operation being subscribed to</param>
 /// <param name="fromPort">The port to unsubscribe</param>
 /// <param name="respCap">The response capability that was used in the subscription</param>
 /// <returns>true if the port was subscribed and is now unsubscribed,
 /// false if the port was not subscribed</returns>
 public abstract bool Unsubscribe(string roleName, string opName, VPort fromPort, VCapability respCap);
开发者ID:smosgin,项目名称:labofthings,代码行数:11,代码来源:VPort.cs



注:本文中的HomeOS.Hub.Platform.Views.VPort类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Homespun.SimpleToken类代码示例发布时间:2022-05-26
下一篇:
C# Automation.ProgramBlock类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap