Commit 6ab7294e authored by wangjunqiang's avatar wangjunqiang

修复组分越界的bug

parent 2ad631d4
...@@ -89,224 +89,480 @@ namespace GcDevicePc.Common ...@@ -89,224 +89,480 @@ namespace GcDevicePc.Common
fnLibModbusSlaveHoldingRegister(hModbusHandle, MySlaveReadHoldingRegister, MySlaveWriteHoldingRegister, startaddr, nreg); fnLibModbusSlaveHoldingRegister(hModbusHandle, MySlaveReadHoldingRegister, MySlaveWriteHoldingRegister, startaddr, nreg);
} }
static ushort slavereadhreg(ushort address) static ushort slavereadhreg(ushort address)
{ {
ushort value = 0; ushort value = 0;
ushort signalddress = 17; ushort signalddress = 17;
ushort baseaddress = 23; ushort baseaddress = 23;
address = (ushort) (address - 1); address = (ushort)(address - 1);
int listnum = SharedSpace.Data.listValue.Count; int listnum = SharedSpace.Data.listValue.Count;
if (address >= 17) if (address >= 17)
{ {
ushort[] s = new ushort[2]; ushort[] s = new ushort[2];
float[] f = new float[2]; float[] f = new float[2];
if (address >= 17 && address <= 22) if (address >= 17 && address <= 22)
{ {
if (address == 17 || address == 18) if (address == 17 || address == 18)
f[0] = float.Parse(globaldata.m_dpbuffer.ShowList.showDet.fDetValue.ToString("0.000")); f[0] = float.Parse(globaldata.m_dpbuffer.ShowList.showDet.fDetValue.ToString("0.000"));
if (address == 19 || address == 20) if (address == 19 || address == 20)
f[0] = float.Parse(globaldata.m_dpbuffer.ShowList.showDet.iDetValue.ToString("0.000")); f[0] = float.Parse(globaldata.m_dpbuffer.ShowList.showDet.iDetValue.ToString("0.000"));
if (address == 21 || address == 22) if (address == 21 || address == 22)
f[0] = float.Parse(globaldata.m_dpbuffer.ShowList.showDet.bDetValue.ToString("0.000")); f[0] = float.Parse(globaldata.m_dpbuffer.ShowList.showDet.bDetValue.ToString("0.000"));
Buffer.BlockCopy(f, 2, s, 0, 2); Buffer.BlockCopy(f, 2, s, 0, 2);
Buffer.BlockCopy(f, 0, s, 2, 2); Buffer.BlockCopy(f, 0, s, 2, 2);
value = s[(address - signalddress) % 2]; value = s[(address - signalddress) % 2];
} }
else if (address >= 23 && listnum > 0) else if ( address >= 23 && listnum > 0)
{ {
int readnum = (address - baseaddress) / 2; int readnum = (address - baseaddress) / 2;
f[0] = float.Parse(SharedSpace.Data.listValue[readnum].vale.ToString()); if (readnum <= listnum - 1)
Buffer.BlockCopy(f, 2, s, 0, 2); {
Buffer.BlockCopy(f, 0, s, 2, 2); f[0] = float.Parse(SharedSpace.Data.listValue[readnum].vale.ToString());
value = s[(address - baseaddress) % 2]; Buffer.BlockCopy(f, 2, s, 0, 2);
} Buffer.BlockCopy(f, 0, s, 2, 2);
else value = s[(address - baseaddress) % 2];
{ }
value = 0; else
} {
} value = 0;
}
if (address >= 2 && address < 20)
{ }
switch (address) else
{ {
case 2: value = 0;
{ }
value = (ushort) SharedSpace.Data.typesint; }
}
break; if (address >= 2 && address < 20)
case 3: {
{ switch (address)
value = SharedSpace.Data.change == true ? (ushort) 1 : (ushort) 0; {
} case 2:
break; {
case 4: value = (ushort)SharedSpace.Data.typesint;
{ }
value = globaldata.m_hmibuffer.gcinfo.HMIMac[0]; break;
} case 3:
break; {
case 5: value = SharedSpace.Data.change == true ? (ushort)1 : (ushort)0;
{ }
value = globaldata.m_hmibuffer.gcinfo.HMIMac[1]; break;
} case 4:
break; {
case 6: value = globaldata.m_hmibuffer.gcinfo.HMIMac[0];
{ }
value = globaldata.m_hmibuffer.gcinfo.HMIMac[2]; break;
} case 5:
break; {
case 7: //设备联机状态 value = globaldata.m_hmibuffer.gcinfo.HMIMac[1];
{ }
value = (ushort) (globaldata.m_hmibuffer.gcinfo.hmioffline ? 1 : 0); break;
} case 6:
break; {
case 8: //HMI状态 value = globaldata.m_hmibuffer.gcinfo.HMIMac[2];
{ }
value = globaldata.m_hmibuffer.gcinfo.methodstatus; break;
} case 7: //设备联机状态
break; {
case 9: //前进样口 value = (ushort)(globaldata.m_hmibuffer.gcinfo.hmioffline ? 1 : 0);
{ }
if (CProfileDevice.m_DevParam.syspara.u16InjPortFront == 1) break;
{ case 8: //HMI状态
value = (ushort) (globaldata.m_dpbuffer.ShowList.showtemp.FPActualTemp * 10); {
} value = globaldata.m_hmibuffer.gcinfo.methodstatus;
else }
{ break;
value = 0; case 9: //前进样口
} {
} if (CProfileDevice.m_DevParam.syspara.u16InjPortFront == 1)
break; {
case 10: //后进样口 value = (ushort)(globaldata.m_dpbuffer.ShowList.showtemp.FPActualTemp * 10);
{ }
if (CProfileDevice.m_DevParam.syspara.u16InjPortBehind == 1) else
{ {
value = (ushort) (globaldata.m_dpbuffer.ShowList.showtemp.BPActualTemp * 10); value = 0;
} }
else }
{ break;
value = 0; case 10: //后进样口
} {
} if (CProfileDevice.m_DevParam.syspara.u16InjPortBehind == 1)
break; {
case 11: // 柱箱 value = (ushort)(globaldata.m_dpbuffer.ShowList.showtemp.BPActualTemp * 10);
{ }
if (CProfileDevice.m_DevParam.syspara.u16Col == 1) else
{ {
value = (ushort) (globaldata.m_dpbuffer.ShowList.showtemp.ColActualTemp * 10); value = 0;
} }
else }
{ break;
value = 0; case 11: // 柱箱
} {
} if (CProfileDevice.m_DevParam.syspara.u16Col == 1)
break; {
case 12: //前检测器 value = (ushort)(globaldata.m_dpbuffer.ShowList.showtemp.ColActualTemp * 10);
{ }
if (CProfileDevice.m_DevParam.syspara.u16InjPortFront == 1) else
{ {
if (CProfileDevice.m_DevParam.syspara.u16DetFrontType == 0) value = 0;
{ }
value = (ushort) (globaldata.m_dpbuffer.ShowList.showtemp.fDetActualTemp * 10); }
} break;
else if (CProfileDevice.m_DevParam.syspara.u16DetFrontType == 1) case 12: //前检测器
{ {
value = (ushort) (globaldata.m_dpbuffer.ShowList.showtemp.fDetActualTemp * 10); if (CProfileDevice.m_DevParam.syspara.u16InjPortFront == 1)
} {
else if (CProfileDevice.m_DevParam.syspara.u16DetFrontType == 0)
{ {
value = 0; value = (ushort)(globaldata.m_dpbuffer.ShowList.showtemp.fDetActualTemp * 10);
} }
} else if (CProfileDevice.m_DevParam.syspara.u16DetFrontType == 1)
else {
{ value = (ushort)(globaldata.m_dpbuffer.ShowList.showtemp.fDetActualTemp * 10);
value = 0; }
} else
} {
break; value = 0;
case 13: //中检测器 }
{ }
if (CProfileDevice.m_DevParam.syspara.u16DetInter == 1) else
{ {
if (CProfileDevice.m_DevParam.syspara.u16DetInterType == 0) value = 0;
{ }
value = (ushort) (globaldata.m_dpbuffer.ShowList.showtemp.iDetActualTemp * 10); }
} break;
else if (CProfileDevice.m_DevParam.syspara.u16DetInterType == 1) case 13: //中检测器
{ {
value = (ushort) (globaldata.m_dpbuffer.ShowList.showtemp.iDetActualTemp * 10); if (CProfileDevice.m_DevParam.syspara.u16DetInter == 1)
} {
else if (CProfileDevice.m_DevParam.syspara.u16DetInterType == 0)
{ {
value = 0; value = (ushort)(globaldata.m_dpbuffer.ShowList.showtemp.iDetActualTemp * 10);
} }
} else if (CProfileDevice.m_DevParam.syspara.u16DetInterType == 1)
else if (CProfileDevice.m_DevParam.syspara.u16AuxHeater1 == 1) {
{ value = (ushort)(globaldata.m_dpbuffer.ShowList.showtemp.iDetActualTemp * 10);
value = (ushort) (globaldata.m_dpbuffer.ShowList.showtemp.AuxActualTemp1 * 10); }
} else
else {
{ value = 0;
value = 0; }
} }
} else if (CProfileDevice.m_DevParam.syspara.u16AuxHeater1 == 1)
break; {
case 14: //后检测器 value = (ushort)(globaldata.m_dpbuffer.ShowList.showtemp.AuxActualTemp1 * 10);
{ }
if (CProfileDevice.m_DevParam.syspara.u16DetBehind == 1) else
{ {
if (CProfileDevice.m_DevParam.syspara.u16DetBehindType == 0) value = 0;
{ }
value = (ushort) (globaldata.m_dpbuffer.ShowList.showtemp.bDetActualTemp * 10); }
} break;
else if (CProfileDevice.m_DevParam.syspara.u16DetBehindType == 1) case 14: //后检测器
{ {
value = (ushort) (globaldata.m_dpbuffer.ShowList.showtemp.bDetActualTemp * 10); if (CProfileDevice.m_DevParam.syspara.u16DetBehind == 1)
} {
else if (CProfileDevice.m_DevParam.syspara.u16AuxHeater2 == 1) if (CProfileDevice.m_DevParam.syspara.u16DetBehindType == 0)
{ {
value = (ushort) (globaldata.m_dpbuffer.ShowList.showtemp.AuxActualTemp2 * 10); value = (ushort)(globaldata.m_dpbuffer.ShowList.showtemp.bDetActualTemp * 10);
} }
else else if (CProfileDevice.m_DevParam.syspara.u16DetBehindType == 1)
{ {
value = 0; value = (ushort)(globaldata.m_dpbuffer.ShowList.showtemp.bDetActualTemp * 10);
} }
} else if (CProfileDevice.m_DevParam.syspara.u16AuxHeater2 == 1)
else {
{ value = (ushort)(globaldata.m_dpbuffer.ShowList.showtemp.AuxActualTemp2 * 10);
value = 0; }
} else
} {
break; value = 0;
case 15: //前点火信号 }
{ }
if (CProfileDevice.m_DevParam.syspara.u16DetFrontType == 1) else
{ {
value = globaldata.m_dpbuffer.ShowList.showDet.fDetStatue; value = 0;
} }
else }
{ break;
value = 0; case 15: //前点火信号
} {
} if (CProfileDevice.m_DevParam.syspara.u16DetFrontType == 1)
break; {
case 16: //后点火信号 value = globaldata.m_dpbuffer.ShowList.showDet.fDetStatue;
{ }
if (CProfileDevice.m_DevParam.syspara.u16DetInterType == 1) else
{ {
value = globaldata.m_dpbuffer.ShowList.showDet.fDetStatue; value = 0;
} }
else }
{ break;
value = 0; case 16: //后点火信号
} {
} if (CProfileDevice.m_DevParam.syspara.u16DetInterType == 1)
break; {
} value = globaldata.m_dpbuffer.ShowList.showDet.fDetStatue;
} }
else
return value; {
} value = 0;
}
}
break;
}
}
return value;
}
//static ushort slavereadhreg(ushort address)
//{
// ushort value = 0;
// ushort baseaddress = 20;
// address = (ushort)(address - 1);
// int listnum = SharedSpace.Data.listValue.Count;
// int readnum = (address - baseaddress) / 2;
// if (readnum <= listnum - 1 && listnum > 0 && address >= 20)
// {
// // lock(CKVocAnalyzer.GlobalCKV.valueparamlist){
// try
// {
// ushort[] s = new ushort[2];
// float[] f = new float[2];
// {
// f[0] = float.Parse(SharedSpace.Data.listValue[readnum].vale.ToString());
// Buffer.BlockCopy(f, 2, s, 0, 2);
// Buffer.BlockCopy(f, 0, s, 2, 2);
// }
// value = s[(address - baseaddress) % 2];
// }
// catch
// {
// }
// //}
// }
// if (address >= 2 && address < 20)
// {
// switch (address)
// {
// case 2:
// {
// value = (ushort)SharedSpace.Data.typesint;
// }
// break;
// case 3:
// {
// value = SharedSpace.Data.change == true ? (ushort)1 : (ushort)0;
// }
// break;
// case 4:
// {
// value = globaldata.m_hmibuffer.gcinfo.HMIMac[0];
// }
// break;
// case 5:
// {
// value = globaldata.m_hmibuffer.gcinfo.HMIMac[1];
// }
// break;
// case 6:
// {
// value = globaldata.m_hmibuffer.gcinfo.HMIMac[2];
// }
// break;
// case 7: //设备联机状态
// {
// value = (ushort)(globaldata.m_hmibuffer.gcinfo.hmioffline ? 1 : 0);
// }
// break;
// case 8: //HMI状态
// {
// value = globaldata.m_hmibuffer.gcinfo.methodstatus;
// }
// break;
// case 9: //前进样口
// {
// if (CProfileDevice.m_DevParam.syspara.u16InjPortFront == 1)
// {
// value = (ushort)(globaldata.m_dpbuffer.ShowList.showtemp.FPActualTemp * 10);
// }
// else
// {
// value = 0;
// }
// }
// break;
// case 10: //后进样口
// {
// if (CProfileDevice.m_DevParam.syspara.u16InjPortBehind == 1)
// {
// value = (ushort)(globaldata.m_dpbuffer.ShowList.showtemp.BPActualTemp * 10);
// }
// else
// {
// value = 0;
// }
// }
// break;
// case 11: // 柱箱
// {
// if (CProfileDevice.m_DevParam.syspara.u16Col == 1)
// {
// value = (ushort)(globaldata.m_dpbuffer.ShowList.showtemp.ColActualTemp * 10);
// }
// else
// {
// value = 0;
// }
// }
// break;
// case 12: //前检测器
// {
// if (CProfileDevice.m_DevParam.syspara.u16InjPortFront == 1)
// {
// if (CProfileDevice.m_DevParam.syspara.u16DetFrontType == 0)
// {
// value = (ushort)(globaldata.m_dpbuffer.ShowList.showtemp.fDetActualTemp * 10);
// }
// else if (CProfileDevice.m_DevParam.syspara.u16DetFrontType == 1)
// {
// value = (ushort)(globaldata.m_dpbuffer.ShowList.showtemp.fDetActualTemp * 10);
// }
// else
// {
// value = 0;
// }
// }
// else
// {
// value = 0;
// }
// }
// break;
// case 13: //中检测器
// {
// if (CProfileDevice.m_DevParam.syspara.u16DetInter == 1)
// {
// if (CProfileDevice.m_DevParam.syspara.u16DetInterType == 0)
// {
// value = (ushort)(globaldata.m_dpbuffer.ShowList.showtemp.iDetActualTemp * 10);
// }
// else if (CProfileDevice.m_DevParam.syspara.u16DetInterType == 1)
// {
// value = (ushort)(globaldata.m_dpbuffer.ShowList.showtemp.iDetActualTemp * 10);
// }
// else
// {
// value = 0;
// }
// }
// else if (CProfileDevice.m_DevParam.syspara.u16AuxHeater1 == 1)
// {
// value = (ushort)(globaldata.m_dpbuffer.ShowList.showtemp.AuxActualTemp1 * 10);
// }
// else
// {
// value = 0;
// }
// }
// break;
// case 14: //后检测器
// {
// if (CProfileDevice.m_DevParam.syspara.u16DetBehind == 1)
// {
// if (CProfileDevice.m_DevParam.syspara.u16DetBehindType == 0)
// {
// value = (ushort)(globaldata.m_dpbuffer.ShowList.showtemp.bDetActualTemp * 10);
// }
// else if (CProfileDevice.m_DevParam.syspara.u16DetBehindType == 1)
// {
// value = (ushort)(globaldata.m_dpbuffer.ShowList.showtemp.bDetActualTemp * 10);
// }
// else if (CProfileDevice.m_DevParam.syspara.u16AuxHeater2 == 1)
// {
// value = (ushort)(globaldata.m_dpbuffer.ShowList.showtemp.AuxActualTemp2 * 10);
// }
// else
// {
// value = 0;
// }
// }
// else
// {
// value = 0;
// }
// }
// break;
// case 15: //前点火信号
// {
// if (CProfileDevice.m_DevParam.syspara.u16DetFrontType == 1)
// {
// value = globaldata.m_dpbuffer.ShowList.showDet.fDetStatue;
// }
// else
// {
// value = 0;
// }
// }
// break;
// case 16: //后点火信号
// {
// if (CProfileDevice.m_DevParam.syspara.u16DetInterType == 1)
// {
// value = globaldata.m_dpbuffer.ShowList.showDet.fDetStatue;
// }
// else
// {
// value = 0;
// }
// }
// break;
// case 17: //前检测器值
// {
// if (CProfileDevice.m_DevParam.syspara.u16DetFront == 1)
// {
// value = (ushort)(globaldata.m_dpbuffer.ShowList.showDet.fDetValue * 1000);
// }
// else
// {
// value = 0;
// }
// }
// break;
// case 18: //中检测器值
// {
// if (CProfileDevice.m_DevParam.syspara.u16DetInter == 1)
// {
// value = (ushort)(globaldata.m_dpbuffer.ShowList.showDet.iDetValue * 1000);
// }
// else
// {
// value = 0;
// }
// }
// break;
// case 19: //后检测器值
// {
// if (CProfileDevice.m_DevParam.syspara.u16DetBehind == 1)
// {
// value = (ushort)(globaldata.m_dpbuffer.ShowList.showDet.bDetValue * 1000);
// }
// else
// {
// value = 0;
// }
// }
// break;
// }
// }
// return value;
//}
static void slavewirtehreg(ushort address, ushort value) static void slavewirtehreg(ushort address, ushort value)
{ {
......
...@@ -110,7 +110,7 @@ namespace GcDevicePc ...@@ -110,7 +110,7 @@ namespace GcDevicePc
tempshow.Text = "运行时间/总时间"; tempshow.Text = "运行时间/总时间";
if (globaldata.MethodRun_Statue == 4 || globaldata.MethodRun_Statue == 5) if (globaldata.MethodRun_Statue == 4 || globaldata.MethodRun_Statue == 5)
// tempshow.SubItems.Add((globaldata.RunTime_Now/60.0f).ToString("0.0") + "/" + (globaldata.RunTotal_Now/60.0f).ToString("0.0")); // tempshow.SubItems.Add((globaldata.RunTime_Now/60.0f).ToString("0.0") + "/" + (globaldata.RunTotal_Now/60.0f).ToString("0.0"));
tempshow.SubItems.Add((globaldata.m_dpbuffer.ShowList.showtime.runtimenow / 60.0f).ToString("0.0") + "/" + (globaldata.m_dpbuffer.ShowList.showtime.alltime / 60.0f).ToString("0.0")); tempshow.SubItems.Add((globaldata.m_dpbuffer.ShowList.showtime.runtimenow / 60.0f).ToString("0.00") + "/" + (globaldata.m_dpbuffer.ShowList.showtime.alltime / 60.0f).ToString("0.00"));
else else
tempshow.SubItems.Add("未运行"); tempshow.SubItems.Add("未运行");
......
...@@ -849,6 +849,5 @@ namespace GcDevicePc.ProThread ...@@ -849,6 +849,5 @@ namespace GcDevicePc.ProThread
} }
} }
} }
} }
...@@ -106,8 +106,8 @@ namespace GcDevicePc.ProThread ...@@ -106,8 +106,8 @@ namespace GcDevicePc.ProThread
try try
{ {
client = new UdpClient(new IPEndPoint(IPAddress.Any, 0)); // client = new UdpClient(new IPEndPoint(IPAddress.Any, 0));
// client = new UdpClient(new IPEndPoint(IPAddress.Parse(this._localip), 0)); client = new UdpClient(new IPEndPoint(IPAddress.Parse(this._localip), 0));
endpoint = new IPEndPoint(IPAddress.Parse("255.255.255.255"), 233); endpoint = new IPEndPoint(IPAddress.Parse("255.255.255.255"), 233);
// endpoint = new IPEndPoint(IPAddress.Parse("192.168.10.230"), 233); // endpoint = new IPEndPoint(IPAddress.Parse("192.168.10.230"), 233);
client.Send(sendBytes, sendBytes.Length, endpoint); client.Send(sendBytes, sendBytes.Length, endpoint);
......
...@@ -13,7 +13,7 @@ namespace GcDevicePc ...@@ -13,7 +13,7 @@ namespace GcDevicePc
Application.SetCompatibleTextRenderingDefault(false); Application.SetCompatibleTextRenderingDefault(false);
bool createNew; bool createNew;
// Application.Run(new DebugForm());
{ {
using (System.Threading.Mutex mutex = new System.Threading.Mutex(true, Application.ProductName, out createNew)) using (System.Threading.Mutex mutex = new System.Threading.Mutex(true, Application.ProductName, out createNew))
{ {
......
...@@ -21,9 +21,9 @@ namespace GcDevicePc ...@@ -21,9 +21,9 @@ namespace GcDevicePc
{ {
int ret = 1; int ret = 1;
FileServerClient singlesend = new FileServerClient(); FileServerClient singlesend = new FileServerClient();
singlesend.WtClientInit("192.168.10.230", 911); singlesend.WtClientInit("192.168.1.88", 911);
ret = singlesend.WtHMICloseRro("WtMainProc"); ret = singlesend.WtHMICloseRro("WtMainProc");
if (ret == 1) // if (ret == 1)
{ {
MessageBox.Show("停止HMI成功!"); MessageBox.Show("停止HMI成功!");
ret = singlesend.WtHMIRunPro("GcDevice.exe", globaldata.exeremoteFolder); ret = singlesend.WtHMIRunPro("GcDevice.exe", globaldata.exeremoteFolder);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment