This commit is contained in:
gongxh
2021-12-27 09:51:57 +08:00
parent d39ac43a08
commit c6260156f8
17 changed files with 68 additions and 67 deletions

View File

@@ -120,24 +120,6 @@
<Reference Include="Krypton.Toolkit, Version=5.550.2108.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Krypton.Toolkit.5.550.2108.1\lib\net45\Krypton.Toolkit.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ReportViewer.Common, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.ReportingServices.ReportViewerControl.Winforms.140.1000.523\lib\net40\Microsoft.ReportViewer.Common.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ReportViewer.DataVisualization, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.ReportingServices.ReportViewerControl.Winforms.140.1000.523\lib\net40\Microsoft.ReportViewer.DataVisualization.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ReportViewer.Design, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.ReportingServices.ReportViewerControl.Winforms.140.1000.523\lib\net40\Microsoft.ReportViewer.Design.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ReportViewer.ProcessingObjectModel, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.ReportingServices.ReportViewerControl.Winforms.140.1000.523\lib\net40\Microsoft.ReportViewer.ProcessingObjectModel.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ReportViewer.WinForms, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.ReportingServices.ReportViewerControl.Winforms.140.1000.523\lib\net40\Microsoft.ReportViewer.WinForms.dll</HintPath>
</Reference>
<Reference Include="Microsoft.SqlServer.Types, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.SqlServer.Types.14.0.314.76\lib\net40\Microsoft.SqlServer.Types.dll</HintPath>
</Reference>
<Reference Include="NModbus4, Version=2.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\public\NModbus4.dll</HintPath>
@@ -145,14 +127,10 @@
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Design" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
@@ -278,6 +256,7 @@
<Compile Include="FrmUserControl\Base\frmWarning.Designer.cs">
<DependentUpon>frmWarning.cs</DependentUpon>
</Compile>
<Compile Include="ListItem.cs" />
<Compile Include="Utils\GlobalHelper.cs" />
<Compile Include="Model\BasCleanTypeMsg.cs" />
<Compile Include="Model\BasPlcItemMd.cs" />

View File

@@ -11,7 +11,7 @@ using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.UI.WebControls;
using System.Windows.Forms;
namespace CleanMachineHMI.FrmUserControl

View File

@@ -11,7 +11,7 @@ using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.UI.WebControls;
using System.Windows.Forms;
namespace CleanMachineHMI.FrmUserControl

View File

@@ -13,7 +13,7 @@ using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Web.UI.WebControls;
using System.Windows.Forms;
namespace CleanMachineHMI.FrmUserControl

View File

@@ -13,7 +13,7 @@ using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.UI.WebControls;
using System.Windows.Forms;
namespace CleanMachineHMI.FrmUserControl

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CleanMachineHMI
{
public class ListItem
{
public string Value { get; set; }
public string Text { get; set; }
}
}

View File

@@ -1,4 +1,6 @@
using LeadDataBaseUtility;
#define USE_LOCAL_TCP_DEBUG //使用本地调式
using LeadDataBaseUtility;
using Modbus.Device;
using NX_LogUtility;
using System;
@@ -60,8 +62,15 @@ namespace CleanMachineHMI
set { this._isConn = value; }
}
private static IModbusMaster master;
#if USE_LOCAL_TCP_DEBUG
private static System.Net.Sockets.TcpClient port;
#else
private static SerialPort port;
#endif
/// <summary>
/// 初始化PLC
/// </summary>
/// <returns></returns>
public bool PlcInit()
{
try
@@ -72,8 +81,12 @@ namespace CleanMachineHMI
StopBits stopbis = Convert.ToInt32(GlobalHelper.ParameterList.Select(" PARAMETER_CODE = 'StopBits'")[0]["PARAMETER_VALUE"]) == 0 ? StopBits.None : (Convert.ToInt32(GlobalHelper.ParameterList.Select(" PARAMETER_CODE = 'StopBits'")[0]["PARAMETER_VALUE"]) == 1 ? StopBits.One : StopBits.Two);
Parity paritymsg = Convert.ToInt32(GlobalHelper.ParameterList.Select(" PARAMETER_CODE = 'ParityMsg'")[0]["PARAMETER_VALUE"]) == 0 ? Parity.None : (Convert.ToInt32(GlobalHelper.ParameterList.Select(" PARAMETER_CODE = 'ParityMsg'")[0]["PARAMETER_VALUE"]) == 1 ? Parity.Odd : Parity.Even);
int modbusPattern = Convert.ToInt32(GlobalHelper.ParameterList.Select(" PARAMETER_CODE = 'ModbusPattern'")[0]["PARAMETER_VALUE"]);
// port = new SerialPort(portname, baudrate, paritymsg, databits, stopbis);
#if USE_LOCAL_TCP_DEBUG
port = new System.Net.Sockets.TcpClient();
#else
port = new SerialPort(portname, baudrate, paritymsg, databits, stopbis);
#endif
if (modbusPattern == 0)
{
master = ModbusSerialMaster.CreateRtu(port);
@@ -82,9 +95,13 @@ namespace CleanMachineHMI
{
master = ModbusSerialMaster.CreateAscii(port);
}
#if USE_LOCAL_TCP_DEBUG
port.Connect("127.0.0.1", 5002);
// port.Open();
this._isConn = true;
#else
port.Open();
#endif
return true;
}
catch (Exception ex)
@@ -795,18 +812,25 @@ namespace CleanMachineHMI
WritePlcItem("PlcHeartbeatWriteData", wcsToPlcHeartDataNew.ToString(), PlcItemTypeDesc.D);
}
//if (DateTime.Now > HeartbeatTime.AddSeconds(5))//心跳超时
//{
// isConn = false;
// //报警处理。
// frmMainNew.Show_Plc_Alarm("PLC heartbeat data is abnormal, PLC loses connection!");
// if (ReConnNum % 5 == 0)
// {
// ClosePlcConn();
// PlcInit();
// }
// ReConnNum++;
//}
#if USE_LOCAL_TCP_DEBUG
#else
if (DateTime.Now > HeartbeatTime.AddSeconds(5))//心跳超时
{
isConn = false;
//报警处理。
frmMainNew.Show_Plc_Alarm("PLC heartbeat data is abnormal, PLC loses connection!");
if (ReConnNum % 5 == 0)
{
ClosePlcConn();
PlcInit();
}
ReConnNum++;
}
#endif
}
catch
{

View File

@@ -11,7 +11,7 @@ using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.UI.WebControls;
using System.Windows.Forms;
namespace CleanMachineHMI.frmChild

View File

@@ -11,7 +11,7 @@ using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.UI.WebControls;
using System.Windows.Forms;
namespace CleanMachineHMI.frmChild

View File

@@ -11,7 +11,7 @@ using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.UI.WebControls;
using System.Windows.Forms;
namespace CleanMachineHMI.frmChild

View File

@@ -11,7 +11,7 @@ using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.UI.WebControls;
using System.Windows.Forms;
namespace CleanMachineHMI.frmChild

View File

@@ -11,7 +11,7 @@ using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.UI.WebControls;
using System.Windows.Forms;
namespace CleanMachineHMI.frmChild

View File

@@ -11,7 +11,7 @@ using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.UI.WebControls;
using System.Windows.Forms;
namespace CleanMachineHMI.frmChild

View File

@@ -8,7 +8,7 @@ using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.UI.WebControls;
using System.Windows.Forms;
namespace CleanMachineHMI.frmChild

View File

@@ -136,7 +136,7 @@ namespace CleanMachineHMI
{
}
Thread.Sleep(5);
Thread.Sleep(20);
}
}
private void InitControl()