| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497 |
- using IvfTl.Control.Entity;
- namespace ivf_tl_SerialHelper.Util
- {
- public static class Commander
- {
- //public static int MachineModel { get; set; }
- /// <summary>
- /// 求累加和校验
- /// </summary>
- /// <param name="bytes"></param>
- /// <returns></returns>
- public static byte[] CreateORC(byte[] bytes)
- {
- byte orcByte = 0x00;
- for (int i = 0; i < bytes.Length - 1; i++)
- {
- orcByte += bytes[i];
- }
- bytes[bytes.Length - 1] = orcByte;
- return bytes;
- }
- /// <summary>
- /// 判断校验
- /// </summary>
- /// <param name="bytes"></param>
- /// <returns></returns>
- public static bool CheckORC(byte[] bytes)
- {
- byte orcByte = 0x00;
- for (int i = 0; i < bytes.Length - 1; i++)
- {
- orcByte += bytes[i];
- }
- return bytes[bytes.Length - 1] == orcByte;
- }
- public static void CustomProtocolLength(CustomProtocol custom)
- {
- custom.lenght = 6;
- custom.WaitTime = 0;
- switch (custom.sendBuffer[1])
- {
- case 0x01://握手指令
- custom.lenght = 6;
- break;
- case 0x02://自检指令
- custom.lenght = 6;
- break;
- case 0x04://设置目标温度
- custom.lenght = 7;
- break;
- case 0x05://电机控制指令
- custom.lenght = 6;
- break;
- case 0x06://读传感器信号
- custom.lenght = 9;
- break;
- case 0x08://读传感器AD
- custom.lenght = 9;
- break;
- case 0x09://设置IO
- custom.lenght = 6;
- break;
- case 0x10://获取IO
- custom.lenght = 7;
- break;
- case 0x11://读E方
- custom.lenght = 10;
- break;
- case 0x12://写E方
- custom.lenght = 6;
- break;
- case 0x18://读电机位置
- custom.lenght = 10;
- break;
- case 0x19://缓冲瓶补气
- custom.lenght = 6;
- break;
- case 0x20://读缓冲瓶数据
- custom.lenght = 12;
- break;
- }
- }
- #region 操作
- /// <summary>
- /// 握手 64
- /// </summary>
- /// <returns></returns>
- public static void CreateHandCommand(this CustomProtocol custom)
- {
-
- custom.sendBuffer = CreateORC(new byte[] { 0x5E, 0x01, 0x00, 0x05, 0x00 });
- CustomProtocolLength(custom);
- }
- /// <summary>
- /// 是否开启自动换气
- /// </summary>
- /// <param name="custom"></param>
- public static void CreateAutoCommand(this CustomProtocol custom, bool auto)
- {
- if (auto)
- {
- //7B
- custom.sendBuffer = CreateORC(new byte[] { 0x5E, 0x16, 0x00, 0x06, 0x01, 0x00 });
- }
- else
- {
- //7A
- custom.sendBuffer = CreateORC(new byte[] { 0x5E, 0x16, 0x00, 0x06, 0x00, 0x00 });
- }
- CustomProtocolLength(custom);
- }
- /// <summary>
- /// 打开CCD补光LED,长度7
- /// </summary>
- /// <returns></returns>
- public static void CreateOpenLEDCommand(this CustomProtocol custom)
- {
- custom.sendBuffer = new byte[] { 0x5E, 0x09, 0x00, 0x07, 0x00, 0x01, 0x6F };
- CustomProtocolLength(custom);
- }
- /// <summary>
- /// 关闭CCD补光LED,长度7
- /// </summary>
- /// <returns></returns>
- public static void CreateCloseLEDCommand(this CustomProtocol custom)
- {
- custom.sendBuffer = new byte[] { 0x5E, 0x09, 0x00, 0x07, 0x00, 0x00, 0x6E };
- CustomProtocolLength(custom);
- }
- /// <summary>
- /// 打开进气阀
- /// </summary>
- /// <returns></returns>
- public static void CreateOpenIntakeValveCommand(this CustomProtocol custom)
- {
- custom.sendBuffer = CreateORC(new byte[] { 0x5E, 0x09, 0x00, 0x07, 0x01, 0x01, 0x00 });
- CustomProtocolLength(custom);
- }
- /// <summary>
- /// 关闭进气阀
- /// </summary>
- /// <returns></returns>
- public static void CreateCloseIntakeValveCommand(this CustomProtocol custom)
- {
- custom.sendBuffer = CreateORC(new byte[] { 0x5E, 0x09, 0x00, 0x07, 0x01, 0x00, 0x00 });
- CustomProtocolLength(custom);
- }
- /// <summary>
- /// 打开排气阀
- /// </summary>
- /// <returns></returns>
- public static void CreateOpenExhaustValveCommand(this CustomProtocol custom)
- {
- custom.sendBuffer = CreateORC(new byte[] { 0x5E, 0x09, 0x00, 0x07, 0x02, 0x01, 0x00 });
- CustomProtocolLength(custom);
- }
- /// <summary>
- /// 关闭排气阀
- /// </summary>
- /// <returns></returns>
- public static void CreateCloseExhaustValveCommand(this CustomProtocol custom)
- {
- custom.sendBuffer = CreateORC(new byte[] { 0x5E, 0x09, 0x00, 0x07, 0x02, 0x00, 0x00 });
- CustomProtocolLength(custom);
- }
- /// <summary>
- /// 缓冲瓶补气 7C
- /// </summary>
- /// <returns></returns>
- public static void CreateBufferBottleAerationCommand(this CustomProtocol custom)
- {
- custom.sendBuffer = CreateORC(new byte[] { 0x5E, 0x19, 0x00, 0x05, 0x00 });
- CustomProtocolLength(custom);
- }
- /// <summary>
- /// 仓室补气 72
- /// </summary>
- /// <returns></returns>
- public static void CreateHouseAerationCommand(this CustomProtocol custom)
- {
- custom.sendBuffer = CreateORC(new byte[] { 0x5E, 0x09, 0x00, 0x07, 0x04, 0x01, 0x00 });
- CustomProtocolLength(custom);
- }
- /// <summary>
- /// 舱室排气
- /// </summary>
- /// <returns></returns>
- public static void CreateHouseVentCommand(this CustomProtocol custom)
- {
- custom.sendBuffer = CreateORC(new byte[] { 0x5E, 0x09, 0x00, 0x07, 0x05, 0x01, 0x00 });
- CustomProtocolLength(custom);
- }
- /// <summary>
- /// 读垂直电机位置
- /// </summary>
- /// <returns></returns>
- public static void CreateReadVerticalMotorCommand(this CustomProtocol custom)
- {
- custom.sendBuffer = CreateORC(new byte[] { 0x5E, 0x18, 0x00, 0x06, 0x02, 0x00 });
- CustomProtocolLength(custom);
- }
- /// <summary>
- /// 读水平电机位置
- /// </summary>
- /// <returns></returns>
- public static void CreateReadHorizontalMotorCommand(this CustomProtocol custom)
- {
- custom.sendBuffer = CreateORC(new byte[] { 0x5E, 0x18, 0x00, 0x06, 0x01, 0x00 });
- CustomProtocolLength(custom);
- }
- /// <summary>
- /// 读E方 仪器编号
- /// </summary>
- /// <returns></returns>
- public static void CreateReadTLNumCommand(this CustomProtocol custom)
- {
- custom.sendBuffer = CreateORC(new byte[] { 0x5E, 0x11, 0x00, 0x09, 0x00, 0x00, 0x08, 0x04, 0x00 });
- CustomProtocolLength(custom);
- }
- #endregion
- #region 温度、压力、仓门状态
- /// <summary>
- /// 温度 6b(下盖板温度)
- /// </summary>
- /// <param name="wayNum"></param>
- /// <returns></returns>
- public static void CreateReadTemperatureCommand(this CustomProtocol custom)
- {
- custom.sendBuffer = CreateORC(new byte[] { 0x5E, 0x06, 0x00, 0x06, 0x00, 0x00 });
- CustomProtocolLength(custom);
- }
- /// <summary>
- /// 获取上盖板温度
- /// </summary>
- /// <returns></returns>
- public static void CreateReadShangTemperatureCommand(this CustomProtocol custom)
- {
- custom.sendBuffer = CreateORC(new byte[] { 0x5E, 0x06, 0x00, 0x06, 0x01, 0x00 });
- CustomProtocolLength(custom);
- }
- /// <summary>
- /// 获取玻璃片下方温度
- /// </summary>
- /// <returns></returns>
- public static void CreateReadBoLiTemperatureCommand(this CustomProtocol custom)
- {
- custom.sendBuffer = CreateORC(new byte[] { 0x5E, 0x06, 0x00, 0x06, 0x02, 0x00 });
- CustomProtocolLength(custom);
- }
- /// <summary>
- /// 压力
- /// </summary>
- /// <param name="wayNum"></param>
- /// <returns></returns>
- public static void CreateReadPressureCommand(this CustomProtocol custom)
- {
- custom.sendBuffer = CreateORC(new byte[] { 0x5E, 0x06, 0x00, 0x06, 0x03, 0x00 });
- CustomProtocolLength(custom);
- }
- /// <summary>
- /// 获取缓冲瓶气压 83
- /// </summary>
- /// <returns></returns>
- public static void CreateBufferBottlePressureCommand(this CustomProtocol custom)
- {
- custom.sendBuffer = CreateORC(new byte[] { 0x5E, 0x20, 0x00, 0x05, 0x00 });
- CustomProtocolLength(custom);
- }
- /// <summary>
- /// 门
- /// </summary>
- /// <returns>5E 0A 00 06 02 71</returns>
- public static void CreateReadDoorCommand(this CustomProtocol custom)
- {
- custom.sendBuffer = CreateORC(new byte[] { 0x5E, 0x10, 0x00, 0x06, 0x02, 0x00 });
- CustomProtocolLength(custom);
- }
-
- #endregion
- /// <summary>
- /// 读EEPROM->水平电机Well位置,返回长度10个字节
- /// </summary>
- /// <param name="wellNum"></param>
- /// <returns></returns>
- public static void CreateReadEEPROMhoriMtWellHoriPos(this CustomProtocol custom,int wellNum)
- {
- List<byte> command = new List<byte>();
- command.Add(0x5E);
- command.Add(0x11);
- command.Add(0x00);
- command.Add(0x09);
- switch (wellNum)
- {
- case 1:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x00);
- break;
- case 2:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x50);
- break;
- case 3:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x54);
- break;
- case 4:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x58);
- break;
- case 5:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x5C);
- break;
- case 6:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x60);
- break;
- case 7:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x64);
- break;
- case 8:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x68);
- break;
- case 9:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x6C);
- break;
- case 10:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x70);
- break;
- case 11:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x74);
- break;
- case 12:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x78);
- break;
- case 13:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x7C);
- break;
- case 14:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x80);
- break;
- case 15:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x84);
- break;
- case 16:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x04);
- break;
- default:
- break;
- }
- command.Add(0x04);
- command.Add(0x00);
- custom.sendBuffer = CreateORC(command.ToArray());
- CustomProtocolLength(custom);
- }
- /// <summary>
- /// 写EEPROM->水平电机Well位置,返回长度10个字节
- /// </summary>
- /// <param name="wellNum"></param>
- /// <returns></returns>
- public static void CreateWriteEEPROMhoriMtWellHoriPos(this CustomProtocol custom,int wellNum, int newValue)
- {
- byte[] pulses = BitConverter.GetBytes(newValue);
- List<byte> command = new List<byte>();
- command.Add(0x5E);//帧头
- command.Add(0x12);//WRITE_EEPROM
- command.Add(0x00);//CMDNO
- command.Add(0x0C);//LTH
- switch (wellNum)
- {
- case 1:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x00);
- break;
- case 2:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x50);
- break;
- case 3:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x54);
- break;
- case 4:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x58);
- break;
- case 5:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x5C);
- break;
- case 6:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x60);
- break;
- case 7:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x64);
- break;
- case 8:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x68);
- break;
- case 9:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x6C);
- break;
- case 10:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x70);
- break;
- case 11:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x74);
- break;
- case 12:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x78);
- break;
- case 13:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x7C);
- break;
- case 14:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x80);
- break;
- case 15:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x84);
- break;
- case 16:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x04);
- break;
- default:
- break;
- }
- if (BitConverter.IsLittleEndian)
- {
- command.Add(pulses[0]);//参数1(低)
- command.Add(pulses[1]);//参数2
- command.Add(pulses[2]);//参数3
- command.Add(pulses[3]);//参数4(高)
- }
- else
- {
- command.Add(pulses[3]);//参数1(低)
- command.Add(pulses[2]);//参数2
- command.Add(pulses[1]);//参数3
- command.Add(pulses[0]);//参数4 (高)
- }
-
- command.Add(0x00);//校验和CRC
- custom.sendBuffer = CreateORC(command.ToArray());
- CustomProtocolLength(custom);
- }
- /// <summary>
- /// 读EEPROM->下加热板目标温度
- /// </summary>
- /// <param name="wellNum"></param>
- /// <returns></returns>
- public static void CreateReadTargetTemp(this CustomProtocol custom)
- {
- List<byte> command = new List<byte>();
- command.Add(0x5E);
- command.Add(0x11);
- command.Add(0x00);
- command.Add(0x09);
- command.Add(0x00);
- command.Add(0x02);
- command.Add(0x38);
- command.Add(0x04);
- command.Add(0x00);
- custom.sendBuffer = CreateORC(command.ToArray());
- CustomProtocolLength(custom);
- }
- /// <summary>
- /// 读EEPROM->垂直电机焦准脉冲数(零点),返回长度10个字节
- /// </summary>
- /// <returns></returns>
- public static void CreateReadEEPROMvertMtStartPulse(this CustomProtocol custom,int i)
- {
- List<byte> command = new List<byte>();
- command.Add(0x5E);
- command.Add(0x11);
- command.Add(0x00);
- command.Add(0x09);
- switch (i)
- {
- case 1:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x08);
- break;
- case 2:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x0C);
- break;
- case 3:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x10);
- break;
- case 4:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x14);
- break;
- case 5:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x18);
- break;
- case 6:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x1C);
- break;
- case 7:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x20);
- break;
- case 8:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x24);
- break;
- case 9:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x28);
- break;
- case 10:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x2C);
- break;
- case 11:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x30);
- break;
- case 12:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x34);
- break;
- case 13:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x38);
- break;
- case 14:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x3C);
- break;
- case 15:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x40);
- break;
- case 16:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x44);
- break;
- default:
- break;
- }
- command.Add(0x04);
- command.Add(0x00);
- custom.sendBuffer = CreateORC(command.ToArray());
- CustomProtocolLength(custom);
- }
- /// <summary>
- /// 写入EEPROM->垂直电机焦准脉冲数(零点),返回长度6个字节
- /// </summary>
- /// <returns></returns>
- public static void CreateWriteEEPROMvertMtStartPulse(this CustomProtocol custom, int pulse)
- {
- byte[] pulses = BitConverter.GetBytes(pulse);
- List<byte> command = new List<byte>();
- command.Add(0x5E);//帧头
- command.Add(0x12);//WRITE_EEPROM
- command.Add(0x00);//CMDNO
- command.Add(0x0C);//LTH
- command.Add(0x00);//地址(高)
- command.Add(0x03);//地址(中)
- command.Add(0x1C);//地址(低)
- if (BitConverter.IsLittleEndian)
- {
- command.Add(pulses[0]);//参数1(低)
- command.Add(pulses[1]);//参数2
- command.Add(pulses[2]);//参数3
- command.Add(pulses[3]);//参数4(高)
- }
- else
- {
- command.Add(pulses[3]);//参数1(低)
- command.Add(pulses[2]);//参数2
- command.Add(pulses[1]);//参数3
- command.Add(pulses[0]);//参数4 (高)
- }
- command.Add(0x00);//校验和CRC
- custom.sendBuffer = CreateORC(command.ToArray());
- CustomProtocolLength(custom);
- }
- /// <summary>
- /// 读EEPROM->垂直电机扫描间隔脉冲,返回长度10个字节
- /// </summary>
- /// <returns></returns>
- public static void CreateReadEEPROMvertMtScanPluse(this CustomProtocol custom)
- {
- custom.sendBuffer = CreateORC(new byte[] { 0x5E, 0x11, 0x00, 0x09, 0x00, 0x04, 0x48, 0x04, 0x00 });
- CustomProtocolLength(custom);
- }
- /// <summary>
- /// 写入EEPROM->垂直电机扫描间隔脉冲,返回长度6个字节
- /// </summary>
- /// <returns></returns>
- public static void CreateWriteEEPROMvertMtScanPluse(this CustomProtocol custom,int pulse)
- {
- byte[] pulses = BitConverter.GetBytes(pulse);
- List<byte> command = new List<byte>();
- command.Add(0x5E);//帧头
- command.Add(0x12);//WRITE_EEPROM
- command.Add(0x00);//CMDNO
- command.Add(0x0C);//LTH
- command.Add(0x00);//地址(高)
- command.Add(0x04);//地址(中)
- command.Add(0x48);//地址(低)
- if (BitConverter.IsLittleEndian)
- {
- command.Add(pulses[0]);//参数1(低)
- command.Add(pulses[1]);//参数2
- command.Add(pulses[2]);//参数3
- command.Add(pulses[3]);//参数4(高)
- }
- else
- {
- command.Add(pulses[3]);//参数1(低)
- command.Add(pulses[2]);//参数2
- command.Add(pulses[1]);//参数3
- command.Add(pulses[0]);//参数4(高)
- }
- command.Add(0x00);//校验和CRC
- custom.sendBuffer = CreateORC(command.ToArray());
- CustomProtocolLength(custom);
- }
- /// <summary>
- /// 读EEPROM->仓室进气阀打开时间
- /// </summary>
- /// <returns></returns>
- public static void CreateReadEEPROOpenIntakeTimeCommand(this CustomProtocol custom)
- {
- custom.sendBuffer = CreateORC(new byte[] { 0x5E, 0x11, 0x00, 0x09, 0x00, 0x03, 0x0c, 0x04, 0x00 });
- CustomProtocolLength(custom);
- }
- /// <summary>
- /// 写EEPROM->仓室进气阀打开时间
- /// </summary>
- /// <param name="wellNum"></param>
- /// <returns></returns>
- public static void CreateWriteEEPROOpenIntakeTimeCommand(this CustomProtocol custom,int newValue)
- {
- byte[] pulses = BitConverter.GetBytes(newValue);
- List<byte> command = new List<byte>();
- command.Add(0x5E);//帧头
- command.Add(0x12);//WRITE_EEPROM
- command.Add(0x00);//CMDNO
- command.Add(0x0C);//LTH
- command.Add(0x00);
- command.Add(0x03);
- command.Add(0x0c);
- if (BitConverter.IsLittleEndian)
- {
- command.Add(pulses[0]);//参数1(低)
- command.Add(pulses[1]);//参数2
- command.Add(pulses[2]);//参数3
- command.Add(pulses[3]);//参数4(高)
- }
- else
- {
- command.Add(pulses[3]);//参数1(低)
- command.Add(pulses[2]);//参数2
- command.Add(pulses[1]);//参数3
- command.Add(pulses[0]);//参数4(高)
- }
- command.Add(0x00);//校验和CRC
- custom.sendBuffer = CreateORC(command.ToArray());
- CustomProtocolLength(custom);
- }
- /// <summary>
- /// 读EEPROM->缓冲瓶气阀打开时间
- /// </summary>
- /// <returns></returns>
- public static void CreateReadEEPROOpenIntakeTimeBufferCommand(this CustomProtocol custom)
- {
- custom.sendBuffer = CreateORC(new byte[] { 0x5E, 0x11, 0x00, 0x09, 0x00, 0x05, 0x0c, 0x04, 0x00 });
- CustomProtocolLength(custom);
- }
- /// <summary>
- /// 写EEPROM->缓冲瓶进气阀打开时间
- /// </summary>
- /// <param name="wellNum"></param>
- /// <returns></returns>
- public static void CreateWriteEEPROOpenIntakeTimeBufferCommand(this CustomProtocol custom,int newValue)
- {
- byte[] pulses = BitConverter.GetBytes(newValue);
- List<byte> command = new List<byte>();
- command.Add(0x5E);//帧头
- command.Add(0x12);//WRITE_EEPROM
- command.Add(0x00);//CMDNO
- command.Add(0x0C);//LTH
- command.Add(0x00);
- command.Add(0x05);
- command.Add(0x0c);
- if (BitConverter.IsLittleEndian)
- {
- command.Add(pulses[0]);//参数1(低)
- command.Add(pulses[1]);//参数2
- command.Add(pulses[2]);//参数3
- command.Add(pulses[3]);//参数4(高)
- }
- else
- {
- command.Add(pulses[3]);//参数1(低)
- command.Add(pulses[2]);//参数2
- command.Add(pulses[1]);//参数3
- command.Add(pulses[0]);//参数4(高)
- }
- command.Add(0x00);//校验和CRC
- custom.sendBuffer = CreateORC(command.ToArray());
- CustomProtocolLength(custom);
- }
- /// <summary>
- /// 读E方 -->灯光亮度
- /// </summary>
- /// <param name="num"></param>
- /// <returns></returns>
- public static void CreateReadEEPROMLightNum(this CustomProtocol custom)
- {
- var array = new byte[] { 0x5E, 0x11, 0x00, 0x09, 0x00, 0x05, 0x34, 0x04, 0x00 };
- custom.sendBuffer = CreateORC(array);
- CustomProtocolLength(custom);
- }
- // ── M-01/M-02/M-03 合并遗留补齐:写/读舱室排气阀打开时间、写灯光亮度 ──
- // 字节与合并前 operate 端 ivf_tl_Entity/ComEntitys/Commander.cs 同名方法逐字一致(地址表/小端/CreateORC),
- // 该实现真机已用;补此三 builder 以解除 SerialChannelImpl 的 M-01/M-02/M-03 桩(此前 control Commander 缺对应 builder)。
- /// <summary>
- /// 写EEPROM->舱室排气阀打开时间(地址 00 03 08,与写进气阀 00 03 0c 仅地址低字节不同)
- /// </summary>
- public static void CreateWriteEEPROOpenVentTimeCommand(this CustomProtocol custom, int newValue)
- {
- byte[] pulses = BitConverter.GetBytes(newValue);
- List<byte> command = new List<byte>();
- command.Add(0x5E);//帧头
- command.Add(0x12);//WRITE_EEPROM
- command.Add(0x00);//CMDNO
- command.Add(0x0C);//LTH
- command.Add(0x00);
- command.Add(0x03);
- command.Add(0x08);
- if (BitConverter.IsLittleEndian)
- {
- command.Add(pulses[0]);//参数1(低)
- command.Add(pulses[1]);//参数2
- command.Add(pulses[2]);//参数3
- command.Add(pulses[3]);//参数4(高)
- }
- else
- {
- command.Add(pulses[3]);//参数1(低)
- command.Add(pulses[2]);//参数2
- command.Add(pulses[1]);//参数3
- command.Add(pulses[0]);//参数4(高)
- }
- command.Add(0x00);//校验和CRC
- custom.sendBuffer = CreateORC(command.ToArray());
- CustomProtocolLength(custom);
- }
- /// <summary>
- /// 读E方 -->舱室排气阀打开时间(地址 00 03 08)
- /// </summary>
- public static void CreateReadEEPROMVentNum(this CustomProtocol custom)
- {
- var array = new byte[] { 0x5E, 0x11, 0x00, 0x09, 0x00, 0x03, 0x08, 0x04, 0x00 };
- custom.sendBuffer = CreateORC(array);
- CustomProtocolLength(custom);
- }
- /// <summary>
- /// 写E方 -->灯光亮度(地址 00 05 34,与读灯光亮度同地址)
- /// </summary>
- public static void CreateWriteEEPROMLightNum(this CustomProtocol custom, int num)
- {
- byte[] newValue = BitConverter.GetBytes(num);
- List<byte> command = new List<byte>();
- command.Add(0x5E);//帧头
- command.Add(0x12);//WRITE_EEPROM
- command.Add(0x00);//CMDNO
- command.Add(0x0C);//LTH
- command.Add(0x00);//地址(高)
- command.Add(0x05);//地址(中)
- command.Add(0x34);//地址(低)
- if (BitConverter.IsLittleEndian)
- {
- command.Add(newValue[0]);//参数1(低)
- command.Add(newValue[1]);//参数2
- command.Add(newValue[2]);//参数3
- command.Add(newValue[3]);//参数4(高)
- }
- else
- {
- command.Add(newValue[3]);//参数1(低)
- command.Add(newValue[2]);//参数2
- command.Add(newValue[1]);//参数3
- command.Add(newValue[0]);//参数4(高)
- }
- command.Add(0x00);//校验和CRC
- custom.sendBuffer = CreateORC(command.ToArray());
- CustomProtocolLength(custom);
- }
- /// <summary>
- /// 读EEPROM->CCDSN
- /// </summary>
- /// <returns></returns>
- public static void CreateGetModuleCommand(this CustomProtocol custom)
- {
- custom.sendBuffer = CreateORC(new byte[] { 0x5E, 0x11, 0x00, 0x09, 0x00, 0x00, 0x10, 0x04, 0x00 });
- CustomProtocolLength(custom);
- }
- /// <summary>
- /// 写EEPROM
- /// </summary>
- /// <param name="address">地址</param>
- /// <param name="value">值</param>
- /// <returns></returns>
- public static void CreateWriteEEPROM(this CustomProtocol custom,int address, double value)
- {
- byte[] byteAddress = BitConverter.GetBytes(address);
- byte[] byteValue = BitConverter.GetBytes(value);
- List<byte> command = new List<byte>();
- command.Add(0x5E);//帧头
- command.Add(0x12);//WRITE_EEPROM
- command.Add(0x00);//CMDNO
- command.Add(0x0C);//LTH
- if (BitConverter.IsLittleEndian)
- {
- command.Add(byteAddress[2]);//地址(高)
- command.Add(byteAddress[1]);//地址(中)
- command.Add(byteAddress[0]);//地址(低)
- command.Add(byteValue[0]);//参数1(低)
- command.Add(byteValue[1]);//参数2
- command.Add(byteValue[2]);//参数3
- command.Add(byteValue[3]);//参数4(高)
- }
- else
- {
- command.Add(byteAddress[0]);//地址(高)
- command.Add(byteAddress[1]);//地址(中)
- command.Add(byteAddress[2]);//地址(低)
- command.Add(byteValue[3]);//参数1(低)
- command.Add(byteValue[2]);//参数2
- command.Add(byteValue[1]);//参数3
- command.Add(byteValue[0]);//参数4(高)
- }
-
- command.Add(0x00);//校验和CRC
- custom.sendBuffer = CreateORC(command.ToArray());
- CustomProtocolLength(custom);
- }
- #region 电机运动
- /// <summary>
- /// 水平电机复位运动,长度11
- /// </summary>
- /// <returns></returns>
- public static void CreateHorizontalMotorResetCommand(this CustomProtocol custom)
- {
- /*
- * 第1字节 第2字节 第3字节 第4字节 第5字节 第6字节 第7字节 第8字节 第9字节 第10字节 第11字节
- 帧头 ST SET_MOTOR CMDNO LTH 辅助指令码 参数1 参数2 参数3 参数4 参数5 校验和CRC
- 帧头 ST = 5E
- SET_MOTOR = 0x05
- CMDNO = 00
- LTH = 11
- 辅助指令码 = 高半字节(水平电机=1|扫描电机=2) + 低半字节(正转=0|反转=1|脱机=2|复位=3|绝对运动=4)
- 参数1,参数2:电机运动的脉冲值,参数1是高8位,参数2是低8位,组成16位的脉冲值;
- 参数3:0x00;
- 参数4,参数5:0x00,0x00
- */
- custom.sendBuffer = CreateORC(new byte[] { 0x5E, 0x05, 0x00, 0x0B, 0x13, 0x00, 0x00, 0x00, 0x0B, 0xB8, 0x44 });
- CustomProtocolLength(custom);
- }
- /// <summary>
- /// 水平电机正向运动,长度11
- /// </summary>
- /// <param name="pulse">脉冲值</param>
- /// <returns></returns>
- public static void CreateHorizontalMotorForwardCommand(this CustomProtocol custom,int? pulse)
- {
- byte[] pulses = BitConverter.GetBytes(pulse.Value);
- List<byte> command = new List<byte>();
- command.Add(0x5E);//帧头
- command.Add(0x05);//SET_MOTOR
- command.Add(0x00);//CMDNO
- command.Add(0x0B);//LTH
- command.Add(0x10);//辅助指令码
- if (BitConverter.IsLittleEndian)
- {
- command.Add(pulses[3]);//参数1 高
- command.Add(pulses[2]);//参数2
- command.Add(pulses[1]);//参数3
- command.Add(pulses[0]);//参数4 低
- }
- else
- {
- command.Add(pulses[0]);//参数1 高
- command.Add(pulses[1]);//参数2
- command.Add(pulses[2]);//参数3
- command.Add(pulses[3]);//参数4 低
- }
- command.Add(0x00);//参数5
- command.Add(0x00);//校验和CRC
- custom.sendBuffer = CreateORC(command.ToArray());
- CustomProtocolLength(custom);
- }
- /// <summary>
- /// 水平电机反向运动,长度11
- /// </summary>
- /// <returns></returns>
- public static void CreateHorizontalMotorBackwardCommand(this CustomProtocol custom,int? pulse)
- {
- byte[] pulses = BitConverter.GetBytes(pulse.Value);
- List<byte> command = new List<byte>();
- command.Add(0x5E);//帧头
- command.Add(0x05);//SET_MOTOR
- command.Add(0x00);//CMDNO
- command.Add(0x0B);//LTH
- command.Add(0x11);//辅助指令码
- if (BitConverter.IsLittleEndian)
- {
- command.Add(pulses[3]);//参数1 高
- command.Add(pulses[2]);//参数2
- command.Add(pulses[1]);//参数3
- command.Add(pulses[0]);//参数4 低
- }
- else
- {
- command.Add(pulses[0]);//参数1 高
- command.Add(pulses[1]);//参数2
- command.Add(pulses[2]);//参数3
- command.Add(pulses[3]);//参数4 低
- }
- command.Add(0x00);//参数5
- command.Add(0x00);//校验和CRC
- custom.sendBuffer = CreateORC(command.ToArray());
- CustomProtocolLength(custom);
- }
- /// <summary>
- /// 水平电机绝对运动
- /// </summary>
- /// <param name="pulse"></param>
- /// <returns></returns>
- public static void CreateHorizontalMotorMoveToCommand(this CustomProtocol custom,int? pulse)
- {
- byte[] pulses = BitConverter.GetBytes(pulse.Value);
- List<byte> command = new List<byte>();
- command.Add(0x5E);//帧头
- command.Add(0x05);//SET_MOTOR
- command.Add(0x00);//CMDNO
- command.Add(0x0B);//LTH
- command.Add(0x14);//辅助指令码
- if (BitConverter.IsLittleEndian)
- {
- command.Add(pulses[3]);//参数1 高
- command.Add(pulses[2]);//参数2
- command.Add(pulses[1]);//参数3
- command.Add(pulses[0]);//参数4 低
- }
- else
- {
- command.Add(pulses[0]);//参数1 高
- command.Add(pulses[1]);//参数2
- command.Add(pulses[2]);//参数3
- command.Add(pulses[3]);//参数4 低
- }
- command.Add(0x00);//参数5
- command.Add(0x00);//校验和CRC
- custom.sendBuffer = CreateORC(command.ToArray());
- CustomProtocolLength(custom);
- }
- /// <summary>
- /// 垂直电机复位运动,长度11
- /// </summary>
- /// <returns></returns>
- public static void CreateVerticalMotorResetCommand(this CustomProtocol custom)
- {
- custom.sendBuffer = CreateORC(new byte[] { 0x5E, 0x05, 0x00, 0x0B, 0x23, 0x00, 0x00, 0x00, 0x07, 0xD0, 0x68 });
- CustomProtocolLength(custom);
- }
- /// <summary>
- /// 垂直电机正向运动,长度11
- /// </summary>
- /// <param name="pulse">脉冲值</param>
- /// <returns></returns>
- public static void CreateVerticalMotorForwardCommand(this CustomProtocol custom,int? pulse)
- {
- byte[] pulses = BitConverter.GetBytes(pulse.Value);
- List<byte> command = new List<byte>();
- command.Add(0x5E);//帧头
- command.Add(0x05);//SET_MOTOR
- command.Add(0x00);//CMDNO
- command.Add(0x0B);//LTH
- command.Add(0x20);//辅助指令码
- if (BitConverter.IsLittleEndian)
- {
- command.Add(pulses[3]);//参数1 高
- command.Add(pulses[2]);//参数2
- command.Add(pulses[1]);//参数3
- command.Add(pulses[0]);//参数4 低
- }
- else
- {
- command.Add(pulses[0]);//参数1 高
- command.Add(pulses[1]);//参数2
- command.Add(pulses[2]);//参数3
- command.Add(pulses[3]);//参数4 低
- }
- command.Add(0x00);//参数5
- command.Add(0x00);//校验和CRC
- custom.sendBuffer = CreateORC(command.ToArray());
- CustomProtocolLength(custom);
- }
- /// <summary>
- /// 垂直电机绝对运动
- /// </summary>
- /// <param name="pulse"></param>
- /// <returns></returns>
- public static void CreateVerticalMotorAbsoluteMovementCommand(this CustomProtocol custom,int? pulse)
- {
- byte[] pulses = BitConverter.GetBytes(pulse.Value);
- List<byte> command = new List<byte>();
- command.Add(0x5E);//帧头
- command.Add(0x05);//SET_MOTOR
- command.Add(0x00);//CMDNO
- command.Add(0x0B);//LTH
- command.Add(0x24);//辅助指令码
- if (BitConverter.IsLittleEndian)
- {
- command.Add(pulses[3]);//参数1 高
- command.Add(pulses[2]);//参数2
- command.Add(pulses[1]);//参数3
- command.Add(pulses[0]);//参数4 低
- }
- else
- {
- command.Add(pulses[0]);//参数1 高
- command.Add(pulses[1]);//参数2
- command.Add(pulses[2]);//参数3
- command.Add(pulses[3]);//参数4 低
- }
- command.Add(0x00);//参数5
- command.Add(0x00);//校验和CRC
- custom.sendBuffer = CreateORC(command.ToArray());
- CustomProtocolLength(custom);
- }
- /// <summary>
- /// 垂直电机反向运动,长度11
- /// </summary>
- /// <returns></returns>
- public static void CreateVerticalMotorBackwardCommand(this CustomProtocol custom,int? pulse)
- {
- byte[] pulses = BitConverter.GetBytes(pulse.Value);
- List<byte> command = new List<byte>();
- command.Add(0x5E);//帧头
- command.Add(0x05);//SET_MOTOR
- command.Add(0x00);//CMDNO
- command.Add(0x0B);//LTH
- command.Add(0x21);//辅助指令码
- if (BitConverter.IsLittleEndian)
- {
- command.Add(pulses[3]);//参数1 高
- command.Add(pulses[2]);//参数2
- command.Add(pulses[1]);//参数3
- command.Add(pulses[0]);//参数4 低
- }
- else
- {
- command.Add(pulses[0]);//参数1 高
- command.Add(pulses[1]);//参数2
- command.Add(pulses[2]);//参数3
- command.Add(pulses[3]);//参数4 低
- }
- command.Add(0x00);//参数5
- command.Add(0x00);//校验和CRC
- custom.sendBuffer = CreateORC(command.ToArray());
- CustomProtocolLength(custom);
- }
- #endregion
- #region
- /// <summary>
- /// 换气时打开气阀
- /// </summary>
- /// <returns></returns>
- public static byte[] CreateOpenGasValveCommand()
- {
- return CreateORC(new byte[] { 0x5E, 0x09, 0x00, 0x07, 0x01, 0x01, 0x00 });//上电
- }
- /// <summary>
- /// 换气时关闭气阀
- /// </summary>
- /// <returns></returns>
- public static byte[] CreateCloseGasValveCommand()
- {
- return CreateORC(new byte[] { 0x5E, 0x09, 0x00, 0x07, 0x01, 0x00, 0x00 });//断电
- }
- /// <summary>
- /// 培养指令
- /// </summary>
- /// <param name="isOpen"></param>
- /// <returns></returns>
- public static byte[] CreateGasCommand(bool isOpen)
- {
- //5E 09 00 07 02 01 71
- if (isOpen)
- return CreateORC(new byte[] { 0x5E, 0x09, 0x00, 0x07, 0x02, 0x01, 0x00 });//开始培养
- else
- return CreateORC(new byte[] { 0x5E, 0x09, 0x00, 0x07, 0x02, 0x00, 0x00 });//结束培养
- }
- /// <summary>
- /// 读EEPROM->水平电机well间隔脉冲,返回长度10个字节
- /// </summary>
- /// <returns></returns>
- public static byte[] CreateReadEEPROMhoriMtWellInterval()
- {
- var array = new byte[] { 0x5E, 0x11, 0x00, 0x09, 0x00, 0x02, 0x24, 0x04, 0x00 };
- return CreateORC(array);
- }
- /// <summary>
- /// 读EEPROM->16垂直电机焦准脉冲数(零点),返回长度10个字节
- /// </summary>
- /// <returns></returns>
- public static byte[] CreateReadEEPROMvertMtStartPulse1(int wellNum)
- {
- List<byte> command = new List<byte>();
- command.Add(0x5E);
- command.Add(0x11);
- command.Add(0x00);
- command.Add(0x09);
- switch (wellNum)
- {
- case 1:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x08);
- break;
- case 2:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x0C);
- break;
- case 3:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x10);
- break;
- case 4:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x14);
- break;
- case 5:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x18);
- break;
- case 6:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x1C);
- break;
- case 7:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x20);
- break;
- case 8:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x24);
- break;
- case 9:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x28);
- break;
- case 10:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x2C);
- break;
- case 11:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x30);
- break;
- case 12:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x34);
- break;
- case 13:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x38);
- break;
- case 14:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x3C);
- break;
- case 15:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x40);
- break;
- case 16:
- command.Add(0x00);
- command.Add(0x04);
- command.Add(0x44);
- break;
- default:
- break;
- }
- command.Add(0x04);
- command.Add(0x00);
- var result = CreateORC(command.ToArray());
- return result;
- }
- /// <summary>
- /// 写EEPROM->水平电机1号Well位置(零点),返回长度6个字节
- /// </summary>
- /// <returns></returns>
- public static byte[] CreateWriteEEPROMhoriMtWell1HoriPos(int pulse)
- {
- byte[] pulses = BitConverter.GetBytes(pulse);
- List<byte> command = new List<byte>();
- command.Add(0x5E);//帧头
- command.Add(0x12);//WRITE_EEPROM
- command.Add(0x00);//CMDNO
- command.Add(0x0C);//LTH
- command.Add(0x00);//地址(高)
- command.Add(0x04);//地址(中)
- command.Add(0x00);//地址(低)
- if (BitConverter.IsLittleEndian)
- {
- command.Add(pulses[0]);//参数1(低)
- command.Add(pulses[1]);//参数2
- command.Add(pulses[2]);//参数3
- command.Add(pulses[3]);//参数4(高)
- }
- else
- {
- command.Add(pulses[3]);//参数1(低)
- command.Add(pulses[2]);//参数2
- command.Add(pulses[1]);//参数3
- command.Add(pulses[0]);//参数4(高)
- }
- command.Add(0x00);//校验和CRC
- var result = CreateORC(command.ToArray());
- return result;
- }
- /// <summary>
- /// 写入EEPROM->水平电机well间隔脉冲,返回长度6个字节
- /// </summary>
- /// <returns></returns>
- public static byte[] CreateWriteEEPROMhoriMtWellInterval(int pulse)
- {
- byte[] pulses = BitConverter.GetBytes(pulse);
- List<byte> command = new List<byte>();
- command.Add(0x5E);//帧头
- command.Add(0x12);//WRITE_EEPROM
- command.Add(0x00);//CMDNO
- command.Add(0x0C);//LTH
- command.Add(0x00);//地址(高)
- command.Add(0x02);//地址(中)
- command.Add(0x24);//地址(低)
- if (BitConverter.IsLittleEndian)
- {
- command.Add(pulses[0]);//参数1(低)
- command.Add(pulses[1]);//参数2
- command.Add(pulses[2]);//参数3
- command.Add(pulses[3]);//参数4(高)
- }
- else
- {
- command.Add(pulses[3]);//参数1(低)
- command.Add(pulses[2]);//参数2
- command.Add(pulses[1]);//参数3
- command.Add(pulses[0]);//参数4(高)
- }
- command.Add(0x00);//校验和CRC
- var result = CreateORC(command.ToArray());
- return result;
- }
- /// <summary>
- /// 写入EEPROM->换气标志
- /// </summary>
- /// <param name="flag">换气前写1,换气后写0。</param>
- /// <returns></returns>
- public static byte[] CreateWriteEEPROMChangeAir(uint flag)
- {
- byte[] pulses = BitConverter.GetBytes(flag);
- List<byte> command = new List<byte>();
- command.Add(0x5E);//帧头
- command.Add(0x12);//WRITE_EEPROM
- command.Add(0x00);//CMDNO
- command.Add(0x0C);//LTH
- command.Add(0x00);//地址(高)
- command.Add(0x03);//地址(中)
- command.Add(0x3C);//地址(低)
- if (BitConverter.IsLittleEndian)
- {
- command.Add(pulses[0]);//参数1(低)
- command.Add(pulses[1]);//参数2
- command.Add(pulses[2]);//参数3
- command.Add(pulses[3]);//参数4(高)
- }
- else
- {
- command.Add(pulses[3]);//参数1(低)
- command.Add(pulses[2]);//参数2
- command.Add(pulses[1]);//参数3
- command.Add(pulses[0]);//参数4(高)
- }
- command.Add(0x00);//校验和CRC
- var result = CreateORC(command.ToArray());
- return result;
- }
- /// <summary>
- /// 换气标志
- /// </summary>
- /// <param name="flag">flag=1表示换气前执行的操作</param>
- /// <returns></returns>
- public static byte[] CreateChangeAir(uint flag)
- {
- //5E 09 00 07 03 01 72 换气前
- //5E 09 00 07 03 00 71 换气后
- byte[] newValue = BitConverter.GetBytes(flag);
- List<byte> command = new List<byte>();
- command.Add(0x5E);//帧头
- command.Add(0x09);//WRITE_EEPROM
- command.Add(0x00);//CMDNO
- command.Add(0x07);//LTH
- command.Add(0x03);
- if (flag == 1)
- {
- command.Add(0x01);
- command.Add(0x72);
- }
- else
- {
- command.Add(0x00);
- command.Add(0x71);
- }
- return command.ToArray();
- }
- #endregion
- }
- }
|