internal static void DecodeIncoming(string incomingMessage, ILightSwitchChannel protocol)
        {
            if (incomingMessage.Length == 0)
                return;

            string cmd = incomingMessage.TrimEnd(Environment.NewLine.ToCharArray()).ToUpper();
            string[] commandSegments = cmd.Split('~');

            if (commandSegments[0].Equals("IPHONE"))
                protocol.OnIphone();
            else if (commandSegments[0].Equals("PASSWORD") && commandSegments.Length == 2)
                protocol.OnPassword(commandSegments[1]);
            else if (commandSegments[0].Equals("VERSION"))
                protocol.OnVersion();
            else if (commandSegments[0].Equals("SERVER"))
                protocol.OnServer();
            else if (commandSegments[0].Equals("TERMINATE"))
                protocol.OnTerminate();
            else if (commandSegments[0].Equals("ALIST"))  //DEVICES, SCENES AND ZONES.
                protocol.OnAList();
            else if (commandSegments[0].Equals("LIST")) //DEVICES
                protocol.OnList();
            else if (commandSegments[0].Equals("SLIST"))  //SCENES
                protocol.OnSList();
            else if (commandSegments[0].Equals("ZLIST")) //ZONES
                protocol.OnZList();
            else if (commandSegments[0].Equals("DEVICE") && commandSegments.Length == 4)
                protocol.OnDevice(commandSegments[1], commandSegments[2], commandSegments[3]);
            else if (commandSegments[0].Equals("SCENE") && commandSegments.Length == 2)
                protocol.OnScene(commandSegments[1]);
            else if (commandSegments[0].Equals("ZONE") && commandSegments.Length == 3)
                protocol.OnZone(commandSegments[1], commandSegments[2]);
            else if (commandSegments[0].Equals("THERMMODE") && commandSegments.Length == 4)
                protocol.OnThermMode(commandSegments[1], commandSegments[2], commandSegments[3]);
            else if (commandSegments[0].Equals("THERMTEMP") && commandSegments.Length == 5)
                protocol.OnThermTemp(commandSegments[1], commandSegments[2], commandSegments[3], commandSegments[4]);
        }
예제 #2
0
        internal static void DecodeIncoming(string incomingMessage, ILightSwitchChannel protocol)
        {
            if (incomingMessage.Length == 0)
            {
                return;
            }

            string cmd = incomingMessage.TrimEnd(Environment.NewLine.ToCharArray()).ToUpper();

            string[] commandSegments = cmd.Split('~');

            if (commandSegments[0].Equals("IPHONE"))
            {
                protocol.OnIphone();
            }
            else if (commandSegments[0].Equals("PASSWORD") && commandSegments.Length == 2)
            {
                protocol.OnPassword(commandSegments[1]);
            }
            else if (commandSegments[0].Equals("VERSION"))
            {
                protocol.OnVersion();
            }
            else if (commandSegments[0].Equals("SERVER"))
            {
                protocol.OnServer();
            }
            else if (commandSegments[0].Equals("TERMINATE"))
            {
                protocol.OnTerminate();
            }
            else if (commandSegments[0].Equals("ALIST"))  //DEVICES, SCENES AND ZONES.
            {
                protocol.OnAList();
            }
            else if (commandSegments[0].Equals("LIST")) //DEVICES
            {
                protocol.OnList();
            }
            else if (commandSegments[0].Equals("SLIST"))  //SCENES
            {
                protocol.OnSList();
            }
            else if (commandSegments[0].Equals("ZLIST")) //ZONES
            {
                protocol.OnZList();
            }
            else if (commandSegments[0].Equals("DEVICE") && commandSegments.Length == 4)
            {
                protocol.OnDevice(commandSegments[1], commandSegments[2], commandSegments[3]);
            }
            else if (commandSegments[0].Equals("SCENE") && commandSegments.Length == 2)
            {
                protocol.OnScene(commandSegments[1]);
            }
            else if (commandSegments[0].Equals("ZONE") && commandSegments.Length == 3)
            {
                protocol.OnZone(commandSegments[1], commandSegments[2]);
            }
            else if (commandSegments[0].Equals("THERMMODE") && commandSegments.Length == 4)
            {
                protocol.OnThermMode(commandSegments[1], commandSegments[2], commandSegments[3]);
            }
            else if (commandSegments[0].Equals("THERMTEMP") && commandSegments.Length == 5)
            {
                protocol.OnThermTemp(commandSegments[1], commandSegments[2], commandSegments[3], commandSegments[4]);
            }
        }