| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using HDL_ON.DAL; |
| | | using HDL_ON.DAL.Net; |
| | | using HDL_ON.Entity.Enumerative; |
| | | using HDL_ON.Entity; |
| | | using Shared; |
| | | using Shared.Net; |
| | | |
| | | namespace HDL_ON |
| | | { |
| | | public partial class Control |
| | | { |
| | | public System.DateTime LatestDateTime = System.DateTime.Now; |
| | | public DateTime LatestDateTime = DateTime.Now; |
| | | |
| | | /// <summary> |
| | | /// 所有微信对一端口的控制都会放到这个集合里 |
| | | /// </summary> |
| | | private static List<Control> controlList = new List<Control>(50); |
| | | |
| | | /// <summary> |
| | | /// 发送数据,等待有反馈 |
| | | /// </summary> |
| | | /// <returns>The bytes send has return.</returns> |
| | | static byte[] ControlBytesSendHasReturn(Command command, byte subnetID, byte deviceID, byte[] gatewayBytes, int sendCount = 3) |
| | | { |
| | | Control control = new Control(); |
| | | control.Send(new Target() |
| | | { |
| | | IPEndPoint = CommonPage.EndPoint, |
| | | Command = command, |
| | | SubnetID = subnetID, |
| | | DeviceID = deviceID, |
| | | AddData = gatewayBytes, |
| | | }, sendCount, true); |
| | | CommonPage.FindGateway = false; |
| | | |
| | | return control.UsefulBytes; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 发送数据,不需要等待回复 |
| | |
| | | DeviceID = deviceID, |
| | | AddData = gatewayBytes, |
| | | }, sendCount, false); |
| | | CommonPage.FindGateway = false; |
| | | MainPage.Log(command.ToString() + "::" + CommonPage.EndPoint.ToString()); |
| | | |
| | | } |
| | | /// <summary> |
| | | /// 000E 搜索回复 |
| | | /// </summary> |
| | | /// <param name="usefullBytes"></param> |
| | | static void ReceiveReadRemark(byte[] usefullBytes) |
| | | { |
| | | try |
| | | { |
| | | //账号没登录不回复 |
| | | if (MainPage.LoginUser == null || !MainPage.LoginUser.IsLogin) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | //if (!isHttpListenerStart) |
| | | //{ |
| | | // //数据接收端口没打开,不回复 |
| | | // return; |
| | | //} |
| | | |
| | | var sendStr = MainPage.LoginUser.accountString; |
| | | |
| | | |
| | | //如果IP地址获取成功 显示最后一位 |
| | | var mAddressBytes = new Shared.Net.NetWiFi().IpAddress.GetAddressBytes(); |
| | | if (mAddressBytes != null && mAddressBytes.Length == 4) |
| | | { |
| | | sendStr = (mAddressBytes[3] & 0xFF).ToString() + ":" + sendStr; |
| | | } |
| | | |
| | | if (usefullBytes.Length <= 2) |
| | | { |
| | | byte[] sendBytes = new byte[20]; |
| | | byte[] b1 = CommonPage.MyEncodingGB2312.GetBytes(sendStr); |
| | | Array.Copy(b1, 0, sendBytes, 0, 20 < b1.Length ? 20 : b1.Length); |
| | | Control.ControlBytesSend(Command.ReadRemarkACK, 0xFF, 0xFF, sendBytes, 1); |
| | | |
| | | } |
| | | else |
| | | { |
| | | |
| | | for (int i = 2, len = usefullBytes.Length; i < len; i++) |
| | | { |
| | | if (i % 2 == 0) |
| | | { |
| | | if ((usefullBytes[i] & 0xFF) == 0xFC |
| | | && (usefullBytes[i + 1] & 0xFF) == 0xFC |
| | | ) |
| | | { |
| | | |
| | | byte[] sendBytes = new byte[20]; |
| | | byte[] b1 = CommonPage.MyEncodingGB2312.GetBytes(sendStr); |
| | | //Remote_GroupName = CommonPage.MyEncodingGB2312.GetString (b1); |
| | | Array.Copy(b1, 0, sendBytes, 0, 20 < b1.Length ? 20 : b1.Length); |
| | | Control.ControlBytesSend(Command.ReadRemarkACK, 0xFF, 0xFF, sendBytes, 1); |
| | | |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | catch { } |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | { |
| | | string receiveFlag = string.Format("{0},{1},{2},", subnetID, deviceID, (int)command); |
| | | |
| | | switch ((Command)command) |
| | | switch (command) |
| | | { |
| | | case Command.YIPanelDeviceInofACK: |
| | | for (int i = 0; i < 4; i++) |
| | | { |
| | | receiveFlag += string.Format("{0}", usefulBytes[i]); |
| | | } |
| | | break; |
| | | case Command.ReadDoorLockSceneObjACK: |
| | | receiveFlag += string.Format("{0},{1},{2},{3},{4}", usefulBytes[0], usefulBytes[1], usefulBytes[2], usefulBytes[3], usefulBytes[4]); |
| | | break; |
| | | case Command.ReadDoorLockClockACK: |
| | | case Command.CreatConnectionACK: |
| | | case Command.SetSingleLightACK: |
| | | receiveFlag += string.Format("{0}", usefulBytes[0]); |
| | | break; |
| | | //门锁,BroadcastDoorLockStateAndAlarm |
| | | //广播门锁状态和报警, |
| | | case Command.BroadcastDoorLockStateAndAlarm://广播门锁状态和报警 |
| | | receiveFlag += string.Format("{0},{1}", usefulBytes[0], usefulBytes[1]); |
| | | break; |
| | | case Command.ReadDoorLockUseRemarkACK: |
| | | case Command.ReadSensorPushMessageACK: |
| | | case Command.SetSensorPushMessageACK: |
| | | case Command.ReadSensorScenceACK: |
| | | case Command.ReadAnalogACK: |
| | | case Command.SetLogicLoopColorACK: |
| | | receiveFlag += string.Format("{0},{1},{2}", usefulBytes[0], usefulBytes[1], usefulBytes[2]); |
| | | break; |
| | | case Command.SetSensorScenceACK: |
| | | receiveFlag += string.Format("{0},{1},{2}", usefulBytes[1], usefulBytes[2], usefulBytes[3]); |
| | | break; |
| | | case Command.SendRemoteInfoToServerACK: |
| | | for (int i = 1; i < 9; i++) |
| | | { |
| | | receiveFlag += string.Format("{0}", usefulBytes[i]); |
| | | } |
| | | break; |
| | | case Command.BroadcastDryContactStatus://由干接点广播出来的数据,程序不做回复。 |
| | | receiveFlag += string.Format("{0}", usefulBytes[0]); |
| | | break; |
| | | case Command.SetSceneACK: |
| | | receiveFlag += string.Format("{0},{1}", usefulBytes[0], usefulBytes[1]); |
| | | break; |
| | | case Command.SetSeriesACK: |
| | | receiveFlag += string.Format("{0},{1}", usefulBytes[0], usefulBytes[1]); |
| | | break; |
| | | case Command.UpdataCurtainModelStutasACK: |
| | | case Command.SetHotelCurtainACK: |
| | | case Command.DownloadInfraredACK: |
| | | case Command.SetSensorPushValuesACK: |
| | | case Command.ReadSensorPushValuesACK: |
| | | receiveFlag += string.Format("{0},{1}", usefulBytes[0], usefulBytes[1]); |
| | | break; |
| | | case Command.ReadLightEquipmentAllLoopBrightnessACK: |
| | | break; |
| | | case Command.SetSingleLightACK: |
| | | receiveFlag += string.Format("{0},{1}", usefulBytes[0], usefulBytes[2]); |
| | | break; |
| | | case Command.UpLoadInfraredACK: |
| | | receiveFlag += string.Format("{0},{1}", usefulBytes[0], usefulBytes[1]); |
| | | break; |
| | | case Command.SetCommonACK: |
| | | case Command.InfraredChannelControlACK: |
| | | case Command.ReadLogicLoopColorACK: |
| | | case Command.ReadACModeACK: |
| | | case Command.SetACModeACK: |
| | | case Command.Serverx_FH_CMD_ACK: |
| | | case Command.ReadSensorHistoryACK: |
| | | case Command.SetSensorAutomationTargetLevelEnableACK: |
| | | case Command.ReadSensorAutomationLevelTargetEnableACK: |
| | | case Command.ReadFloorHeatACK: |
| | | case Command.SetFloorHeatACK: |
| | | receiveFlag += string.Format("{0}", usefulBytes[0]); |
| | | break; |
| | | case Command.ReadFoolHeatACK: |
| | | case Command.SetFoolHeatACK: |
| | | case Command.SetArmACK: |
| | | case Command.ReadArmACK: |
| | | receiveFlag += string.Format("{0}", usefulBytes[0]); |
| | | case Command.ReadRemark: |
| | | //buspro 读备注回复 |
| | | ReceiveReadRemark(usefulBytes); |
| | | break; |
| | | case Command.ReadDeviceModulACK: |
| | | case Command.ReadGatewayACK: |
| | | case Command.ReadSecurityStatusACK: |
| | | receiveFlag = string.Format("{0},{1}", usefulBytes[0], usefulBytes[1]); |
| | | break; |
| | | case Command.UpdataLightDimmingTheLargestLevelACK: |
| | | case Command.UpdataLightDimmingMaximumOrMinimumACK: |
| | | case Command.WriteManageWirelessNetACK: |
| | | case Command.ReadGateWayModelInfoACK: |
| | | case Command.ReadGatewayServerIPACK: |
| | | case Command.SetGateWayModelInfoACK: |
| | | case Command.SetGateWayModelInternetInfoACK: |
| | | case Command.ReadDeviceMacACK: |
| | | case Command.SetDeviceSubnetIDACK: |
| | | case Command.PositioningEquipmentACK: |
| | | case Command.PositioningPanelACK: |
| | | case Command.GotoConfigModeACK: |
| | | case Command.CheckConfigSuccessACK: |
| | | case Command.SetACPanelACK: |
| | | case Command.ReadACPanelACK: |
| | | case Command.ReadTerrestriaHeatRemarkACK: |
| | | case Command.UpdateGatewayIpACK: |
| | | case Command.ReadWirelessPanelModeACK: |
| | | case Command.ReadDrycontactModeACK: |
| | | case Command.ReadACFloorHeatingSettingEquipmentACK: |
| | | case Command.SetACFloorHeatingSettingEquipmentACK: |
| | | case Command.Read43FloorHeatingSettingEquipmentACK: |
| | | case Command.Set43FloorHeatingSettingEquipmentACK: |
| | | case Command.READ_AIR_ALL_Parameter_ack: |
| | | case Command.Set_AIR_ALL_Parameter_ack: |
| | | case Command.ReadFloorHeatProbeACK: |
| | | case Command.ReadButtonKeyEnableACK: |
| | | case Command.UpdateLightDimmingLoopRemakeACK: |
| | | case Command.ReadMusicPanelSettingACK: |
| | | case Command.ReadMusicPanelEnableACK: |
| | | case Command.SetMusicPanelEnableACK: |
| | | case Command.SetMusicPanelSettingACK: |
| | | case Command.SetGatewayACK: |
| | | case Command.ReadGatewayProgrammingModeACK: |
| | | case Command.RED_HSFH_TOTAL_ACK: |
| | | case Command.RED_HSFH_INFORMATION_ACK: |
| | | case Command.RED_HSRM_TOTAL_ACK: |
| | | case Command.RED_HSRM_INFORMATION_ACK: |
| | | case Command.CLEAR_SYSTEM_HISTORY_ACK: |
| | | case Command.SetSensorTargetRemarkACK: |
| | | case Command.ReadSensorAutomationEnableListACK: |
| | | case Command.SetSensorAutomationEnableListACK: |
| | | case Command.SetSensorAutomationListIDACK: |
| | | case Command.ReadSensorAutomationListIDACK: |
| | | case Command.ReadSensorAutomationNameACK: |
| | | case Command.SetSensorAutomationNameACK: |
| | | case Command.Set_Floor_Heat_State_ack: |
| | | case Command.Read_Floor_Heat_State_ack: |
| | | case Command.Read_Air_Condition_Set_ack: |
| | | case Command.HornAlarmBroadcast: |
| | | case Command.ReadHornLoopCountACK: |
| | | case Command.UpdateHornLoopRemakeACK: |
| | | case Command.ReadPanelTempTypeACK: |
| | | receiveFlag += ""; |
| | | break; |
| | | case Command.ControlMusicModel1ACK: |
| | | receiveFlag += ""; |
| | | break; |
| | | case Command.ControlMusicModel2ACK: |
| | | for (int i = 1; i < usefulBytes.Length; i++) |
| | | { |
| | | if (usefulBytes[i + 1] == 44) |
| | | { |
| | | break; |
| | | } |
| | | receiveFlag += string.Format("{0},", usefulBytes[i]); |
| | | } |
| | | break; |
| | | //case Command.YIPanelDeviceInofACK: |
| | | // for (int i = 0; i < 4; i++) |
| | | // { |
| | | // receiveFlag += string.Format("{0}", usefulBytes[i]); |
| | | // } |
| | | // break; |
| | | //case Command.ReadDoorLockSceneObjACK: |
| | | // receiveFlag += string.Format("{0},{1},{2},{3},{4}", usefulBytes[0], usefulBytes[1], usefulBytes[2], usefulBytes[3], usefulBytes[4]); |
| | | // break; |
| | | //case Command.ReadDoorLockClockACK: |
| | | //case Command.CreatConnectionACK: |
| | | // receiveFlag += string.Format("{0}", usefulBytes[0]); |
| | | // break; |
| | | ////门锁,BroadcastDoorLockStateAndAlarm |
| | | ////广播门锁状态和报警, |
| | | //case Command.BroadcastDoorLockStateAndAlarm://广播门锁状态和报警 |
| | | // receiveFlag += string.Format("{0},{1}", usefulBytes[0], usefulBytes[1]); |
| | | // break; |
| | | //case Command.ReadDoorLockUseRemarkACK: |
| | | //case Command.ReadSensorPushMessageACK: |
| | | //case Command.SetSensorPushMessageACK: |
| | | //case Command.ReadSensorScenceACK: |
| | | //case Command.ReadAnalogACK: |
| | | // receiveFlag += string.Format("{0},{1},{2}", usefulBytes[0], usefulBytes[1], usefulBytes[2]); |
| | | // break; |
| | | //case Command.SetSensorScenceACK: |
| | | // receiveFlag += string.Format("{0},{1},{2}", usefulBytes[1], usefulBytes[2], usefulBytes[3]); |
| | | // break; |
| | | //case Command.SendRemoteInfoToServerACK: |
| | | // for (int i = 1; i < 9; i++) |
| | | // { |
| | | // receiveFlag += string.Format("{0}", usefulBytes[i]); |
| | | // } |
| | | // break; |
| | | //case Command.BroadcastDryContactStatus://由干接点广播出来的数据,程序不做回复。 |
| | | // receiveFlag += string.Format("{0}", usefulBytes[0]); |
| | | // break; |
| | | //case Command.SetSceneACK: |
| | | // receiveFlag += string.Format("{0},{1}", usefulBytes[0], usefulBytes[1]); |
| | | // break; |
| | | //case Command.SetSeriesACK: |
| | | // receiveFlag += string.Format("{0},{1}", usefulBytes[0], usefulBytes[1]); |
| | | // break; |
| | | //case Command.SetCurtainModelStutasACK: |
| | | //case Command.SetHotelCurtainACK: |
| | | //case Command.DownloadInfraredACK: |
| | | //case Command.SetSensorPushValuesACK: |
| | | //case Command.ReadSensorPushValuesACK: |
| | | // receiveFlag += string.Format("{0},{1}", usefulBytes[0], usefulBytes[1]); |
| | | // break; |
| | | //case Command.ReadLightEquipmentAllLoopBrightnessACK: |
| | | // break; |
| | | //case Command.UpLoadInfraredACK: |
| | | // receiveFlag += string.Format("{0},{1}", usefulBytes[0], usefulBytes[1]); |
| | | // break; |
| | | //case Command.SetCommonACK: |
| | | //case Command.InfraredChannelControlACK: |
| | | //case Command.Serverx_FH_CMD_ACK: |
| | | //case Command.ReadSensorHistoryACK: |
| | | //case Command.SetSensorAutomationTargetLevelEnableACK: |
| | | //case Command.ReadSensorAutomationLevelTargetEnableACK: |
| | | // receiveFlag += string.Format("{0}", usefulBytes[0]); |
| | | // break; |
| | | //case Command.ReadFoolHeatACK: |
| | | //case Command.SetFoolHeatACK: |
| | | //case Command.SetArmACK: |
| | | //case Command.ReadArmACK: |
| | | // receiveFlag += string.Format("{0}", usefulBytes[0]); |
| | | // break; |
| | | //case Command.ReadDeviceModulACK: |
| | | //case Command.ReadGatewayACK: |
| | | //case Command.ReadSecurityStatusACK: |
| | | // receiveFlag = string.Format("{0},{1}", usefulBytes[0], usefulBytes[1]); |
| | | // break; |
| | | //case Command.UpdataLightDimmingTheLargestLevelACK: |
| | | //case Command.UpdataLightDimmingMaximumOrMinimumACK: |
| | | //case Command.WriteManageWirelessNetACK: |
| | | //case Command.ReadGateWayModelInfoACK: |
| | | //case Command.ReadGatewayServerIPACK: |
| | | //case Command.SetGateWayModelInfoACK: |
| | | //case Command.SetGateWayModelInternetInfoACK: |
| | | //case Command.ReadDeviceMacACK: |
| | | //case Command.SetDeviceSubnetIDACK: |
| | | //case Command.PositioningEquipmentACK: |
| | | //case Command.PositioningPanelACK: |
| | | //case Command.GotoConfigModeACK: |
| | | //case Command.CheckConfigSuccessACK: |
| | | //case Command.SetACPanelACK: |
| | | //case Command.ReadACPanelACK: |
| | | //case Command.ReadTerrestriaHeatRemarkACK: |
| | | //case Command.UpdateGatewayIpACK: |
| | | //case Command.ReadWirelessPanelModeACK: |
| | | //case Command.ReadDrycontactModeACK: |
| | | //case Command.ReadACFloorHeatingSettingEquipmentACK: |
| | | //case Command.SetACFloorHeatingSettingEquipmentACK: |
| | | //case Command.Read43FloorHeatingSettingEquipmentACK: |
| | | //case Command.Set43FloorHeatingSettingEquipmentACK: |
| | | //case Command.READ_AIR_ALL_Parameter_ack: |
| | | //case Command.Set_AIR_ALL_Parameter_ack: |
| | | //case Command.ReadFloorHeatProbeACK: |
| | | //case Command.ReadButtonKeyEnableACK: |
| | | //case Command.UpdateLightDimmingLoopRemakeACK: |
| | | //case Command.ReadMusicPanelSettingACK: |
| | | //case Command.ReadMusicPanelEnableACK: |
| | | //case Command.SetMusicPanelEnableACK: |
| | | //case Command.SetMusicPanelSettingACK: |
| | | //case Command.SetGatewayACK: |
| | | //case Command.ReadGatewayProgrammingModeACK: |
| | | //case Command.RED_HSFH_TOTAL_ACK: |
| | | //case Command.RED_HSFH_INFORMATION_ACK: |
| | | //case Command.RED_HSRM_TOTAL_ACK: |
| | | //case Command.RED_HSRM_INFORMATION_ACK: |
| | | //case Command.CLEAR_SYSTEM_HISTORY_ACK: |
| | | //case Command.SetSensorTargetRemarkACK: |
| | | //case Command.ReadSensorAutomationEnableListACK: |
| | | //case Command.SetSensorAutomationEnableListACK: |
| | | //case Command.SetSensorAutomationListIDACK: |
| | | //case Command.ReadSensorAutomationListIDACK: |
| | | //case Command.ReadSensorAutomationNameACK: |
| | | //case Command.SetSensorAutomationNameACK: |
| | | //case Command.Set_Floor_Heat_State_ack: |
| | | //case Command.Read_Floor_Heat_State_ack: |
| | | //case Command.Read_Air_Condition_Set_ack: |
| | | //case Command.HornAlarmBroadcast: |
| | | //case Command.ReadHornLoopCountACK: |
| | | //case Command.UpdateHornLoopRemakeACK: |
| | | //case Command.ReadPanelTempTypeACK: |
| | | // receiveFlag += ""; |
| | | // break; |
| | | //case Command.ControlMusicModel1ACK: |
| | | // receiveFlag += ""; |
| | | // break; |
| | | //case Command.ControlMusicModel2ACK: |
| | | // for (int i = 1; i < usefulBytes.Length; i++) |
| | | // { |
| | | // if (usefulBytes[i + 1] == 44) |
| | | // { |
| | | // break; |
| | | // } |
| | | // receiveFlag += string.Format("{0},", usefulBytes[i]); |
| | | // } |
| | | // break; |
| | | |
| | | case Command.Remote3thACK: |
| | | receiveFlag = string.Format("{0},", (int)command); |
| | | break; |
| | | case Command.ReadDeviceLoopInfoACK: |
| | | if (usefulBytes[0] == 1) |
| | | { |
| | | receiveFlag += string.Format("{0},{1}", usefulBytes[0], usefulBytes[2]); ; |
| | | } |
| | | else |
| | | receiveFlag += string.Format("{0},{1},{2}", usefulBytes[0], usefulBytes[1], usefulBytes[2]); |
| | | break; |
| | | case Command.SetDeviceLoopInfoACK: |
| | | case Command.InfraredControlACK: |
| | | case Command.SetLogicLoopColorACK: |
| | | case Command.SetSecurityByPassACK: |
| | | case Command.SetSensorAutomationDateTimeCycleACK: |
| | | case Command.ReadSensorAutomationDateTimeCycleACK: |
| | | receiveFlag += string.Format("{0},{1},{2}", usefulBytes[0], usefulBytes[1], usefulBytes[2]); |
| | | break; |
| | | case Command.UpdataRemakeACK: |
| | | break; |
| | | case Command.ReadWirelessPanelButtonKeyACK: |
| | | case Command.WriteWirelessPanelButtonKeyACK: |
| | | case Command.ReadDryContactStatusACK: |
| | | case Command.InstructionPanelKeyACK: |
| | | case Command.ReadInstructionPanelKeyACK: |
| | | case Command.ReadAnalogValueACK: |
| | | case Command.ReadSensorTargetRemarkACK: |
| | | case Command.SetHornTargetStateACK: |
| | | case Command.ReadHornTargetStateACK: |
| | | receiveFlag += string.Format("{0},{1}", usefulBytes[0], usefulBytes[1]); |
| | | break; |
| | | case Command.AssignedAddressACK: |
| | | case Command.UpdataCurtainModelRunTimeACK: |
| | | case Command.ReadCurtainStutasACK: |
| | | case Command.ReadLogicLoopColorACK: |
| | | case Command.ReadPanleTempACK: |
| | | case Command.FreshAirReadACK: |
| | | case Command.FreshAirControlACK: |
| | | case Command.Set_Air_State_New_ack: |
| | | case Command.ReadHornHistoryACK: |
| | | case Command.ReadHornLoopsStatusACK: |
| | | case Command.ReadHornPushACK: |
| | | case Command.SetHornPushACK: |
| | | case Command.ReadHornLoopAlarmACK: |
| | | case Command.SetHornTargetEnableACK: |
| | | case Command.ReadHornTargetEnableACK: |
| | | receiveFlag += string.Format("{0}", usefulBytes[0]); |
| | | break; |
| | | case Command.RemoteFirstACK: |
| | | for (int i = 1; i < 1 + 28; i++) |
| | | { |
| | | receiveFlag += string.Format("{0}", usefulBytes[i]); |
| | | } |
| | | break; |
| | | case Command.RemoteSecoudACK: |
| | | for (int i = 0; i < 7; i++) |
| | | { |
| | | receiveFlag += string.Format("{0}", usefulBytes[i]); |
| | | } |
| | | break; |
| | | //case Command.Remote3thACK: |
| | | // receiveFlag = string.Format("{0},", (int)command); |
| | | // break; |
| | | //case Command.ReadDeviceLoopInfoACK: |
| | | // if (usefulBytes[0] == 1) |
| | | // { |
| | | // receiveFlag += string.Format("{0},{1}", usefulBytes[0], usefulBytes[2]); ; |
| | | // } |
| | | // else |
| | | // receiveFlag += string.Format("{0},{1},{2}", usefulBytes[0], usefulBytes[1], usefulBytes[2]); |
| | | // break; |
| | | //case Command.SetDeviceLoopInfoACK: |
| | | //case Command.InfraredControlACK: |
| | | //case Command.SetSecurityByPassACK: |
| | | //case Command.SetSensorAutomationDateTimeCycleACK: |
| | | //case Command.ReadSensorAutomationDateTimeCycleACK: |
| | | // receiveFlag += string.Format("{0},{1},{2}", usefulBytes[0], usefulBytes[1], usefulBytes[2]); |
| | | // break; |
| | | //case Command.UpdataRemakeACK: |
| | | // break; |
| | | //case Command.ReadWirelessPanelButtonKeyACK: |
| | | //case Command.WriteWirelessPanelButtonKeyACK: |
| | | //case Command.ReadDryContactStatusACK: |
| | | //case Command.InstructionPanelKeyACK: |
| | | //case Command.ReadInstructionPanelKeyACK: |
| | | //case Command.ReadAnalogValueACK: |
| | | //case Command.ReadSensorTargetRemarkACK: |
| | | //case Command.SetHornTargetStateACK: |
| | | //case Command.ReadHornTargetStateACK: |
| | | // receiveFlag += string.Format("{0},{1}", usefulBytes[0], usefulBytes[1]); |
| | | // break; |
| | | //case Command.AssignedAddressACK: |
| | | //case Command.UpdataCurtainModelRunTimeACK: |
| | | //case Command.ReadCurtainStutasACK: |
| | | //case Command.ReadPanleTempACK: |
| | | //case Command.FreshAirReadACK: |
| | | //case Command.FreshAirControlACK: |
| | | //case Command.Set_Air_State_New_ack: |
| | | //case Command.ReadHornHistoryACK: |
| | | //case Command.ReadHornLoopsStatusACK: |
| | | //case Command.ReadHornPushACK: |
| | | //case Command.SetHornPushACK: |
| | | //case Command.ReadHornLoopAlarmACK: |
| | | //case Command.SetHornTargetEnableACK: |
| | | //case Command.ReadHornTargetEnableACK: |
| | | // receiveFlag += string.Format("{0}", usefulBytes[0]); |
| | | // break; |
| | | //case Command.RemoteFirstACK: |
| | | // for (int i = 1; i < 1 + 28; i++) |
| | | // { |
| | | // receiveFlag += string.Format("{0}", usefulBytes[i]); |
| | | // } |
| | | // break; |
| | | //case Command.RemoteSecoudACK: |
| | | // for (int i = 0; i < 7; i++) |
| | | // { |
| | | // receiveFlag += string.Format("{0}", usefulBytes[i]); |
| | | // } |
| | | // break; |
| | | default: |
| | | break; |
| | | } |
| | |
| | | { |
| | | if (Packet.FlagDateTime.AddMilliseconds(1000).Ticks <= System.DateTime.Now.Ticks) |
| | | { |
| | | //System.MainPage.WriteLog ("重发数据:" + SendFlag); |
| | | MainPage.Log("重发数据:" + SendFlag); |
| | | BusSocket.AsyncBeginSend(Packet); |
| | | } |
| | | System.Threading.Thread.Sleep(100); |
| | |
| | | |
| | | switch (target.Command) |
| | | { |
| | | case Command.YIPanelDeviceInof: |
| | | for (int i = 0; i < 4; i++) |
| | | { |
| | | this.sendFlag += string.Format("{0}", target.AddData[i]); |
| | | } |
| | | break; |
| | | case Command.ReadDoorLockSceneObj: |
| | | this.SendFlag += string.Format("{0},{1},{2},{3},{4}", target.AddData[0], target.AddData[1], target.AddData[2], target.AddData[3], target.AddData[4]); |
| | | break; |
| | | case Command.ReadDoorLockClock: |
| | | case Command.CreatConnection: |
| | | this.SendFlag += string.Format("{0}", target.AddData[0]); |
| | | break; |
| | | case Command.ReadDoorLockUseRemark: |
| | | case Command.ReadSensorPushMessage: |
| | | case Command.SetSensorPushMessage: |
| | | case Command.SetSensorScence: |
| | | case Command.ReadAnalog: |
| | | this.sendFlag += string.Format("{0},{1},{2}", target.AddData[0], target.AddData[1], target.AddData[2]); |
| | | break; |
| | | case Command.ReadSensorScence: |
| | | this.sendFlag += string.Format("{0},{1},{2}", target.AddData[0], target.AddData[1], target.AddData[2]); |
| | | break; |
| | | case Command.SendRemoteInfoToServer: |
| | | for (int i = 40; i < 48; i++) |
| | | { |
| | | this.sendFlag += string.Format("{0}", target.AddData[i]); |
| | | } |
| | | break; |
| | | case Command.SetCommonSwitch: |
| | | case Command.InfraredChannelControl: |
| | | case Command.SetSingleLight: |
| | | case Command.ReadLogicLoopColor: |
| | | case Command.ReadACMode: |
| | | case Command.SetACMode: |
| | | case Command.ReadFoolHeat: |
| | | case Command.SetFoolHeat: |
| | | case Command.Serverx_FH_CMD: |
| | | case Command.SetArm: |
| | | case Command.ReadArm: |
| | | case Command.ReadSensorHistory: |
| | | case Command.SetSensorAutomationTargetLevelEnable: |
| | | case Command.ReadSensorAutomationLevelTargetEnable: |
| | | this.SendFlag += string.Format("{0}", target.AddData[0]); |
| | | break; |
| | | case Command.ReadDeviceModul: |
| | | case Command.ReadGateway: |
| | | case Command.ReadSecurityStatus: |
| | | case Command.ReadHornTargetState: |
| | | this.SendFlag = string.Format("{0},{1}", target.AddData[0], target.AddData[1]); |
| | | break; |
| | | case Command.SetScene: |
| | | case Command.SetSeries: |
| | | case Command.SetHotelCurtain: |
| | | case Command.ReadAnalogValue: |
| | | case Command.SetSensorPushValues: |
| | | case Command.ReadSensorPushValues: |
| | | this.SendFlag += string.Format("{0},{1}", target.AddData[0], target.AddData[1]); |
| | | break; |
| | | //case Command.ReadOnePortWirelessFROtherInfo: |
| | | case Command.UpdataRemake: |
| | | case Command.WriteManageWirelessNet: |
| | | case Command.UpdataLightDimmingTheLargestLevel: |
| | | case Command.UpdataLightDimmingMaximumOrMinimum: |
| | | case Command.ReadGateWayModelInfo: |
| | | case Command.ReadGatewayServerIP: |
| | | case Command.SetGateWayModelInfo: |
| | | case Command.SetGateWayModelInternetInfo: |
| | | case Command.ReadDeviceMac: |
| | | case Command.SetDeviceSubnetID: |
| | | case Command.PositioningEquipment: |
| | | case Command.PositioningPanel: |
| | | case Command.CheckConfigSuccess: |
| | | case Command.GotoConfigMode: |
| | | case Command.ReadACPanel: |
| | | case Command.SetACPanel: |
| | | case Command.ReadTerrestriaHeatRemark: |
| | | case Command.UpdateGatewayIp: |
| | | case Command.ReadWirelessPanelMode: |
| | | case Command.ReadDrycontactMode: |
| | | case Command.ReadACFloorHeatingSettingEquipment: |
| | | case Command.SetACFloorHeatingSettingEquipment: |
| | | case Command.Read43FloorHeatingSettingEquipment: |
| | | case Command.Set43FloorHeatingSettingEquipment: |
| | | case Command.READ_AIR_ALL_Parameter: |
| | | case Command.Set_AIR_ALL_Parameter: |
| | | case Command.ReadFloorHeatProbe: |
| | | case Command.ControlMusicModel: |
| | | case Command.ReadButtonKeyEnable: |
| | | case Command.UpdateEquipmentLoopRemake: |
| | | case Command.SetGateway: |
| | | case Command.ReadMusicPanelSetting: |
| | | case Command.ReadMusicPanelEnable: |
| | | case Command.SetMusicPanelEnable: |
| | | case Command.SetMusicPanelSetting: |
| | | case Command.ReadGatewayProgrammingMode: |
| | | case Command.RED_HSFH_TOTAL: |
| | | case Command.RED_HSFH_INFORMATION: |
| | | case Command.RED_HSRM_TOTAL: |
| | | case Command.RED_HSRM_INFORMATION: |
| | | case Command.CLEAR_SYSTEM_HISTORY: |
| | | case Command.SetSensorTargetRemark: |
| | | case Command.ReadSensorAutomationEnableList: |
| | | case Command.SetSensorAutomationEnableList: |
| | | case Command.SetSensorAutomationListID: |
| | | case Command.ReadSensorAutomationListID: |
| | | case Command.SetSensorAutomationName: |
| | | case Command.ReadSensorAutomationName: |
| | | case Command.Set_Floor_Heat_State: |
| | | case Command.Read_Floor_Heat_State: |
| | | case Command.Read_Air_Condition_Set: |
| | | case Command.UpdateHornLoopRemake: |
| | | case Command.ReadHornLoopCount: |
| | | case Command.ReadPanelTempType: |
| | | this.SendFlag += ""; |
| | | break; |
| | | case Command.ControlMusicModel2: |
| | | for (int i = 1; i < target.AddData.Length; i++) |
| | | { |
| | | if (target.AddData[i + 1] == 0x0D) |
| | | { |
| | | break; |
| | | } |
| | | this.sendFlag += string.Format("{0},", target.AddData[i]); |
| | | } |
| | | break; |
| | | case Command.Remote3th: |
| | | this.SendFlag = string.Format("{0},", (int)target.Command + 1); |
| | | break; |
| | | case Command.ReadDeviceLoopInfo: |
| | | if (target.AddData[0] == 1)//特殊处理灯光类,DMX模块每一个回路不固定小类,根据具体设置来回复 |
| | | this.sendFlag += string.Format("{0},{1}", target.AddData[0], target.AddData[2]); |
| | | else |
| | | this.sendFlag += string.Format("{0},{1},{2}", target.AddData[0], target.AddData[1], target.AddData[2]); |
| | | break; |
| | | case Command.SetDeviceLoopInfo: |
| | | case Command.InfraredControl: |
| | | case Command.SetLogicLoopColor: |
| | | case Command.SetSecurityByPass: |
| | | case Command.SetSensorAutomationDateTimeCycle: |
| | | case Command.ReadSensorAutomationDateTimeCycle: |
| | | this.sendFlag += string.Format("{0},{1},{2}", target.AddData[0], target.AddData[1], target.AddData[2]); |
| | | break; |
| | | case Command.ReadWirelessPanelButtonKey: |
| | | case Command.WriteWirelessPanelButtonKey: |
| | | case Command.ReadDryContactStatus: |
| | | case Command.UpdataCurtainModelStutas: |
| | | case Command.SetSingleLight: |
| | | case Command.DownloadInfrared: |
| | | case Command.UpLoadInfrared: |
| | | case Command.InstructionPanelKey: |
| | | case Command.ReadInstructionPanelKey: |
| | | case Command.ReadSensorTargetRemark: |
| | | case Command.SetHornTargetState: |
| | | this.sendFlag += string.Format("{0},{1}", target.AddData[0], target.AddData[1]); |
| | | break; |
| | | case Command.AssignedAddress: |
| | | case Command.UpdataCurtainModelRunTime: |
| | | case Command.ReadCurtainStatus: |
| | | case Command.ReadLogicLoopColor: |
| | | case Command.ReadPanleTemp: |
| | | case Command.FreshAirRead: |
| | | case Command.FreshAirControl: |
| | | case Command.Set_Air_State_New: |
| | | case Command.ReadHornTargetEnable: |
| | | case Command.SetHornTargetEnable: |
| | | case Command.ReadHornLoopAlarm: |
| | | case Command.SetHornPush: |
| | | case Command.ReadHornPush: |
| | | case Command.ReadHornHistory: |
| | | case Command.ReadHornLoopsStatus: |
| | | case Command.ReadFloorHeat: |
| | | case Command.SetFloorHeat: |
| | | this.sendFlag += string.Format("{0}", target.AddData[0]); |
| | | break; |
| | | case Command.RemoteFirst: |
| | | for (int i = 0; i < 28; i++) |
| | | { |
| | | this.sendFlag += string.Format("{0}", target.AddData[i]); |
| | | } |
| | | case Command.SetLogicLoopColor: |
| | | this.sendFlag += string.Format("{0},{1},{2}", target.AddData[0], target.AddData[1], target.AddData[2]); |
| | | break; |
| | | case Command.RemoteSecoud: |
| | | for (int i = 0; i < 7; i++) |
| | | { |
| | | this.sendFlag += string.Format("{0}", target.AddData[i]); |
| | | } |
| | | break; |
| | | //case Command.YIPanelDeviceInof: |
| | | // for (int i = 0; i < 4; i++) |
| | | // { |
| | | // this.sendFlag += string.Format("{0}", target.AddData[i]); |
| | | // } |
| | | // break; |
| | | //case Command.ReadDoorLockSceneObj: |
| | | // this.SendFlag += string.Format("{0},{1},{2},{3},{4}", target.AddData[0], target.AddData[1], target.AddData[2], target.AddData[3], target.AddData[4]); |
| | | // break; |
| | | //case Command.ReadDoorLockClock: |
| | | //case Command.CreatConnection: |
| | | // this.SendFlag += string.Format("{0}", target.AddData[0]); |
| | | // break; |
| | | //case Command.ReadDoorLockUseRemark: |
| | | //case Command.ReadSensorPushMessage: |
| | | //case Command.SetSensorPushMessage: |
| | | //case Command.SetSensorScence: |
| | | //case Command.ReadAnalog: |
| | | // this.sendFlag += string.Format("{0},{1},{2}", target.AddData[0], target.AddData[1], target.AddData[2]); |
| | | // break; |
| | | //case Command.ReadSensorScence: |
| | | // this.sendFlag += string.Format("{0},{1},{2}", target.AddData[0], target.AddData[1], target.AddData[2]); |
| | | // break; |
| | | //case Command.SendRemoteInfoToServer: |
| | | // for (int i = 40; i < 48; i++) |
| | | // { |
| | | // this.sendFlag += string.Format("{0}", target.AddData[i]); |
| | | // } |
| | | // break; |
| | | //case Command.SetCommonSwitch: |
| | | //case Command.InfraredChannelControl: |
| | | //case Command.ReadFoolHeat: |
| | | //case Command.SetFoolHeat: |
| | | //case Command.Serverx_FH_CMD: |
| | | //case Command.SetArm: |
| | | //case Command.ReadArm: |
| | | //case Command.ReadSensorHistory: |
| | | //case Command.SetSensorAutomationTargetLevelEnable: |
| | | //case Command.ReadSensorAutomationLevelTargetEnable: |
| | | // this.SendFlag += string.Format("{0}", target.AddData[0]); |
| | | // break; |
| | | //case Command.ReadDeviceModul: |
| | | //case Command.ReadGateway: |
| | | //case Command.ReadSecurityStatus: |
| | | //case Command.ReadHornTargetState: |
| | | // this.SendFlag = string.Format("{0},{1}", target.AddData[0], target.AddData[1]); |
| | | // break; |
| | | //case Command.SetScene: |
| | | //case Command.SetSeries: |
| | | //case Command.SetHotelCurtain: |
| | | //case Command.ReadAnalogValue: |
| | | //case Command.SetSensorPushValues: |
| | | //case Command.ReadSensorPushValues: |
| | | // this.SendFlag += string.Format("{0},{1}", target.AddData[0], target.AddData[1]); |
| | | // break; |
| | | ////case Command.ReadOnePortWirelessFROtherInfo: |
| | | //case Command.UpdataRemake: |
| | | //case Command.WriteManageWirelessNet: |
| | | //case Command.UpdataLightDimmingTheLargestLevel: |
| | | //case Command.UpdataLightDimmingMaximumOrMinimum: |
| | | //case Command.ReadGateWayModelInfo: |
| | | //case Command.ReadGatewayServerIP: |
| | | //case Command.SetGateWayModelInfo: |
| | | //case Command.SetGateWayModelInternetInfo: |
| | | //case Command.ReadDeviceMac: |
| | | //case Command.SetDeviceSubnetID: |
| | | //case Command.PositioningEquipment: |
| | | //case Command.PositioningPanel: |
| | | //case Command.CheckConfigSuccess: |
| | | //case Command.GotoConfigMode: |
| | | //case Command.ReadACPanel: |
| | | //case Command.SetACPanel: |
| | | //case Command.ReadTerrestriaHeatRemark: |
| | | //case Command.UpdateGatewayIp: |
| | | //case Command.ReadWirelessPanelMode: |
| | | //case Command.ReadDrycontactMode: |
| | | //case Command.ReadACFloorHeatingSettingEquipment: |
| | | //case Command.SetACFloorHeatingSettingEquipment: |
| | | //case Command.Read43FloorHeatingSettingEquipment: |
| | | //case Command.Set43FloorHeatingSettingEquipment: |
| | | //case Command.READ_AIR_ALL_Parameter: |
| | | //case Command.Set_AIR_ALL_Parameter: |
| | | //case Command.ReadFloorHeatProbe: |
| | | //case Command.ControlMusicModel: |
| | | //case Command.ReadButtonKeyEnable: |
| | | //case Command.UpdateEquipmentLoopRemake: |
| | | //case Command.SetGateway: |
| | | //case Command.ReadMusicPanelSetting: |
| | | //case Command.ReadMusicPanelEnable: |
| | | //case Command.SetMusicPanelEnable: |
| | | //case Command.SetMusicPanelSetting: |
| | | //case Command.ReadGatewayProgrammingMode: |
| | | //case Command.RED_HSFH_TOTAL: |
| | | //case Command.RED_HSFH_INFORMATION: |
| | | //case Command.RED_HSRM_TOTAL: |
| | | //case Command.RED_HSRM_INFORMATION: |
| | | //case Command.CLEAR_SYSTEM_HISTORY: |
| | | //case Command.SetSensorTargetRemark: |
| | | //case Command.ReadSensorAutomationEnableList: |
| | | //case Command.SetSensorAutomationEnableList: |
| | | //case Command.SetSensorAutomationListID: |
| | | //case Command.ReadSensorAutomationListID: |
| | | //case Command.SetSensorAutomationName: |
| | | //case Command.ReadSensorAutomationName: |
| | | //case Command.Set_Floor_Heat_State: |
| | | //case Command.Read_Floor_Heat_State: |
| | | //case Command.Read_Air_Condition_Set: |
| | | //case Command.UpdateHornLoopRemake: |
| | | //case Command.ReadHornLoopCount: |
| | | //case Command.ReadPanelTempType: |
| | | // this.SendFlag += ""; |
| | | // break; |
| | | //case Command.ControlMusicModel2: |
| | | // for (int i = 1; i < target.AddData.Length; i++) |
| | | // { |
| | | // if (target.AddData[i + 1] == 0x0D) |
| | | // { |
| | | // break; |
| | | // } |
| | | // this.sendFlag += string.Format("{0},", target.AddData[i]); |
| | | // } |
| | | // break; |
| | | //case Command.Remote3th: |
| | | // this.SendFlag = string.Format("{0},", (int)target.Command + 1); |
| | | // break; |
| | | //case Command.ReadDeviceLoopInfo: |
| | | // if (target.AddData[0] == 1)//特殊处理灯光类,DMX模块每一个回路不固定小类,根据具体设置来回复 |
| | | // this.sendFlag += string.Format("{0},{1}", target.AddData[0], target.AddData[2]); |
| | | // else |
| | | // this.sendFlag += string.Format("{0},{1},{2}", target.AddData[0], target.AddData[1], target.AddData[2]); |
| | | // break; |
| | | //case Command.SetDeviceLoopInfo: |
| | | //case Command.InfraredControl: |
| | | //case Command.SetSecurityByPass: |
| | | //case Command.SetSensorAutomationDateTimeCycle: |
| | | //case Command.ReadSensorAutomationDateTimeCycle: |
| | | // this.sendFlag += string.Format("{0},{1},{2}", target.AddData[0], target.AddData[1], target.AddData[2]); |
| | | // break; |
| | | //case Command.ReadWirelessPanelButtonKey: |
| | | //case Command.WriteWirelessPanelButtonKey: |
| | | //case Command.ReadDryContactStatus: |
| | | //case Command.SetCurtainModelStutas: |
| | | //case Command.DownloadInfrared: |
| | | //case Command.UpLoadInfrared: |
| | | //case Command.InstructionPanelKey: |
| | | //case Command.ReadInstructionPanelKey: |
| | | //case Command.ReadSensorTargetRemark: |
| | | //case Command.SetHornTargetState: |
| | | // this.sendFlag += string.Format("{0},{1}", target.AddData[0], target.AddData[1]); |
| | | // break; |
| | | //case Command.AssignedAddress: |
| | | //case Command.UpdataCurtainModelRunTime: |
| | | //case Command.ReadCurtainStatus: |
| | | //case Command.ReadPanleTemp: |
| | | //case Command.FreshAirRead: |
| | | //case Command.FreshAirControl: |
| | | //case Command.Set_Air_State_New: |
| | | //case Command.ReadHornTargetEnable: |
| | | //case Command.SetHornTargetEnable: |
| | | //case Command.ReadHornLoopAlarm: |
| | | //case Command.SetHornPush: |
| | | //case Command.ReadHornPush: |
| | | //case Command.ReadHornHistory: |
| | | //case Command.ReadHornLoopsStatus: |
| | | // this.sendFlag += string.Format("{0}", target.AddData[0]); |
| | | // break; |
| | | //case Command.RemoteFirst: |
| | | // for (int i = 0; i < 28; i++) |
| | | // { |
| | | // this.sendFlag += string.Format("{0}", target.AddData[i]); |
| | | // } |
| | | // break; |
| | | //case Command.RemoteSecoud: |
| | | // for (int i = 0; i < 7; i++) |
| | | // { |
| | | // this.sendFlag += string.Format("{0}", target.AddData[i]); |
| | | // } |
| | | // break; |
| | | default: |
| | | //return; |
| | | break; |
| | |
| | | /// <param name="sendCount">重发次数</param> |
| | | public void Send(Target target, int sendCount, bool isWait) |
| | | { |
| | | Packet = new Packet(target.SendBytes, target.IPEndPoint); |
| | | Packet.HaveSendCount = 3 - sendCount; |
| | | |
| | | ini(target); |
| | | |
| | | if (isWait) |
| | | try |
| | | { |
| | | this.wait(); |
| | | Packet = new Packet(target.SendBytes, target.IPEndPoint); |
| | | Packet.HaveSendCount = 3 - sendCount; |
| | | |
| | | ini(target); |
| | | |
| | | if (isWait) |
| | | { |
| | | this.wait(); |
| | | } |
| | | } |
| | | catch(Exception ex) |
| | | { |
| | | MainPage.Log($"Send bus data error {ex.Message}"); |
| | | } |
| | | } |
| | | |