当前位置: 首页>>代码示例>>C#>>正文


C# VPort.Subscribe方法代码示例

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


在下文中一共展示了VPort.Subscribe方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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:donnaknew,项目名称:programmingProject,代码行数:35,代码来源:AppThermometer.cs

示例2: InitCamera

        //called when the lock is acquired and cameraPort is non-existent in the dictionary
        private void InitCamera(VPort cameraPort)
        {
            VCapability capability = GetCapability(cameraPort, Constants.UserSystem);

            //return if we didn't get a capability
            if (capability == null)
            {
                logger.Log("{0} didn't get a capability for {1}", this.ToString(), cameraPort.ToString());

                return;
            }

            //otherwise, add this to our list of cameras

            logger.Log("{0} adding camera port {1}", this.ToString(), cameraPort.ToString());

            CameraInfo cameraInfo = new CameraInfo();
            cameraInfo.Capability = capability;
            cameraInfo.LastImageBytes = new byte[0];
            cameraInfo.VideoWriter = null;
            cameraInfo.CurrVideoStartTime = DateTime.MinValue;
            cameraInfo.CurrVideoEndTime = DateTime.MinValue;

            registeredCameras.Add(cameraPort, cameraInfo);

            string cameraFriendlyName = cameraPort.GetInfo().GetFriendlyName();
            cameraFriendlyNames.Add(cameraFriendlyName, cameraPort);

            cameraPort.Subscribe(RoleCamera.RoleName, RoleCamera.OpGetVideo, ControlPort, cameraInfo.Capability, ControlPortCapability);
        }
开发者ID:donnaknew,项目名称:programmingProject,代码行数:31,代码来源:AppSmartCam.cs

示例3: PortRegistered

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

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

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

                //lets not monitor switches
                //if (Role.ContainsRole(port, RoleSwitchMultiLevel.RoleName))
                //{
                //    if (port.GetInfo().GetFriendlyName().Equals(switchFriendlyName, StringComparison.CurrentCultureIgnoreCase))
                //    {
                //        switchPort = port;
                //        switchPortCapability = GetCapability(port, Constants.UserSystem);

                //        if (switchPortCapability != null)
                //        {
                //            switchPort.Subscribe(RoleSwitchMultiLevel.RoleName, RoleSwitchMultiLevel.OpGetName,
                //                this.ControlPort, switchPortCapability, this.ControlPortCapability);
                //        }
                //    }
                //}

                if (Role.ContainsRole(port, RoleSensor.RoleName))
                {
                    //if (port.GetInfo().GetFriendlyName().Equals(sensorFriendlyName, StringComparison.CurrentCultureIgnoreCase))
                    //{
                    //    sensorPort = port;
                    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);
                    }
                    //}
                }

            }
        }
开发者ID:smosgin,项目名称:labofthings,代码行数:54,代码来源:AppAlerts.cs

示例4: InitSwitch

        void InitSwitch(VPort switchPort, SwitchType switchType, bool isColored)
        {

            logger.Log("{0} adding switch {1} {2}", this.ToString(), switchType.ToString(), switchPort.ToString());

            SwitchInfo switchInfo = new SwitchInfo();
            switchInfo.Capability = GetCapability(switchPort, Constants.UserSystem);
            switchInfo.Level = 0;
            switchInfo.Type = switchType;

            switchInfo.IsColored = isColored;
            switchInfo.Color = Color.Black;

            registeredSwitches.Add(switchPort, switchInfo);

            string switchFriendlyName = switchPort.GetInfo().GetFriendlyName();
            switchFriendlyNames.Add(switchFriendlyName, switchPort);

            if (switchInfo.Capability != null)
            {
                IList<VParamType> retVals;

                if (switchType == SwitchType.Multi)
                {
                    retVals = switchPort.Invoke(RoleSwitchMultiLevel.RoleName, RoleSwitchMultiLevel.OpGetName, null,
                    ControlPort, switchInfo.Capability, ControlPortCapability);

                    switchPort.Subscribe(RoleSwitchMultiLevel.RoleName, RoleSwitchMultiLevel.OpGetName, ControlPort, switchInfo.Capability, ControlPortCapability);

                    if (retVals[0].Maintype() < 0)
                    {
                        logger.Log("SwitchController could not get current level for {0}", switchFriendlyName);
                    }
                    else
                    {
                        switchInfo.Level = (double)retVals[0].Value();
                    }
                }
                else
                {
                    retVals = switchPort.Invoke(RoleSwitchBinary.RoleName, RoleSwitchBinary.OpGetName, null,
                    ControlPort, switchInfo.Capability, ControlPortCapability);

                    switchPort.Subscribe(RoleSwitchBinary.RoleName, RoleSwitchBinary.OpGetName, ControlPort, switchInfo.Capability, ControlPortCapability);

                    if (retVals[0].Maintype() < 0)
                    {
                        logger.Log("SwitchController could not get current level for {0}", switchFriendlyName);
                    }
                    else
                    {
                        bool boolLevel = (bool)retVals[0].Value();
                        switchInfo.Level = (boolLevel) ? 1 : 0;
                    }
                }

                //fix the color up now

                if (isColored)
                {
                    var retValsColor = switchPort.Invoke(RoleLightColor.RoleName, RoleLightColor.OpGetName, null,
                                                          ControlPort, switchInfo.Capability, ControlPortCapability);

                    switchPort.Subscribe(RoleLightColor.RoleName, RoleLightColor.OpGetName, ControlPort, switchInfo.Capability, ControlPortCapability);

                    if (retVals[0].Maintype() < 0)
                    {
                        logger.Log("SwitchController could not get color for {0}", switchFriendlyName);
                    }
                    else
                    {
                        byte red, green, blue;

                        red = Math.Min(Math.Max((byte)(int)retValsColor[0].Value(), (byte)0), (byte)255);
                        green = Math.Min(Math.Max((byte)(int)retValsColor[1].Value(), (byte)0), (byte)255);
                        blue = Math.Min(Math.Max((byte)(int)retValsColor[2].Value(), (byte)0), (byte)255);

                        switchInfo.Color = Color.FromArgb(red, green, blue);
                    }
                }
            }
        }
开发者ID:donnaknew,项目名称:programmingProject,代码行数:82,代码来源:AppArduinoCam.cs


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