Browse Source

数据获取修改

master
pry 2 years ago
parent
commit
cf391d2019
2 changed files with 9 additions and 4 deletions
  1. +8
    -3
      BPASmartClient.S7Net/EntityClassResolution.cs
  2. +1
    -1
      DosingSystem/Service/SiemensDevice.cs

+ 8
- 3
BPASmartClient.S7Net/EntityClassResolution.cs View File

@@ -55,8 +55,8 @@ namespace BPASmartClient.S7Net
numBytes += len;
break;
default:
if (type.IsClass) numBytes += 2.0;
numBytes = GetClassSize(Activator.CreateInstance(type), numBytes, isInnerProperty: true);
if (type.IsClass) IncrementToEven(ref numBytes);
break;
}

@@ -219,7 +219,12 @@ namespace BPASmartClient.S7Net
break;
default:
{
if (propertyType.IsClass) numBytes += 2;
//if (propertyType.IsClass) numBytes += 2;
numBytes = Math.Ceiling(numBytes);
if (numBytes / 2.0 - Math.Floor(numBytes / 2.0) > 0.0)
{
numBytes += 1.0;
}
object obj2 = Activator.CreateInstance(propertyType);
numBytes = FromBytes(obj2, bytes, numBytes);
obj = obj2;
@@ -337,8 +342,8 @@ namespace BPASmartClient.S7Net
}
break;
default:
if (propertyValue.GetType().IsClass) numBytes += 2;
numBytes = ToBytes(propertyValue, bytes, numBytes);
//if (propertyValue.GetType().IsClass) IncrementToEven(ref numBytes);
break;
}



+ 1
- 1
DosingSystem/Service/SiemensDevice.cs View File

@@ -22,7 +22,7 @@ namespace BPASmartClient.DosingSystem

public void Connect(string ip)
{
//GlobalDevice.PlcData = MySiemens.ReadClass<PlcToComputer>(3);//获取PLC到上位机的数据
GlobalDevice.PlcData = MySiemens.ReadClass<PlcToComputer>(3);//获取PLC到上位机的数据
while (!MySiemens.IsConnected)
{
MySiemens.Connect(S7.Net.CpuType.S71200, ip);


Loading…
Cancel
Save