Commit 5c9b274e 顾剑亮

WriteDO直接发送

1 个父辈 1040b75b
此文件类型无法预览
...@@ -34,7 +34,7 @@ namespace Asa.IOModule ...@@ -34,7 +34,7 @@ namespace Asa.IOModule
private int[] _valueAI; //AI模拟量 private int[] _valueAI; //AI模拟量
private int[] _valueAO; //AO模拟量 private int[] _valueAO; //AO模拟量
private List<byte> _receive; private List<byte> _receive;
private System.Collections.Concurrent.ConcurrentQueue<byte[]> _writeDO; //private System.Collections.Concurrent.ConcurrentQueue<byte[]> _writeDO;
private log4net.ILog log; private log4net.ILog log;
private readonly Box_Type _typeInput; //输入类型 private readonly Box_Type _typeInput; //输入类型
...@@ -123,7 +123,7 @@ namespace Asa.IOModule ...@@ -123,7 +123,7 @@ namespace Asa.IOModule
_uid = 0; _uid = 0;
IsConn = false; IsConn = false;
_receive = new List<byte>(); _receive = new List<byte>();
_writeDO = new System.Collections.Concurrent.ConcurrentQueue<byte[]>(); //_writeDO = new System.Collections.Concurrent.ConcurrentQueue<byte[]>();
//test //test
...@@ -300,7 +300,12 @@ namespace Asa.IOModule ...@@ -300,7 +300,12 @@ namespace Asa.IOModule
buff[7] = 5; //功能码 buff[7] = 5; //功能码
buff[9] = _addressOutput[add]; //地址 buff[9] = _addressOutput[add]; //地址
buff[10] = (byte)sta; //写入值 buff[10] = (byte)sta; //写入值
_writeDO.Enqueue(buff);
//_writeDO.Enqueue(buff);
//return true;
_client.Send(buff);
log.Debug("Send: " + HexBuff(buff));
return true; return true;
} }
catch (Exception ex) catch (Exception ex)
...@@ -339,14 +344,17 @@ namespace Asa.IOModule ...@@ -339,14 +344,17 @@ namespace Asa.IOModule
} }
else else
{ {
if (_writeDO.TryDequeue(out buff)) //2020年5月25日
{ time += SEND_SLEEP;
continue;
} // if (_writeDO.TryDequeue(out buff))
else // {
{ // }
continue; //else
} // {
// continue;
// }
//2020年5月23日 //2020年5月23日
// if (writeTimer >= 3) //连续发送WriteDO3次,强制发送DO // if (writeTimer >= 3) //连续发送WriteDO3次,强制发送DO
...@@ -367,17 +375,20 @@ namespace Asa.IOModule ...@@ -367,17 +375,20 @@ namespace Asa.IOModule
// } // }
// } // }
} }
time += SEND_SLEEP;
} }
else else
{ {
if (_writeDO.TryDequeue(out buff)) //2020年5月25日
{ buff = GetReadDI_Command();
} //if (_writeDO.TryDequeue(out buff))
else //{
{ //}
buff = GetReadDI_Command(); //else
} //{
// buff = GetReadDI_Command();
//}
//2020年5月23日 //2020年5月23日
//if (writeTimer >= 3) //连续发送WriteDO3次,强制发送DI和DO //if (writeTimer >= 3) //连续发送WriteDO3次,强制发送DI和DO
...@@ -415,7 +426,6 @@ namespace Asa.IOModule ...@@ -415,7 +426,6 @@ namespace Asa.IOModule
try try
{ {
//test
_client.Send(buff); _client.Send(buff);
log.Debug("Send: " + HexBuff(buff)); log.Debug("Send: " + HexBuff(buff));
} }
......
...@@ -6,3 +6,4 @@ D:\OneDrive - 上海挚锦科技有限公司\SMD\AIOBOX\AIOBOX\obj\Debug\Asa.IOM ...@@ -6,3 +6,4 @@ D:\OneDrive - 上海挚锦科技有限公司\SMD\AIOBOX\AIOBOX\obj\Debug\Asa.IOM
D:\OneDrive - 上海挚锦科技有限公司\SMD\AIOBOX\AIOBOX\obj\Debug\Asa.IOModule.AIOBOX.pdb D:\OneDrive - 上海挚锦科技有限公司\SMD\AIOBOX\AIOBOX\obj\Debug\Asa.IOModule.AIOBOX.pdb
D:\OneDrive - 上海挚锦科技有限公司\SMD\AIOBOX\AIOBOX\bin\Debug\log4net.dll D:\OneDrive - 上海挚锦科技有限公司\SMD\AIOBOX\AIOBOX\bin\Debug\log4net.dll
D:\OneDrive - 上海挚锦科技有限公司\SMD\AIOBOX\AIOBOX\obj\Debug\AIOBOX.csproj.CopyComplete D:\OneDrive - 上海挚锦科技有限公司\SMD\AIOBOX\AIOBOX\obj\Debug\AIOBOX.csproj.CopyComplete
D:\OneDrive - 上海挚锦科技有限公司\SMD\AIOBOX\AIOBOX\obj\Debug\AIOBOX.csprojAssemblyReference.cache
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!