HSLMCProtocolPlc.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711
  1. using Aitex.Core.RT.DataCenter;
  2. using Aitex.Core.RT.Event;
  3. using Aitex.Core.RT.IOCore;
  4. using Aitex.Core.RT.Log;
  5. using Aitex.Core.RT.OperationCenter;
  6. using Aitex.Core.RT.SCCore;
  7. using Aitex.Core.Util;
  8. using MECF.Framework.Common.Communications;
  9. using MECF.Framework.RT.Core.IoProviders;
  10. using MECF.Framework.RT.Core.IoProviders.Mitsubishis;
  11. using System;
  12. using System.Collections;
  13. using System.Collections.Generic;
  14. using System.Diagnostics;
  15. using System.Linq;
  16. using System.Net;
  17. using System.Net.Sockets;
  18. using System.Text;
  19. using System.Threading;
  20. using System.Threading.Tasks;
  21. using System.Xml;
  22. using MECF.Framework.RT.Core.IoProviders.Melsec;
  23. using MECF.Framework.RT.Core.IoProviders.Common;
  24. namespace MECF.Framework.RT.Core.IoProviders.Mitsubishis
  25. {
  26. public class HSLMCProtocolPlc : IoProvider, IConnection
  27. {
  28. public string Address
  29. {
  30. get { return $"{_ip}:{_port}"; }
  31. }
  32. public bool IsConnected
  33. {
  34. get { return IsOpened; }
  35. }
  36. public bool Connect()
  37. {
  38. return true;
  39. }
  40. public bool Disconnect()
  41. {
  42. return true;
  43. }
  44. private string _ip = "127.0.0.1";
  45. //private string _localIp = "127.0.0.1";
  46. private int _port = 6731;
  47. private int _socketId = 101;
  48. private int _stationId = 102;
  49. private byte[] _bufferIn;
  50. private byte[] _bufferOut;
  51. private MelsecMcNet melsec_net = null;
  52. //private int demandAiFrom; //should be the same the offset in lstBuffers
  53. //private int demandAiSize;
  54. //private int demandAoFrom; //should be the same the offset in lstBuffers
  55. //private int demandAoSize;
  56. //private bool inDemanding = false;
  57. private string aiStoragename = "D";
  58. private string aoStoragename = "D";
  59. private string diStoragename = "B";
  60. private string doStoragename = "B";
  61. private ushort perIoLength = 960;
  62. private Stopwatch stopwatchDi = new Stopwatch();
  63. private Stopwatch stopwatchDo = new Stopwatch();
  64. private Stopwatch stopwatchAi = new Stopwatch();
  65. private Stopwatch stopwatchAo = new Stopwatch();
  66. private int comunicationSpanDi;
  67. private int comunicationSpanDo;
  68. private int comunicationSpanAi;
  69. private int comunicationSpanAo;
  70. protected int comunicationSpanTotal;
  71. private Stopwatch stopwatchTotal = new Stopwatch();
  72. private int diStartAddress;
  73. private int doStartAddress;
  74. private int aiStartAddress;
  75. private int aoStartAddress;
  76. //private List<IoBlockItem> _blockSectionsDemand;
  77. private int plcCollectionInterval;
  78. private int connectionNumber;
  79. private bool isWriteRecipe;
  80. private int recipeOffset;
  81. private short[] recipeData = new short[50 * 15];
  82. public override void Initialize(string module, string name, List<IoBlockItem> lstBuffers, IIoBuffer buffer, XmlElement nodeParameter, string ioMappingPathFile, string ioModule)
  83. {
  84. Module = module;
  85. Name = name;
  86. _source = module + "." + name;
  87. _buffer = buffer;
  88. _nodeParameter = nodeParameter;
  89. _blockSections = lstBuffers;
  90. buffer.SetBufferBlock(_source, lstBuffers);
  91. buffer.SetIoMapByModule(_source, 0, ioMappingPathFile, ioModule);
  92. SetParameter(nodeParameter);
  93. State = IoProviderStateEnum.Uninitialized;
  94. plcCollectionInterval = SC.ContainsItem("System.PlcCollectionInterval") ? SC.GetValue<int>("System.PlcCollectionInterval") : 50;
  95. _thread = new PeriodicJob(plcCollectionInterval, OnTimer, name);
  96. ConnectionManager.Instance.Subscribe(Name, this);
  97. DATA.Subscribe($"{Module}.{Name}.IsConnected", () => melsec_net == null ? false : melsec_net.IsConnected);
  98. OP.Subscribe($"{Name}.Reconnect", (string cmd, object[] args) =>
  99. {
  100. Close();
  101. Open();
  102. return true;
  103. });
  104. }
  105. protected override bool OnTimer()
  106. {
  107. if (State == IoProviderStateEnum.Uninitialized)
  108. {
  109. SetState(IoProviderStateEnum.Opening);
  110. Open();
  111. }
  112. if (State == IoProviderStateEnum.Opened)
  113. {
  114. try
  115. {
  116. stopwatchTotal.Start();
  117. foreach (var bufferSection in _blockSections)
  118. {
  119. if (bufferSection.Type == IoType.DI)
  120. {
  121. stopwatchDi.Start();
  122. bool[] diBuffer = ReadDi(bufferSection.Offset, bufferSection.Size);
  123. if (diBuffer != null)
  124. {
  125. _buffer.SetDiBuffer(_source, bufferSection.Offset, diBuffer);
  126. //TraceArray(diBuffer);
  127. }
  128. stopwatchDi.Stop();
  129. }
  130. else if (bufferSection.Type == IoType.AI)
  131. {
  132. stopwatchAi.Start();
  133. short[] aiBuffer = ReadAi(bufferSection.Offset, bufferSection.Size);
  134. if (aiBuffer != null)
  135. {
  136. _buffer.SetAiBuffer(_source, bufferSection.Offset, aiBuffer);
  137. }
  138. stopwatchAi.Stop();
  139. }
  140. //else if (bufferSection.Type == IoType.DO)
  141. //{
  142. // bool[] doBuffer = ReadDo(bufferSection.Offset, bufferSection.Size);
  143. // if (doBuffer != null)
  144. // {
  145. // _buffer.SetDoBuffer(_source, bufferSection.Offset, doBuffer);
  146. // }
  147. //}
  148. //else if (bufferSection.Type == IoType.AO)
  149. //{
  150. // short[] aoBuffer = ReadAo(bufferSection.Offset, bufferSection.Size);
  151. // if (aoBuffer != null)
  152. // {
  153. // _buffer.SetAoBuffer(_source, bufferSection.Offset, aoBuffer);
  154. // if (bufferSection.AIOType == typeof(float))
  155. // {
  156. // _isAIOFloatType = true;
  157. // _buffer.SetAoBufferFloat(_source, bufferSection.Offset, Array.ConvertAll(aoBuffer, x => (float)x).ToArray());
  158. // }
  159. // }
  160. //}
  161. }
  162. comunicationSpanDi = (int)stopwatchDi.ElapsedMilliseconds;
  163. stopwatchDi.Reset();
  164. comunicationSpanAi = (int)stopwatchAi.ElapsedMilliseconds;
  165. stopwatchAi.Reset();
  166. stopwatchAo.Start();
  167. Dictionary<int, short[]> aos = _buffer.GetAoBuffer(_source);
  168. if (aos != null)
  169. {
  170. foreach (var ao in aos)
  171. {
  172. WriteAo(aoStartAddress, ao.Value);
  173. }
  174. }
  175. stopwatchAo.Stop();
  176. comunicationSpanAo = (int)stopwatchAo.ElapsedMilliseconds;
  177. stopwatchAo.Reset();
  178. stopwatchDo.Start();
  179. Dictionary<int, bool[]> dos = _buffer.GetDoBuffer(_source);
  180. if (dos != null)
  181. {
  182. foreach (var doo in dos)
  183. {
  184. WriteDo(doStartAddress, doo.Value);
  185. }
  186. }
  187. stopwatchDo.Stop();
  188. comunicationSpanDo = (int)stopwatchDo.ElapsedMilliseconds;
  189. stopwatchDo.Reset();
  190. if (isWriteRecipe)
  191. {
  192. isWriteRecipe = false;
  193. WriteRecipe(recipeOffset, recipeData);
  194. }
  195. stopwatchTotal.Stop();
  196. comunicationSpanTotal = (int)stopwatchTotal.ElapsedMilliseconds;
  197. stopwatchTotal.Reset();
  198. }
  199. catch (Exception ex)
  200. {
  201. LOG.Error($"{Name} {ex}");
  202. //SetState(IoProviderStateEnum.Error);
  203. Thread.Sleep(1000);
  204. Close();
  205. Open();
  206. }
  207. }
  208. _trigError.CLK = State == IoProviderStateEnum.Error;
  209. if (_trigError.Q)
  210. {
  211. EV.PostAlarmLog(Module, $"{_source} PLC {_ip}:{_port} error");
  212. }
  213. _trigNotConnected.CLK = State != IoProviderStateEnum.Opened;
  214. if (_trigNotConnected.T)
  215. {
  216. EV.PostInfoLog(Module, $"{_source} connected");
  217. }
  218. if (_trigNotConnected.R)
  219. {
  220. EV.PostAlarmLog(Module, $"{_source} PLC {_ip}:{_port} not connected");
  221. }
  222. if (State != IoProviderStateEnum.Opened && connectionNumber < 3)
  223. {
  224. Thread.Sleep(1000);
  225. Close();
  226. Open();
  227. connectionNumber++;
  228. EV.PostInfoLog(Module, $"{_source} PLC {_ip}:{_port} reconnection {connectionNumber}");
  229. if (connectionNumber >=3)
  230. {
  231. EV.PostAlarmLog(Module, $"{_source} PLC {_ip}:{_port} not connected");
  232. }
  233. }
  234. return true;
  235. }
  236. public override void Reset()
  237. {
  238. if (State != IoProviderStateEnum.Opened)
  239. {
  240. Close();
  241. Open();
  242. connectionNumber = 0;
  243. }
  244. }
  245. protected override void SetParameter(XmlElement nodeParameter)
  246. {
  247. string strIp = nodeParameter.GetAttribute("ip");
  248. //_localIp = nodeParameter.GetAttribute("localIp");
  249. string strPort = nodeParameter.GetAttribute("port");
  250. string networkId = nodeParameter.GetAttribute("network_id");
  251. string stationId = nodeParameter.GetAttribute("station_id");
  252. aiStoragename = nodeParameter.GetAttribute("aiStoragename");
  253. aoStoragename = nodeParameter.GetAttribute("aoStoragename");
  254. diStoragename = nodeParameter.GetAttribute("diStoragename");
  255. doStoragename = nodeParameter.GetAttribute("doStoragename");
  256. ushort.TryParse(nodeParameter.GetAttribute("perIoLength"), out perIoLength);
  257. perIoLength = perIoLength == 0 ? (ushort)960 : perIoLength;
  258. int.TryParse(nodeParameter.GetAttribute("doStartAddress"), out doStartAddress);
  259. int.TryParse(nodeParameter.GetAttribute("diStartAddress"), out diStartAddress);
  260. int.TryParse(nodeParameter.GetAttribute("aoStartAddress"), out aoStartAddress);
  261. int.TryParse(nodeParameter.GetAttribute("aiStartAddress"), out aiStartAddress);
  262. _port = int.Parse(strPort);
  263. _ip = strIp;
  264. _socketId = int.Parse(networkId);
  265. _stationId = int.Parse(stationId);
  266. }
  267. protected override void Open()
  268. {
  269. melsec_net = new MelsecMcNet(_ip, _port);
  270. _bufferOut = new byte[2048];
  271. _bufferIn = new byte[2048];
  272. melsec_net.ConnectClose();
  273. try
  274. {
  275. OperateResult connect = melsec_net.ConnectServer();
  276. if (connect.IsSuccess)
  277. {
  278. SetState(IoProviderStateEnum.Opened);
  279. }
  280. }
  281. catch (Exception ex)
  282. {
  283. LOG.Error(ex.Message);
  284. }
  285. }
  286. protected override void Close()
  287. {
  288. melsec_net.ConnectClose();
  289. SetState(IoProviderStateEnum.Closed);
  290. }
  291. protected override bool[] ReadDi(int offset, int size)
  292. {
  293. bool[] buff = new bool[size];
  294. int count = size / perIoLength;
  295. if (count < 1)
  296. {
  297. bool[] dibuffer = DoReadDi(diStartAddress, (ushort)size);
  298. if (dibuffer != null)
  299. Array.Copy(dibuffer, 0, buff, 0, dibuffer.Length);
  300. else
  301. return null;
  302. }
  303. else
  304. {
  305. bool[] dibuffer;
  306. for (int i = 0; i < count; i++)
  307. {
  308. dibuffer = DoReadDi(i * perIoLength + diStartAddress, perIoLength);
  309. if (dibuffer != null)
  310. Array.Copy(dibuffer, 0, buff, i * perIoLength, dibuffer.Length);
  311. else
  312. return null;
  313. }
  314. if (size % perIoLength != 0)
  315. {
  316. dibuffer = DoReadDi(diStartAddress + perIoLength * count, (ushort)(size % perIoLength));
  317. if (dibuffer != null)
  318. Array.Copy(dibuffer, 0, buff, size - size % perIoLength, dibuffer.Length);
  319. else
  320. return null;
  321. }
  322. }
  323. return buff;
  324. }
  325. protected bool[] ReadDo(int offset, int size)
  326. {
  327. bool[] buff = new bool[size];
  328. int count = size / perIoLength;
  329. if (count < 1)
  330. {
  331. bool[] dobuffer = DoReadDo(doStartAddress, (ushort)size);
  332. if (dobuffer != null)
  333. Array.Copy(dobuffer, 0, buff, 0, dobuffer.Length);
  334. else
  335. return null;
  336. }
  337. else
  338. {
  339. bool[] dobuffer;
  340. for (int i = 0; i < count; i++)
  341. {
  342. dobuffer = DoReadDo(i * perIoLength + doStartAddress, perIoLength);
  343. if (dobuffer != null)
  344. Array.Copy(dobuffer, 0, buff, i * perIoLength, dobuffer.Length);
  345. else
  346. return null;
  347. }
  348. if (size % perIoLength != 0)
  349. {
  350. dobuffer = DoReadDo(doStartAddress + perIoLength * count, (ushort)(size % perIoLength));
  351. if (dobuffer != null)
  352. Array.Copy(dobuffer, 0, buff, size - size % perIoLength, dobuffer.Length);
  353. else
  354. return null;
  355. }
  356. }
  357. return buff;
  358. }
  359. protected override short[] ReadAi(int offset, int size)
  360. {
  361. short[] buff = new short[size];
  362. int count = size / perIoLength;
  363. if (count < 1)
  364. {
  365. short[] aibuffer = DoReadAi(aiStartAddress, size);
  366. if (aibuffer != null)
  367. Array.Copy(aibuffer, 0, buff, 0, aibuffer.Length);
  368. }
  369. else
  370. {
  371. short[] aibuffer;
  372. for (int i = 0; i < count; i++)
  373. {
  374. aibuffer = DoReadAi(i * perIoLength + aiStartAddress, perIoLength);
  375. if (aibuffer != null)
  376. Array.Copy(aibuffer, 0, buff, i * perIoLength, aibuffer.Length);
  377. }
  378. if (size % perIoLength != 0)
  379. {
  380. aibuffer = DoReadAi(aiStartAddress + perIoLength * count, (ushort)(size % perIoLength));
  381. if (aibuffer != null)
  382. Array.Copy(aibuffer, 0, buff, size - size % perIoLength, aibuffer.Length);
  383. }
  384. }
  385. return buff;
  386. }
  387. protected short[] ReadAo(int offset, int size)
  388. {
  389. short[] buff = new short[size];
  390. int count = size / perIoLength;
  391. if (count < 1)
  392. {
  393. short[] aobuffer = DoReadAo(aoStartAddress, (ushort)size);
  394. if (aobuffer != null)
  395. Array.Copy(aobuffer, 0, buff, 0, aobuffer.Length);
  396. }
  397. else
  398. {
  399. short[] aobuffer;
  400. for (int i = 0; i < count; i++)
  401. {
  402. aobuffer = DoReadAo(i * perIoLength + aoStartAddress, perIoLength);
  403. if (aobuffer != null)
  404. Array.Copy(aobuffer, 0, buff, i * perIoLength, aobuffer.Length);
  405. }
  406. if (size % perIoLength != 0)
  407. {
  408. aobuffer = DoReadAo(aoStartAddress + perIoLength * count, (ushort)(size % perIoLength));
  409. if (aobuffer != null)
  410. Array.Copy(aobuffer, 0, buff, size - size % perIoLength, aobuffer.Length);
  411. }
  412. }
  413. return buff;
  414. }
  415. protected override void WriteDo(int offset, bool[] data)
  416. {
  417. bool[] databuffer = new bool[perIoLength];
  418. int count = data.Length / perIoLength;
  419. if (count < 1)
  420. {
  421. Array.Copy(data, 0, databuffer, 0, data.Length);
  422. Array.Resize(ref databuffer, data.Length);
  423. DoWriteDo(offset, databuffer);
  424. }
  425. else
  426. {
  427. for (int i = 0; i < count; i++)
  428. {
  429. Array.Copy(data, i * perIoLength, databuffer, 0, databuffer.Length);
  430. DoWriteDo(offset + perIoLength * i, databuffer);
  431. }
  432. if (data.Length % perIoLength != 0)
  433. {
  434. Array.Copy(data, perIoLength * count, databuffer, 0, data.Length % perIoLength);
  435. Array.Resize(ref databuffer, data.Length % perIoLength);
  436. DoWriteDo(offset + perIoLength * count, databuffer);
  437. }
  438. }
  439. }
  440. protected override void WriteAo(int offset, short[] data)
  441. {
  442. short[] databuffer = new short[perIoLength];
  443. int count = data.Length / perIoLength;
  444. if (count < 1)
  445. {
  446. Array.Copy(data, 0, databuffer, 0, data.Length);
  447. Array.Resize(ref databuffer, data.Length);
  448. DoWriteAo(offset, databuffer);
  449. }
  450. else
  451. {
  452. for (int i = 0; i < count; i++)
  453. {
  454. Array.Copy(data, i * perIoLength, databuffer, 0, databuffer.Length);
  455. DoWriteAo(offset + perIoLength * i, databuffer, data.Length, i);
  456. }
  457. if(data.Length % perIoLength != 0)
  458. {
  459. Array.Copy(data, perIoLength * count, databuffer, 0, data.Length % perIoLength);
  460. Array.Resize(ref databuffer, data.Length % perIoLength);
  461. DoWriteAo(offset + perIoLength * count, databuffer, data.Length);
  462. }
  463. }
  464. }
  465. public void RecipeData(int offset, short[] data)
  466. {
  467. recipeOffset = offset;
  468. recipeData = data;
  469. isWriteRecipe = true;
  470. }
  471. public void WriteRecipe(int offset, short[] data)
  472. {
  473. short[] databuffer = new short[perIoLength];
  474. int count = data.Length / perIoLength;
  475. if (count < 1)
  476. {
  477. Array.Copy(data, 0, databuffer, 0, data.Length);
  478. Array.Resize(ref databuffer, data.Length);
  479. DoWriteAo(offset, databuffer);
  480. }
  481. else
  482. {
  483. for (int i = 0; i < count; i++)
  484. {
  485. Array.Copy(data, i * perIoLength, databuffer, 0, databuffer.Length);
  486. DoWriteAo(offset + perIoLength * i, databuffer, data.Length, i);
  487. }
  488. if (data.Length % perIoLength != 0)
  489. {
  490. Array.Copy(data, perIoLength * count, databuffer, 0, data.Length % perIoLength);
  491. Array.Resize(ref databuffer, data.Length % perIoLength);
  492. DoWriteAo(offset + perIoLength * count, databuffer, data.Length);
  493. }
  494. }
  495. }
  496. private short[] DoReadAi(int offset, int size)
  497. {
  498. OperateResult<short[]> result = melsec_net.ReadInt16($"{aiStoragename}{offset}",(ushort)size);
  499. if (!result.IsSuccess)
  500. {
  501. LOG.Error(result.Message);
  502. SetState(IoProviderStateEnum.Error);
  503. return null;
  504. }
  505. return result.Content;
  506. }
  507. private short[] DoReadAo(int offset, ushort size)
  508. {
  509. OperateResult<short[]> result = melsec_net.ReadInt16($"{aoStoragename}{offset}", size);
  510. if (!result.IsSuccess)
  511. {
  512. LOG.Error(result.Message);
  513. SetState(IoProviderStateEnum.Error);
  514. return null;
  515. }
  516. return result.Content;
  517. }
  518. private bool DoWriteAo(int offset, short[] data, int total = 0, int count = 100)
  519. {
  520. OperateResult result = melsec_net.Write($"{aoStoragename}{offset}", data);
  521. if (!result.IsSuccess)
  522. {
  523. LOG.Error(result.Message);
  524. SetState(IoProviderStateEnum.Error);
  525. }
  526. return result.IsSuccess;
  527. }
  528. private bool[] DoReadDi(int offset, ushort size)
  529. {
  530. OperateResult<bool[]> result = melsec_net.ReadBool($"{diStoragename}{offset.ToString("X")}", size);
  531. if (!result.IsSuccess)
  532. {
  533. LOG.Error(result.Message);
  534. SetState(IoProviderStateEnum.Error);
  535. return null;
  536. }
  537. return result.Content;
  538. }
  539. private bool[] DoReadDo(int offset, ushort size)
  540. {
  541. OperateResult<bool[]> result = melsec_net.ReadBool($"{doStoragename}{offset.ToString("X")}", size);
  542. if (!result.IsSuccess)
  543. {
  544. LOG.Error(result.Message);
  545. SetState(IoProviderStateEnum.Error);
  546. return null;
  547. }
  548. return result.Content;
  549. }
  550. private bool DoWriteDo(int offset, bool[] data)
  551. {
  552. OperateResult result = melsec_net.Write($"{doStoragename}{offset.ToString("X")}", data);
  553. if (!result.IsSuccess)
  554. {
  555. LOG.Error(result.Message);
  556. SetState(IoProviderStateEnum.Error);
  557. }
  558. return result.IsSuccess;
  559. }
  560. public override bool SetValue(AOAccessor aoItem, short value)
  561. {
  562. if (State != IoProviderStateEnum.Opened)
  563. return false;
  564. //WriteAo(aoStartAddress + aoItem.Index, new short[] { value });
  565. return true;
  566. }
  567. public override bool SetValueFloat(AOAccessor aoItem, float value)
  568. {
  569. if (State != IoProviderStateEnum.Opened)
  570. return false;
  571. return true;
  572. }
  573. public override bool SetValue(DOAccessor doItem, bool value)
  574. {
  575. //if (State != IoProviderStateEnum.Opened)
  576. // return false;
  577. //if (!IO.CanSetDO(doItem.Name, value, out string reason))
  578. //{
  579. // LOG.Error(reason);
  580. // return false;
  581. //}
  582. ////foreach (var bufferSection in _blockSections)
  583. ////{
  584. //// if (bufferSection.Type == IoType.DO)
  585. //// {
  586. //// bool[] doBuffer = ReadDo(bufferSection.Offset, bufferSection.Size);
  587. //// if (doBuffer != null)
  588. //// {
  589. //// _buffer.SetDoBuffer(_source, bufferSection.Offset, doBuffer);
  590. //// }
  591. //// }
  592. ////}
  593. //Dictionary<int, bool[]> dos = _buffer.GetDoBuffer(_source);
  594. //if (dos != null)
  595. //{
  596. // foreach (var doo in dos)
  597. // {
  598. // //doo.Value[doItem.Index] = value;
  599. // //WriteDo(doStartAddress, doo.Value);
  600. // WriteDo(doStartAddress + doItem.Index, new bool[] { value });
  601. // }
  602. //}
  603. return true;
  604. }
  605. }
  606. }