songnan.zhang 3 years ago
parent
commit
d93efc31dd
  1. 2
      ServicesCenter/WCF/OpcServerHost/App.config
  2. 37
      ServicesCenter/WCF/OpcServerHost/OpcDeal/ParaInit.cs

2
ServicesCenter/WCF/OpcServerHost/App.config

@ -3,7 +3,7 @@
<appSettings>
<add key="ServerAddressIP" value="net.tcp://127.0.0.1:4444/OpcService"/>
<!--<add key="OPCServerIP" value="10.111.226.150" />-->
<add key="OPCServerIP" value="127.0.0.1" />
<add key="OPCServerIP" value="10.111.144.99" />
<add key="OPCServerName" value="Kepware.KEPServerEX.V6" />
<!--<add key="OPCServerName" value="kepware.KEPServerEX.V5" />-->
<add key="PRODUCELINE" value="CFAACD" />

37
ServicesCenter/WCF/OpcServerHost/OpcDeal/ParaInit.cs

@ -689,13 +689,10 @@ namespace OpcServerHost.Init
#endregion
#region 捕获条码扫描完成标记
if (currentPC.COLUMNCODE == "PLC_Scan_Ok_t")
{
if (currentPC.COLUMNTYPE == OpcEnumGeter.COLUMNTYPE.EQUIPSCANFLAG.GetHashCode().ToString())
{
#region 提示扫描条码完成
if (itemValue == null)
@ -743,21 +740,24 @@ namespace OpcServerHost.Init
{
string item = parameter.MACHINECODDE + ":" + parameter.MOLDNUMBER + ":" + parameter.COLUMNCODE;
var result = opcplcConnection.ReadtagValue(opcItemDict[item]);
//var result = (object)"[0.25.68.48.52.67.82.69.87.85.70.76.50.49.49.50.49.53.48.48.49.83.68.48.48.48.49]";
if (result != null)
var result = opcplcConnection.ReadtagValue(opcItemDict[item]);
if (result != null)
{
ASCIIEncoding asciiEncoding = new ASCIIEncoding();
var product_str = result.ToString().Replace("[","").Replace("]", "").Split('.');
var count = Convert.ToInt32(product_str[1]) - 1;
var productCode = "";
for (int c = 0; c <= count; c++)
{
byte[] byteArray = new byte[] { Convert.ToByte(product_str[c + 2]) };
productCode += asciiEncoding.GetString(byteArray);
}
parameter.PARAVALUE = productCode;
ASCIIEncoding asciiEncoding = new ASCIIEncoding();
var arraysList = (Array[])result;
var count = Convert.ToInt32(arraysList[1]) - 1;
//var count = 24;
var productCode = "";
for (int c = 0; c <= count; c++)
{
byte[] byteArray = new byte[] { Convert.ToByte(arraysList[c + 2]) };
productCode += asciiEncoding.GetString(byteArray);
}
parameter.PARAVALUE = productCode;
}
Console.WriteLine(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "Get Barcode " + " " + parameter.MACHINECODDE + ":" + parameter.MOLDNUMBER + ":" + parameter.COLUMNCODE + " " + ((result == null) ? " " : result.ToString()), currentPC.MACHINECODDE);
@ -813,7 +813,6 @@ namespace OpcServerHost.Init
#endregion
}
}
#endregion
#region 中断

Loading…
Cancel
Save