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


C# VPort.ToString方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: PortDeregistered

 public override void PortDeregistered(VPort port)
 {
     lock (this)
     {
         if (Role.ContainsRole(port, RoleSensor.RoleName))
         {
             if (registeredSensors.ContainsKey(port))
             {
                 registeredSensors.Remove(port);
                 logger.Log("{0} removed sensor port {1}", this.ToString(), port.ToString());
             }
         }
         if (Role.ContainsRole(port, RoleActuator.RoleName))
         {
             if (registeredActuators.ContainsKey(port))
             {
                 registeredActuators.Remove(port);
                 logger.Log("{0} removed actuator port {1}", this.ToString(), port.ToString());
             }
         }
     }
 }
开发者ID:smosgin,项目名称:labofthings,代码行数:22,代码来源:AppThermometer.cs

示例6: 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

示例7: 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

示例8: OnNotification

        public override void OnNotification(string roleName, string opName, IList<VParamType> retVals, VPort senderPort)
        {
            lock (this)
            {
                //check if notification is speech event
                if (roleName.Contains(RoleSpeechReco.RoleName) && opName.Equals(RoleSpeechReco.OpPhraseRecognizedSubName))
                { 
                    string rcvdCmd = (string)retVals[0].Value();
   
                    switch (rcvdCmd)
                    {
                       case "ALLON":
                            SetAllSwitches(1.0);
                           break;

                        case "ALLOFF":
                           SetAllSwitches(0.0); 
                        break;

                        case "PLAYMOVIE":
                            SetAllSwitches(0.1);
                        break;

                        case "DISCO":
                            DiscoSwitches();
                        break;

                    }
                    return;
                }

                if (!registeredSwitches.ContainsKey(senderPort))
                    throw new Exception("Got notification from an unknown port " + senderPort.ToString());

                switch (opName)
                {
                    case RoleSwitchBinary.OpGetName:
                        {
                            if (retVals.Count >= 1 && retVals[0].Value() != null)
                            {
                                bool level = (bool)retVals[0].Value();

                                registeredSwitches[senderPort].Level = (level)? 1 : 0;
                            }
                            else
                            {
                                logger.Log("{0} got bad result for getlevel subscription from {1}", this.ToString(), senderPort.ToString());
                            }
                        }
                        break;
                    case RoleSwitchMultiLevel.OpGetName:
                        {
                            if (retVals.Count >= 1 && retVals[0].Value() != null)
                            {
                                double level = (double)retVals[0].Value();

                                registeredSwitches[senderPort].Level = level;
                            }
                            else
                            {
                                logger.Log("{0} got bad result for getlevel subscription from {1}", this.ToString(), senderPort.ToString());
                            }
                        }
                        break;
                    case RoleLightColor.OpGetName:
                        {
                            if (!registeredSwitches[senderPort].IsColored)
                            {
                                logger.Log("Got {0} for non-colored switch {1}", opName, senderPort.ToString());

                                return;
                            }

                            if (retVals.Count >= 3)
                            {
                                byte red, green, blue;

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

                                registeredSwitches[senderPort].Color = Color.FromArgb(red, green, blue);
                            }
                            else
                            {
                                logger.Log("{0} got bad result for getlevel subscription from {1}", this.ToString(), senderPort.ToString());
                            }
                        }
                        break;
                    default:
                        logger.Log("Got notification from incomprehensible operation: " + opName);
                        break;
                }
            }
        }
开发者ID:donnaknew,项目名称:programmingProject,代码行数:95,代码来源:SwitchController.cs

