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); //FanService.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); FanService.last_effective_command = new command("close", ""); } } } }); DeviceCommandManager.executeCommand(enumDeviceCommand.查询风扇状态, ipEndPoint); }
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) { switch (ls.State) { case true: if (myCommand != null) { myCommand.Name = stateName.打开; } this.invokeCallback(myCommand); break; case false: if (myCommand != null) { myCommand.Name = stateName.关闭; } this.invokeCallback(myCommand); break; } } } }); DeviceCommandManager.executeCommand(enumDeviceCommand.查询风扇状态, ipEndPoint, 1000); }
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); EngineService.last_effective_command = new command("open", ""); } else { string log = "电机已经关闭"; this.add_log(log); Debug.WriteLine(log); EngineService.last_effective_command = new command("close", ""); } } } }); DeviceCommandManager.executeCommand(enumDeviceCommand.查询电机状态, ipEndPoint); }