/// <summary> /// /// </summary> /// <param name="ch"></param> /// <param name="targetId"></param> /// <returns></returns> public byte[] SingleQuiryPowersupply(PowersupplyChannel ch, int targetId = 0) { byte[] ar = null; UInt16 crc; SingleQuiryPowersupplyCmd cmd = new SingleQuiryPowersupplyCmd(); InitHeader(typeof(SingleQuiryPowersupplyCmd), (CmdHeader)cmd, 0x02, TYPE_POWER, (UInt16)targetId); cmd.channel = (byte)ch; ar = Struct2Array <SingleQuiryPowersupplyCmd>(cmd); crc = CalcCRC16(0, ar, ar.Length - 2); ar[ar.Length - 2] = (byte)(crc >> 8); ar[ar.Length - 1] = (byte)(crc & 0xff); return(ar); }
/// <summary> /// 获取电源配置命令的字节数组 /// </summary> /// <param name="ch">配置电源的通道</param> /// <param name="mode">对应通道的工作模式</param> /// <param name="vset">DCDC模式下的输出电压,单位‘毫伏’</param> /// <param name="targetId"></param> /// <returns></returns> public byte[] PowersupplyConfig(PowersupplyChannel ch, PowerMode mode, int vset = 5000, int targetId = 0) { byte[] ar = null; UInt16 crc; PowersupplyConfigCmd cmd = new PowersupplyConfigCmd(); byte ctrlcode = 0x01; if (PowersupplyChannel.ChannelAll == ch) { ctrlcode = 0xff; } InitHeader(typeof(PowersupplyConfigCmd), (CmdHeader)cmd, ctrlcode, TYPE_POWER, (UInt16)targetId); cmd.mode = (byte)mode; cmd.channel = (byte)ch; cmd.Vset_h = (byte)(vset >> 8); cmd.Vset_l = (byte)(vset & 0xff); ar = Struct2Array <PowersupplyConfigCmd>(cmd); crc = CalcCRC16(0, ar, ar.Length - 2); ar[ar.Length - 2] = (byte)(crc >> 8); ar[ar.Length - 1] = (byte)(crc & 0xff); return(ar); }