예제 #1
0
        public LightState parseResponse(string res)
        {
            LightState r = null;

            switch (res.ToUpper())
            {
            case "A00A":
                r = new LightState(name, false);
                break;

            case "A00B":
                r = new LightState(name, true);
                break;
            }
            return(r);
        }
예제 #2
0
        void 检查红灯状态(IPEndPoint ipEndPoint)
        {
            DeviceCommandManager.setCommandCallback(enumDeviceCommand.查询红灯状态,
                                                    (data) =>
            {
                Debug.WriteLine("红灯状态 => " + data);
                IDeviceCommand idc = DeviceCommandManager.getDeivceCommand(enumDeviceCommand.查询红灯状态);
                if (null != idc)
                {
                    LightState ls = idc.parseResponse(data);
                    if (null != ls)
                    {
                        if (ls.State)
                        {
                            string log = "红灯已经打开";
                            this.add_log(log);
                            Debug.WriteLine(log);
                            //RedLightService.last_effective_command = new command("open", "");
                            command cmd      = new command(stateName.打开, "");
                            cmd.TargetDevice = TargetDeiveName.红灯;
                            cmd.Initializing = "true";
                            this.sendInitialInfo(ws, cmd);
                        }
                        else
                        {
                            string log = "红灯已经关闭";
                            this.add_log(log);
                            Debug.WriteLine(log);

                            //RedLightService.last_effective_command = new command("close", "");
                        }
                    }
                }
            });
            DeviceCommandManager.executeCommand(enumDeviceCommand.查询红灯状态, ipEndPoint);
        }
예제 #3
0
 public LightState parseResponse(string res)
 {
     LightState r = null;
     switch (res.ToUpper())
     {
         case "A006":
             r = new LightState(name, false);
             break;
         case "A007":
             r = new LightState(name, true);
             break;
     }
     return r;
 }