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"> <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> <HintPath>..\packages\Krypton.Toolkit.5.550.2108.1\lib\net45\Krypton.Toolkit.dll</HintPath>
</Reference> </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"> <Reference Include="NModbus4, Version=2.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\public\NModbus4.dll</HintPath> <HintPath>..\public\NModbus4.dll</HintPath>
@@ -145,14 +127,10 @@
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Configuration" /> <Reference Include="System.Configuration" />
<Reference Include="System.Core" /> <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.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" /> <Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
@@ -278,6 +256,7 @@
<Compile Include="FrmUserControl\Base\frmWarning.Designer.cs"> <Compile Include="FrmUserControl\Base\frmWarning.Designer.cs">
<DependentUpon>frmWarning.cs</DependentUpon> <DependentUpon>frmWarning.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="ListItem.cs" />
<Compile Include="Utils\GlobalHelper.cs" /> <Compile Include="Utils\GlobalHelper.cs" />
<Compile Include="Model\BasCleanTypeMsg.cs" /> <Compile Include="Model\BasCleanTypeMsg.cs" />
<Compile Include="Model\BasPlcItemMd.cs" /> <Compile Include="Model\BasPlcItemMd.cs" />

View File

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

View File

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

View File

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

View File

@@ -13,7 +13,7 @@ using System.Drawing;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Web.UI.WebControls;
using System.Windows.Forms; using System.Windows.Forms;
namespace CleanMachineHMI.FrmUserControl 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 Modbus.Device;
using NX_LogUtility; using NX_LogUtility;
using System; using System;
@@ -60,8 +62,15 @@ namespace CleanMachineHMI
set { this._isConn = value; } set { this._isConn = value; }
} }
private static IModbusMaster master; private static IModbusMaster master;
#if USE_LOCAL_TCP_DEBUG
private static System.Net.Sockets.TcpClient port; private static System.Net.Sockets.TcpClient port;
#else
private static SerialPort port;
#endif
/// <summary>
/// 初始化PLC
/// </summary>
/// <returns></returns>
public bool PlcInit() public bool PlcInit()
{ {
try 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); 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); 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"]); 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(); port = new System.Net.Sockets.TcpClient();
#else
port = new SerialPort(portname, baudrate, paritymsg, databits, stopbis);
#endif
if (modbusPattern == 0) if (modbusPattern == 0)
{ {
master = ModbusSerialMaster.CreateRtu(port); master = ModbusSerialMaster.CreateRtu(port);
@@ -82,9 +95,13 @@ namespace CleanMachineHMI
{ {
master = ModbusSerialMaster.CreateAscii(port); master = ModbusSerialMaster.CreateAscii(port);
} }
#if USE_LOCAL_TCP_DEBUG
port.Connect("127.0.0.1", 5002); port.Connect("127.0.0.1", 5002);
// port.Open();
this._isConn = true; this._isConn = true;
#else
port.Open();
#endif
return true; return true;
} }
catch (Exception ex) catch (Exception ex)
@@ -795,18 +812,25 @@ namespace CleanMachineHMI
WritePlcItem("PlcHeartbeatWriteData", wcsToPlcHeartDataNew.ToString(), PlcItemTypeDesc.D); WritePlcItem("PlcHeartbeatWriteData", wcsToPlcHeartDataNew.ToString(), PlcItemTypeDesc.D);
} }
//if (DateTime.Now > HeartbeatTime.AddSeconds(5))//心跳超时
//{
// isConn = false; #if USE_LOCAL_TCP_DEBUG
// //报警处理。
// frmMainNew.Show_Plc_Alarm("PLC heartbeat data is abnormal, PLC loses connection!"); #else
// if (ReConnNum % 5 == 0)
// { if (DateTime.Now > HeartbeatTime.AddSeconds(5))//心跳超时
// ClosePlcConn(); {
// PlcInit(); isConn = false;
// } //报警处理。
// ReConnNum++; frmMainNew.Show_Plc_Alarm("PLC heartbeat data is abnormal, PLC loses connection!");
//} if (ReConnNum % 5 == 0)
{
ClosePlcConn();
PlcInit();
}
ReConnNum++;
}
#endif
} }
catch catch
{ {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,14 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<entityFramework>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
<provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
</providers>
</entityFramework>
</configuration>

View File

@@ -103,9 +103,6 @@
<Compile Include="LeadDbHelperSQLServer.cs" /> <Compile Include="LeadDbHelperSQLServer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\NX_LogUtility\NX_LogUtility.csproj"> <ProjectReference Include="..\NX_LogUtility\NX_LogUtility.csproj">
<Project>{925057D8-7EE8-42ED-8AA0-628AF82F10B2}</Project> <Project>{925057D8-7EE8-42ED-8AA0-628AF82F10B2}</Project>