示例9: ForgetCamera

        //called when the lock is acquired
        private void ForgetCamera(VPort cameraPort)
        {
            cameraFriendlyNames.Remove(cameraPort.GetInfo().GetFriendlyName());

            //stop recording if we have a video make object
            StopRecording(cameraPort, true);

            registeredCameras.Remove(cameraPort);

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

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

示例10: DeregisterPort

        /// <summary>
        /// Deregister a port to declare it unavailable for use by other modules
        /// </summary>
        /// <param name="port">The port to deregisted</param>
        /// <param name="owner">The module to which the port belongs</param>
        /// <returns></returns>
        public int DeregisterPort(VPort port, VModule module)
        {
            ResultCode result;

            lock (this)
            {
                if (registeredPorts.ContainsKey(port))
                {
                    if (module.Equals(registeredPorts[port]))
                    {
                        logger.Log("deregistering port: {0}", port.ToString());
                        registeredPorts.Remove(port);

                        result = ResultCode.Success;
                    }
                    else
                    {
                        logger.Log("got port deregisteration for {0} from a non-owner {1}", port.ToString(), module.ToString());

                        result = ResultCode.Failure;
                    }
                }
                else
                {
                    logger.Log("got deregisteration for unregistered port: {0}", port.ToString());

                    result = ResultCode.PortNotFound;
                }
            }

            if (result == ResultCode.Success)
            {
                
                BroadcastPortDeregistration(port, module); 
                // broadcast needs to be asyncronous because the module's addin (and appdomain, ports, etc) will be wiped
                /*
                System.Threading.Thread newThread = new System.Threading.Thread(delegate() { 
                 //   System.Threading.Thread.Sleep(Settings.portRegisterDelay); 
                    BroadcastPortDeregistration(port, module); });
                newThread.Name = "Deregister Port " + port;
                newThread.Start(); */
            }

            return (int)result;
        }
开发者ID:donnaknew,项目名称:programmingProject,代码行数:51,代码来源:Platform.cs

示例11: RemoteInstallCapability

        /// <summary>
        /// Install the capability on the port
        /// </summary>
        /// <param name="capability">The capability to install</param>
        /// <param name="targetPort">The port on which to install</param>
        /// <returns>If the install succeeded</returns>
        private bool RemoteInstallCapability(Capability capability, VPort targetPort)
        {
            VModule targetModule = null;

            lock (this)
            {
                if (registeredPorts.ContainsKey(targetPort))
                {
                    targetModule = registeredPorts[targetPort];
                }
            }

            if (targetModule == null)
            {
                logger.Log("Platform could not find the target module for port {0}", targetPort.ToString());
                return false;
            }

            ResultCode result = (ResultCode) targetModule.InstallCapability(capability, targetPort);

            if (result == ResultCode.Success) {
                return true;
            }
            else
            {
                logger.Log("RemoteCapabilityInstall failed: {0}", result.ToString());
                return false;
            }
        }
开发者ID:donnaknew,项目名称:programmingProject,代码行数:35,代码来源:Platform.cs

示例12: PortRegistered

        /// <summary>
        ///  Called when a new port is registered with the platform
        /// </summary>
        /// <param name="port"></param>
        public override void PortRegistered(VPort port)
        {
            lock (this)
            {
                if (Role.ContainsRole(port, RoleSwitchMultiLevel.RoleName) ||
                    Role.ContainsRole(port, RoleSwitchBinary.RoleName) ||
                    Role.ContainsRole(port, RoleLightColor.RoleName))
                {
                    if (!registeredSwitches.ContainsKey(port) &&
                        GetCapabilityFromPlatform(port) != null)
                    {
                        var switchType = (Role.ContainsRole(port, RoleSwitchMultiLevel.RoleName)) ? SwitchType.Multi : SwitchType.Binary;

                        bool colored = Role.ContainsRole(port, RoleLightColor.RoleName);

                        InitSwitch(port, switchType, colored);
                    }
                   
                }

                else if (Role.ContainsRole(port, RoleSpeechReco.RoleName))
                {

                    if (!speechPorts.Contains(port) &&
                        GetCapabilityFromPlatform(port) != null)
                    {

                        speechPorts.Add(port);

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


                        //TODO Call it with phrases we care about - FOR NOW HARD CODED in Kinect driver
                        //  var retVal = Invoke(port, RoleSpeechReco.Instance, RoleSpeechReco.OpSetSpeechPhraseName, new ParamType(ParamType.SimpleType.text, "on"));

                        //subscribe to speech reco
                        if (Subscribe(port, RoleSpeechReco.Instance, RoleSpeechReco.OpPhraseRecognizedSubName))
                            logger.Log("{0} subscribed to port {1}", this.ToString(), port.ToString());
                    }
                }
            }
        }
开发者ID:donnaknew,项目名称:programmingProject,代码行数:46,代码来源:SwitchController.cs

示例13: RegisterPort

        /// <summary>
        /// Function call to register a port. Called by modules to activate new ports or to register changes in status.
        /// </summary>
        /// <param name="port"></param>
        /// <returns></returns>
        public int RegisterPort(VPort port, VModule module)
        {
            ResultCode result;

            lock (this)
            {
                if (registeredPorts.ContainsKey(port))
                {
                    logger.Log(this + " got registration for an existing port: {0}", port.ToString());
                    result = ResultCode.Failure;
                }
                else
                {
                    if (runningModules.ContainsKey(module))
                    {
                        registeredPorts[port] = module;
                        logger.Log(this + " added {0} from {1}", port.ToString(), module.ToString());
                        result = ResultCode.Success;
                    }
                    else
                    {
                        logger.Log(this + " got port {0} registeration request from non-existent module {1}", port.ToString(), module.ToString());
                        result = ResultCode.ModuleNotFound;
                    }
                }
            }

            if (result == ResultCode.Success)
            {
                SafeThread newThread = new SafeThread(delegate() {
         //           System.Threading.Thread.Sleep(Settings.portRegisterDelay);
                    BroadcastPortRegistration(port, module);
                }, "RegisterPort " + port , logger);
                newThread.Start();
            }

            return (int) result;
        }
开发者ID:donnaknew,项目名称:programmingProject,代码行数:43,代码来源:Platform.cs

示例14: SendEchoRequest

        public void SendEchoRequest(VPort port, int counter)
        {
            try
            {
                DateTime requestTime = DateTime.Now;

                var retVals = Invoke(port, RoleDummy2.Instance, RoleDummy2.OpEchoName, new ParamType(counter));

                double diffMs = (DateTime.Now - requestTime).TotalMilliseconds;

                if (retVals[0].Maintype() != (int)ParamType.SimpleType.error)
                {

                    int rcvdNum = (int) retVals[0].Value();

                    logger.Log("echo success to {0} after {1} ms. sent = {2} rcvd = {3}", port.ToString(), diffMs.ToString(), counter.ToString(), rcvdNum.ToString());
                }
                else
                {
                    logger.Log("echo failure to {0} after {1} ms. sent = {2} error = {3}", port.ToString(), diffMs.ToString(), counter.ToString(), retVals[0].Value().ToString());
                }

            }
            catch (Exception e)
            {
                logger.Log("Error while calling echo request: {0}", e.ToString());
            }
        }
开发者ID:smosgin,项目名称:labofthings,代码行数:28,代码来源:Dummy2.cs

示例15: 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.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。