添加新控制点
This commit is contained in:
@@ -174,8 +174,8 @@ namespace CleanMachineHMI
|
||||
RefreshPlcItem_Y(ref haschange);
|
||||
|
||||
stopWatch.Stop();
|
||||
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
LogHelper.WriteLog($"读取PLC时间:{ts.Milliseconds}", LogTypeEum.Run);
|
||||
if (haschange)
|
||||
{
|
||||
@@ -189,7 +189,7 @@ namespace CleanMachineHMI
|
||||
// thEvent.Set();
|
||||
// ShowWarningMsg();
|
||||
int sleeptime = 100 - ts.Milliseconds;
|
||||
if (sleeptime<0)
|
||||
if (sleeptime < 0)
|
||||
{
|
||||
sleeptime = 0;
|
||||
}
|
||||
@@ -407,14 +407,16 @@ namespace CleanMachineHMI
|
||||
////高位 short 的字节数组。
|
||||
//byte[] tmpByt_2 = BitConverter.GetBytes(readBytArr_D[plcItemDeviationAddress + 1]);
|
||||
////组合为int32的字节数组。
|
||||
//byte[] tmpByt_3 = new byte[] { tmpByt_1[0], tmpByt_1[1], tmpByt_2[0], tmpByt_2[1] };
|
||||
// byte[] tmpByt_3 = new byte[] { tmpByt_1[0], tmpByt_1[1], tmpByt_2[0], tmpByt_2[1] };
|
||||
|
||||
|
||||
////readBytArr_D[plcItemDeviationAddress + 1] << 16 +
|
||||
//item.PlcItemValue = BitConverter.ToUInt32(tmpByt_3, 0).ToString();
|
||||
//value = BitConverter.ToInt32(tmpByt_3, 0).ToString();
|
||||
#endregion
|
||||
|
||||
#region 方法二 :Short数组转换为int数据 20201014 孙亚龙
|
||||
//相较而言 使用位移的算法效率更高一些。
|
||||
value = ((readBytArr_D[plcItemDeviationAddress + 1] << 16) + readBytArr_D[plcItemDeviationAddress]).ToString();
|
||||
value = ((readBytArr_D[plcItemDeviationAddress + 1] << 16) + readBytArr_D[plcItemDeviationAddress]).ToString();
|
||||
|
||||
|
||||
#endregion
|
||||
@@ -952,7 +954,16 @@ namespace CleanMachineHMI
|
||||
}
|
||||
else
|
||||
{
|
||||
return short.Parse(item.PlcItemValue);
|
||||
if (item.PlcItemDataLength == 2)
|
||||
{
|
||||
return int.Parse(item.PlcItemValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
return short.Parse(item.PlcItemValue);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1010,7 +1021,15 @@ namespace CleanMachineHMI
|
||||
}
|
||||
else
|
||||
{
|
||||
retObj = short.Parse(item_D.PlcItemValue);
|
||||
if (item_D.PlcItemDataLength == 2)
|
||||
{
|
||||
retObj = int.Parse(item_D.PlcItemValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
retObj = short.Parse(item_D.PlcItemValue);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
case PlcItemTypeDesc.X:
|
||||
|
||||
Reference in New Issue
Block a user