/// <summary> /// Initializes a new instance of the <see cref="TransmissionManager"/> class. /// </summary> private TransmissionManager(bool isBlueTooth) { if (isBlueTooth) { } else { manager = new CanbusManager(); } this.CANBusPowerOnMSG = CanbusManager.createMsg((int)NodeIdentityEnum.node_battery, ConstInfo.Command_battery_power, ConstInfo.SurfaceCanBusAddr, null, 0); this.CANBusPowerOnMSG.LEN = 3; if (ConstInfo.IsSoftwarePowerON) { this.CANBusPowerOnMSG.DATA[2] = 2; // set power on time out time to 10 minutes. } else { this.CANBusPowerOnMSG.DATA[2] = 3; // read power status. } this.SoftwarePowerControlStart(); /* string powerFlag = ConfigurationManager.AppSettings["controlPoweron"]; * if (powerFlag == "true") * { * this.isControlPowerON = true; * } * else * { * this.isControlPowerON = false; * }*/ }
/// <summary> /// operation fo battery time synchronization /// </summary> /// <param name="isSetTime"></param> /// <returns></returns> public byte[] BatteryTimeOperation(bool isSetTime) { //send date time TimeSpan span = DateTime.Now - ConstInfo.GetBaseTime(); uint seconds = Convert.ToUInt32(span.TotalSeconds); byte[] timeByte = BitConverter.GetBytes(seconds); TPCANMsg time = CanbusManager.createMsg(NodeIdentityEnum.node_battery, ConstInfo.Command_batery_dateTime, ConstInfo.SurfaceCanBusAddr, timeByte, 0); if (isSetTime) { time.DATA[2] = 0; //set time } else { time.DATA[2] = 1;// get battery time } sendPCANData(ref time); int dataLen = 0; byte[] datas = this.getCanBusResponData(ConstInfo.SurfaceCanBusAddr, (int)NodeIdentityEnum.node_battery, ConstInfo.Command_batery_dateTime, 2, ref dataLen); if (dataLen != 8 || datas[2] != time.DATA[2]) { return(null); } if (isSetTime) { uint ses = BitConverter.ToUInt32(datas, 4); if (ses != seconds) { return(null); } return(datas); } else { return(datas); } }
/// <summary> /// get D&I serial numbe and firmware version. /// </summary> /// <returns></returns> public DirectionModuleInfo GetDirectionModualInformation() { //* TPCANStatus stsResult; TPCANMsg requstDI = CanbusManager.createMsg((int)NodeIdentityEnum.node_interface, ConstInfo.Command_interface_DIInformation, ConstInfo.SurfaceCanBusAddr, null, 0); requstDI.LEN = 3; stsResult = this.sendPCANData(ref requstDI); List <byte> result = this.manager.receiveDirctionModuleInformation(ConstInfo.SurfaceCanBusAddr, (int)NodeIdentityEnum.node_interface, ConstInfo.Command_interface_DIInformation); //*/ /* * List<byte> result = new List<byte>(); * byte[] resultByte = new byte[] * { * 0x41, 0x50, 0x53, 0x20, * 0x20, 0x45, 0x44, 0x30, * 0x31, 0x30, 0x35, 0x48, * 0x4E, 0x20, 0x56, 0x65, * 0x72, 0x3A, 0x34, 0x2E, * 0x31, 0x4E, 0x65, 0x74, * 0x75, 0x43, 0x45, 0x78, * 0x0D, 0x0D, 0x0A, 0x04 * }; * result.AddRange( resultByte ); */ if (result != null && result.Count > 0) { return(new DirectionModuleInfo(result)); } else { return(null); } }
public byte[] BatteryPoweroNControl( ) { TPCANStatus stsResult; TPCANMsg pownOn = CanbusManager.createMsg((int)NodeIdentityEnum.node_battery, ConstInfo.Command_battery_power, ConstInfo.SurfaceCanBusAddr, null, 0); pownOn.LEN = 3; pownOn.DATA[2] = 1; //pownOn.DATA[ 2 ] = 0;//OFF ConstInfo.SaveLogToFile("POWER COMMAND TO BATTERY-- on"); stsResult = sendPCANData(ref pownOn); int dl = 0; byte[] res = this.getCanBusResponData(ConstInfo.SurfaceCanBusAddr, (int)NodeIdentityEnum.node_battery, ConstInfo.Command_battery_power, this.PowerProcessTime, ref dl); if (dl <= 0) { return(null); } byte[] result = new byte[dl]; for (int i = 0; i < res.Length && i < dl; i++) { result[i] = res[i]; } return(result); }