コード例 #1
0
ファイル: LifxBulb.cs プロジェクト: loredous/LIFX-Sharp
        public LifxLightStatus GetLightStatus()
        {

            LifxGetLightStatusCommand command = new LifxGetLightStatusCommand();

            LifxCommunicator.Instance.SendCommand(command, this);

            LifxLightStatusMessage lsMessage = (LifxLightStatusMessage)command.ReturnMessage;

            //HSLColor hslColor = new HSLColor((double)(lsMessage.Hue * 240 / 65535), (double)(lsMessage.Saturation * 240 / 65535), (double)(lsMessage.Lumnosity * 240 / 65535));

            LifxColor color = new LifxColor(lsMessage.Hue, lsMessage.Saturation, lsMessage.Lumnosity, lsMessage.Kelvin);

            LifxLightStatus lightsStatus = new LifxLightStatus(color, lsMessage.PowerState, lsMessage.Dim, lsMessage.Label, lsMessage.Tags);

            return lightsStatus;
                
        }
コード例 #2
0
        /// <summary>
        /// Discovers the PanControllers (including their bulbs)
        /// </summary>
        /// <returns>List of bulbs</returns>
        public List<LifxPanController> Discover()
        {
            LifxGetPANGatewayCommand getPANCommand = new LifxGetPANGatewayCommand();

           mFoundPanHandlers.Clear();
           mTimeoutMilliseconds = 1500;
           int savedTimeout = mTimeoutMilliseconds;

           try
           {

               SendCommand(getPANCommand, LifxPanController.UninitializedPanController);

               foreach (LifxPanController controller in mFoundPanHandlers)
               {
                   LifxGetLightStatusCommand getBulbs = new LifxGetLightStatusCommand();
                   getBulbs.IsDiscoveryCommand = true;

                   SendCommand(getBulbs, controller);
               
               }

               return mFoundPanHandlers;
           }
           catch (Exception e)
           {
               //In case of any other exception, re-throw
               throw e;
           }
           finally 
           {
               mTimeoutMilliseconds = savedTimeout;
           }
            
            
        }