diff --git a/HighWayIot.Plc/HighWayIot.Plc.csproj b/HighWayIot.Plc/HighWayIot.Plc.csproj
index 2da7e8b..4f77e52 100644
--- a/HighWayIot.Plc/HighWayIot.Plc.csproj
+++ b/HighWayIot.Plc/HighWayIot.Plc.csproj
@@ -50,9 +50,7 @@
-
-
diff --git a/HighWayIot.Plc/PlcConnect.cs b/HighWayIot.Plc/PlcConnect.cs
index db79169..f22664c 100644
--- a/HighWayIot.Plc/PlcConnect.cs
+++ b/HighWayIot.Plc/PlcConnect.cs
@@ -20,14 +20,15 @@ namespace HighWayIot.Plc
private static LogHelper logHelper = LogHelper.Instance;
///
- /// 静态懒加载MelsecMcNet1
+ /// 静态懒加载MelsecMcNet1 开炼机CPU
///
- private static readonly MelsecMcNet MelsecInstance1 = new PlcConnect().CreateAb("192.168.0.7");
+ //public static readonly MelsecMcNet MelsecInstance1 = new PlcConnect().CreateAb("10.20.48.40");
+ public static readonly MelsecMcNet MelsecInstance1 = new PlcConnect().CreateAb("127.0.0.1");
///
- /// 静态懒加载MelsecMcNet2
+ /// 静态懒加载MelsecMcNet2 成型机CPU
///
- private static readonly MelsecMcNet MelsecInstance2 = new PlcConnect().CreateAb("10.20.48.225");
+ public static readonly MelsecMcNet MelsecInstance2 = new PlcConnect().CreateAb("10.20.48.225");
private PlcConnect()
{
@@ -217,6 +218,9 @@ namespace HighWayIot.Plc
return result;
}
+
+
+
///
/// 字符串读取1
///
diff --git a/HighWayIot.Plc/PlcHelper/BasePlcHelper.cs b/HighWayIot.Plc/PlcHelper/BasePlcHelper.cs
deleted file mode 100644
index ecf6e5b..0000000
--- a/HighWayIot.Plc/PlcHelper/BasePlcHelper.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace HighWayIot.Plc.PlcHelper
-{
- public class BasePlcHelper
- {
- //public PlcConnect PlcInstance = PlcConnect.Instance;
-
- //public BasePlcHelper()
- //{
-
- //}
-
- }
-}
diff --git a/HighWayIot.Plc/PlcHelper/RecipeParaHelper.cs b/HighWayIot.Plc/PlcHelper/RecipeParaHelper.cs
index 0e0a752..e838f8c 100644
--- a/HighWayIot.Plc/PlcHelper/RecipeParaHelper.cs
+++ b/HighWayIot.Plc/PlcHelper/RecipeParaHelper.cs
@@ -57,7 +57,7 @@ namespace HighWayIot.Plc.PlcHelper
bitDatas[1] = bitDatas[1].SetBoolByIndex(1, paraEntity.S9 ?? false);
ushort bitData = bitDatas.FromBytes();
- if(!PlcConnect.PlcWrite1("D390", bitData, DataTypeEnum.UInt16).IsSuccess) return false;
+ if (!PlcConnect.PlcWrite1("D390", bitData, DataTypeEnum.UInt16).IsSuccess) return false;
if (!PlcConnect.PlcWrite1("D391", paraEntity.RimInch ?? 0, DataTypeEnum.UInt16).IsSuccess)
return false;
@@ -179,18 +179,29 @@ namespace HighWayIot.Plc.PlcHelper
///
public List DownLoadFormPlc(ref ZxRecipeParaEntity paraEntity)
{
+ //一次性读取
+ OperateResult result = PlcConnect.MelsecInstance1.Read("D290", 120);
+ byte[] data;
+ if (result.IsSuccess)
+ {
+ data = result.Content;
+ }
+ else
+ {
+ return new List();
+ }
//读取SPEC编号
paraEntity.SpecCode = PlcConnect.ReadUInt321("D206").ToString();
//读取SPEC名称
- paraEntity.SpecName = PlcConnect.ReadString1("D290", 10).Trim();
+ paraEntity.SpecName = PlcConnect.MelsecInstance1.ByteTransform.TransString(data, 0, 10, Encoding.ASCII);
//读取工位参数
- List positionEntitys = SelectReadPositionPara();
+ List positionEntitys = SelectReadPositionPara(data);
//公共参数读取
- ushort bitData = PlcConnect.ReadUInt161($"D390");
+ ushort bitData = PlcConnect.MelsecInstance1.ByteTransform.TransUInt16(data, (390 - 290) * 2);
byte[] bitDatas = bitData.ToBytes();
paraEntity.S0 = bitDatas[0].GetBoolByIndex(0);
paraEntity.S1 = bitDatas[0].GetBoolByIndex(1);
@@ -203,11 +214,11 @@ namespace HighWayIot.Plc.PlcHelper
paraEntity.S8 = bitDatas[1].GetBoolByIndex(0);
paraEntity.S9 = bitDatas[1].GetBoolByIndex(1);
- paraEntity.RimInch = PlcConnect.ReadInt161("D391");
- paraEntity.LightWidth = PlcConnect.ReadInt161("D392");
- paraEntity.SlowDistance = PlcConnect.ReadInt161("D393");
- paraEntity.StopDistance = PlcConnect.ReadInt161("D394");
- paraEntity.TireWeight = PlcConnect.ReadFloat1("D398");
+ paraEntity.RimInch = PlcConnect.MelsecInstance1.ByteTransform.TransInt16(data, (391 - 290) * 2);//("D391");
+ paraEntity.LightWidth = PlcConnect.MelsecInstance1.ByteTransform.TransInt16(data, (392 - 290) * 2);//("D392");
+ paraEntity.SlowDistance = PlcConnect.MelsecInstance1.ByteTransform.TransInt16(data, (393 - 290) * 2);//("D393");
+ paraEntity.StopDistance = PlcConnect.MelsecInstance1.ByteTransform.TransInt16(data, (394 - 290) * 2);//("D394");
+ paraEntity.TireWeight = PlcConnect.MelsecInstance1.ByteTransform.TransSingle(data, (398 - 290) * 2);//("D398");
return positionEntitys;
}
@@ -217,21 +228,21 @@ namespace HighWayIot.Plc.PlcHelper
///
///
///
- private List SelectReadPositionPara()
+ private List SelectReadPositionPara(byte[] data)
{
List e = new List
{
- ReadPositionPara(310),
- ReadPositionPara(320),
- ReadPositionPara(330),
- ReadPositionPara(340),
- ReadPositionPara(350),
- ReadPositionPara(360),
- ReadPositionPara(370),
- ReadPositionPara(380)
+ ReadPositionPara(310-290, data),
+ ReadPositionPara(320-290, data),
+ ReadPositionPara(330-290, data),
+ ReadPositionPara(340-290, data),
+ ReadPositionPara(350-290, data),
+ ReadPositionPara(360-290, data),
+ ReadPositionPara(370-290, data),
+ ReadPositionPara(380-290, data)
};
-
+
return e;
}
@@ -242,23 +253,23 @@ namespace HighWayIot.Plc.PlcHelper
///
///
///
- private ZxRecipePositionParaEntity ReadPositionPara(int add)
+ private ZxRecipePositionParaEntity ReadPositionPara(int add, byte[] data)
{
ZxRecipePositionParaEntity entity = new ZxRecipePositionParaEntity();
- if (add == 310) entity.Position = 1;
- if (add == 320) entity.Position = 2;
- if (add == 330) entity.Position = 31;
- if (add == 340) entity.Position = 32;
- if (add == 350) entity.Position = 41;
- if (add == 360) entity.Position = 42;
- if (add == 370) entity.Position = 51;
- if (add == 380) entity.Position = 52;
-
+ if (add == 310 - 290) entity.Position = 1;
+ if (add == 320 - 290) entity.Position = 2;
+ if (add == 330 - 290) entity.Position = 31;
+ if (add == 340 - 290) entity.Position = 32;
+ if (add == 350 - 290) entity.Position = 41;
+ if (add == 360 - 290) entity.Position = 42;
+ if (add == 370 - 290) entity.Position = 51;
+ if (add == 380 - 290) entity.Position = 52;
+
for (int i = 1; i <= 10; i++)
{
var prop = entity.GetType().GetProperty($"E{i}");
- prop.SetValue(entity, (int)PlcConnect.ReadUInt161($"D{add}"));
+ prop.SetValue(entity, (int)PlcConnect.MelsecInstance1.ByteTransform.TransInt16(data, add * 2));
add++;
}
diff --git a/HighWayIot.Plc/PlcHelper/RfidResult.cs b/HighWayIot.Plc/PlcHelper/RfidResult.cs
deleted file mode 100644
index 259d9fa..0000000
--- a/HighWayIot.Plc/PlcHelper/RfidResult.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace HighWayIot.Plc.PlcHelper
-{
- public class RfidResult
- {
-
- }
-}
diff --git a/HighWayIot.Plc/PlcHelper/WorkStationHelper.cs b/HighWayIot.Plc/PlcHelper/WorkStationHelper.cs
index fbde2dd..153d303 100644
--- a/HighWayIot.Plc/PlcHelper/WorkStationHelper.cs
+++ b/HighWayIot.Plc/PlcHelper/WorkStationHelper.cs
@@ -1,4 +1,5 @@
using HighWayIot.Plc.PlcEntity;
+using HslCommunication;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -27,7 +28,7 @@ namespace HighWayIot.Plc.PlcHelper
//选择是小车的哪个点位
point += rgvStationNo;
- bool result = PlcConnect.PlcWrite1($"B{point.ToString("X")}", true, DataTypeEnum.Bool).IsSuccess;
+ bool result = PlcConnect.PlcWrite2($"B{point.ToString("X")}", true, DataTypeEnum.Bool).IsSuccess;
return result;
}
@@ -41,11 +42,22 @@ namespace HighWayIot.Plc.PlcHelper
{
bool[] result = new bool[17];
- for (int i = 0x230; i <= 0x240; i++)
+ OperateResult PlcResult = PlcConnect.MelsecInstance2.Read("B230", 17);
+
+ byte[] data = PlcResult.Content;
+
+ if (PlcResult.IsSuccess == true)
{
- int j = 0;
- result[j] = PlcConnect.ReadBool1($"B{i.ToString("X")}");
- j++;
+ for (int i = 0; i < 17; i++)
+ {
+ int dataCount = i / 8;
+ int indexCount = i % 8;
+ result[i] = data[dataCount].GetBoolByIndex(indexCount);
+ }
+ }
+ else
+ {
+ return null;
}
return result;
diff --git a/HighWayIot.Winform/Business/WorkStationBusiness.cs b/HighWayIot.Winform/Business/WorkStationBusiness.cs
index 03e0ec9..c0c2c7b 100644
--- a/HighWayIot.Winform/Business/WorkStationBusiness.cs
+++ b/HighWayIot.Winform/Business/WorkStationBusiness.cs
@@ -81,13 +81,19 @@ namespace HighWayIot.Winform.Business
}
///
- /// 自动监视
+ /// 自动监视 获取PLC信号
///
///
public void SingalMonitor(object o)
{
bool[] singals = _workStationHelper.ReadStationSingal();
+ if(singals == null)
+ {
+ _logHelper.Error("工位监视PLC读取信号失败");
+ return;
+ }
+
for (int i = 1; i <= singals.Length; i++)
{
if (singals[i - 1] == true)
diff --git a/HighWayIot.Winform/MainForm/BaseForm.Designer.cs b/HighWayIot.Winform/MainForm/BaseForm.Designer.cs
index 4a54aa2..f4ab905 100644
--- a/HighWayIot.Winform/MainForm/BaseForm.Designer.cs
+++ b/HighWayIot.Winform/MainForm/BaseForm.Designer.cs
@@ -35,6 +35,17 @@ namespace HighWayIot.Winform.MainForm
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(BaseForm));
this.MainMenu = new System.Windows.Forms.MenuStrip();
+ this.SysConfigStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.UserStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.RoleStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.ShiftTimeConfigStripItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.LogoutStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.SysQuitStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.LogManageStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.DaliyReportStripItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.OperateLogStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.AlarmLogStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.MonitorMainPageStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ProductionSchedulingStripItem = new System.Windows.Forms.ToolStripMenuItem();
this.MaterialMenuStripItem = new System.Windows.Forms.ToolStripMenuItem();
this.MaterialConfigStripItem = new System.Windows.Forms.ToolStripMenuItem();
@@ -58,17 +69,11 @@ namespace HighWayIot.Winform.MainForm
this.StripLabel2 = new System.Windows.Forms.ToolStripStatusLabel();
this.TimeStripLabel = new System.Windows.Forms.ToolStripStatusLabel();
this.TimeDisplayTimer = new System.Windows.Forms.Timer(this.components);
- this.SysConfigStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.UserStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.RoleStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.ShiftTimeConfigStripItem = new System.Windows.Forms.ToolStripMenuItem();
- this.LogoutStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.SysQuitStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.LogManageStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.DaliyReportStripItem = new System.Windows.Forms.ToolStripMenuItem();
- this.OperateLogStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.AlarmLogStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.MonitorMainPageStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.SplitLabel4 = new System.Windows.Forms.ToolStripStatusLabel();
+ this.Label1 = new System.Windows.Forms.ToolStripStatusLabel();
+ this.Label2 = new System.Windows.Forms.ToolStripStatusLabel();
+ this.OpenMixStateLabel = new System.Windows.Forms.ToolStripStatusLabel();
+ this.MolderStateLabel = new System.Windows.Forms.ToolStripStatusLabel();
this.MainMenu.SuspendLayout();
this.statusStrip1.SuspendLayout();
this.SuspendLayout();
@@ -92,196 +97,6 @@ namespace HighWayIot.Winform.MainForm
this.MainMenu.TabIndex = 1;
this.MainMenu.Text = "menuStrip1";
//
- // ProductionSchedulingStripItem
- //
- this.ProductionSchedulingStripItem.Image = global::HighWayIot.Winform.Properties.Resources.生产排程;
- this.ProductionSchedulingStripItem.Name = "ProductionSchedulingStripItem";
- this.ProductionSchedulingStripItem.Size = new System.Drawing.Size(84, 22);
- this.ProductionSchedulingStripItem.Text = "生产排程";
- this.ProductionSchedulingStripItem.Click += new System.EventHandler(this.StripMenuItemClick);
- //
- // MaterialMenuStripItem
- //
- this.MaterialMenuStripItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.MaterialConfigStripItem,
- this.MaterialTypeConfigStripItem});
- this.MaterialMenuStripItem.Image = global::HighWayIot.Winform.Properties.Resources.物料库存管控;
- this.MaterialMenuStripItem.Name = "MaterialMenuStripItem";
- this.MaterialMenuStripItem.Size = new System.Drawing.Size(96, 22);
- this.MaterialMenuStripItem.Text = "原材料管理";
- //
- // MaterialConfigStripItem
- //
- this.MaterialConfigStripItem.Image = global::HighWayIot.Winform.Properties.Resources.物料管理;
- this.MaterialConfigStripItem.Name = "MaterialConfigStripItem";
- this.MaterialConfigStripItem.Size = new System.Drawing.Size(180, 22);
- this.MaterialConfigStripItem.Text = "物料管理";
- this.MaterialConfigStripItem.Click += new System.EventHandler(this.StripMenuItemClick);
- //
- // MaterialTypeConfigStripItem
- //
- this.MaterialTypeConfigStripItem.Image = global::HighWayIot.Winform.Properties.Resources.物料需求;
- this.MaterialTypeConfigStripItem.Name = "MaterialTypeConfigStripItem";
- this.MaterialTypeConfigStripItem.Size = new System.Drawing.Size(180, 22);
- this.MaterialTypeConfigStripItem.Text = "物料类型管理";
- this.MaterialTypeConfigStripItem.Click += new System.EventHandler(this.StripMenuItemClick);
- //
- // RecipeConfigStripItem
- //
- this.RecipeConfigStripItem.Image = global::HighWayIot.Winform.Properties.Resources.业务_配方;
- this.RecipeConfigStripItem.Name = "RecipeConfigStripItem";
- this.RecipeConfigStripItem.Size = new System.Drawing.Size(84, 22);
- this.RecipeConfigStripItem.Text = "配方管理";
- this.RecipeConfigStripItem.Click += new System.EventHandler(this.StripMenuItemClick);
- //
- // EquipMaterialBindingStripItem
- //
- this.EquipMaterialBindingStripItem.Image = global::HighWayIot.Winform.Properties.Resources.绑定;
- this.EquipMaterialBindingStripItem.Name = "EquipMaterialBindingStripItem";
- this.EquipMaterialBindingStripItem.Size = new System.Drawing.Size(132, 22);
- this.EquipMaterialBindingStripItem.Text = "机台物料信息绑定";
- this.EquipMaterialBindingStripItem.Click += new System.EventHandler(this.StripMenuItemClick);
- //
- // TestMenuItem
- //
- this.TestMenuItem.Image = global::HighWayIot.Winform.Properties.Resources.PLC;
- this.TestMenuItem.Name = "TestMenuItem";
- this.TestMenuItem.Size = new System.Drawing.Size(105, 22);
- this.TestMenuItem.Text = "PLC测试页面";
- this.TestMenuItem.Click += new System.EventHandler(this.StripMenuItemClick);
- //
- // DeviceDataManageToolStripMenuItem
- //
- this.DeviceDataManageToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.RFIDParamManageToolStripMenuItem,
- this.DeviceParamManageToolStripMenuItem});
- this.DeviceDataManageToolStripMenuItem.Image = global::HighWayIot.Winform.Properties.Resources.参数;
- this.DeviceDataManageToolStripMenuItem.Name = "DeviceDataManageToolStripMenuItem";
- this.DeviceDataManageToolStripMenuItem.Size = new System.Drawing.Size(84, 22);
- this.DeviceDataManageToolStripMenuItem.Text = "参数管理";
- //
- // RFIDParamManageToolStripMenuItem
- //
- this.RFIDParamManageToolStripMenuItem.Image = global::HighWayIot.Winform.Properties.Resources._165_RFID;
- this.RFIDParamManageToolStripMenuItem.Name = "RFIDParamManageToolStripMenuItem";
- this.RFIDParamManageToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
- this.RFIDParamManageToolStripMenuItem.Text = "RFID参数配置";
- this.RFIDParamManageToolStripMenuItem.Click += new System.EventHandler(this.StripMenuItemClick);
- //
- // DeviceParamManageToolStripMenuItem
- //
- this.DeviceParamManageToolStripMenuItem.Image = global::HighWayIot.Winform.Properties.Resources.设备;
- this.DeviceParamManageToolStripMenuItem.Name = "DeviceParamManageToolStripMenuItem";
- this.DeviceParamManageToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
- this.DeviceParamManageToolStripMenuItem.Text = "设备参数配置";
- this.DeviceParamManageToolStripMenuItem.Click += new System.EventHandler(this.StripMenuItemClick);
- //
- // UserControlTabs
- //
- this.UserControlTabs.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.UserControlTabs.Cursor = System.Windows.Forms.Cursors.Default;
- this.UserControlTabs.Location = new System.Drawing.Point(0, 24);
- this.UserControlTabs.Margin = new System.Windows.Forms.Padding(0);
- this.UserControlTabs.Name = "UserControlTabs";
- this.UserControlTabs.SelectedIndex = 0;
- this.UserControlTabs.Size = new System.Drawing.Size(1476, 817);
- this.UserControlTabs.TabIndex = 3;
- //
- // ClosePageButton
- //
- this.ClosePageButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.ClosePageButton.BackColor = System.Drawing.Color.Red;
- this.ClosePageButton.Cursor = System.Windows.Forms.Cursors.Hand;
- this.ClosePageButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
- this.ClosePageButton.ForeColor = System.Drawing.SystemColors.ButtonHighlight;
- this.ClosePageButton.Location = new System.Drawing.Point(1455, 1);
- this.ClosePageButton.Name = "ClosePageButton";
- this.ClosePageButton.Size = new System.Drawing.Size(20, 20);
- this.ClosePageButton.TabIndex = 4;
- this.ClosePageButton.Text = "X";
- this.ClosePageButton.UseVisualStyleBackColor = false;
- this.ClosePageButton.Click += new System.EventHandler(this.CloseButton_Click);
- //
- // statusStrip1
- //
- this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.HighWayLogo,
- this.SplitLabel1,
- this.StripLabel1,
- this.NowLoginUserName,
- this.SplitLabel2,
- this.LogInformationToolStrip,
- this.SplitLabel3,
- this.StripLabel2,
- this.TimeStripLabel});
- this.statusStrip1.Location = new System.Drawing.Point(0, 841);
- this.statusStrip1.Name = "statusStrip1";
- this.statusStrip1.Size = new System.Drawing.Size(1475, 22);
- this.statusStrip1.TabIndex = 5;
- this.statusStrip1.Text = "statusStrip1";
- //
- // HighWayLogo
- //
- this.HighWayLogo.Name = "HighWayLogo";
- this.HighWayLogo.Size = new System.Drawing.Size(143, 17);
- this.HighWayLogo.Text = "Design by HighWayIOT";
- //
- // SplitLabel1
- //
- this.SplitLabel1.BorderSides = ((System.Windows.Forms.ToolStripStatusLabelBorderSides)((System.Windows.Forms.ToolStripStatusLabelBorderSides.Left | System.Windows.Forms.ToolStripStatusLabelBorderSides.Right)));
- this.SplitLabel1.Name = "SplitLabel1";
- this.SplitLabel1.Size = new System.Drawing.Size(4, 17);
- //
- // StripLabel1
- //
- this.StripLabel1.Name = "StripLabel1";
- this.StripLabel1.Size = new System.Drawing.Size(80, 17);
- this.StripLabel1.Text = "当前登录人:";
- //
- // NowLoginUserName
- //
- this.NowLoginUserName.Name = "NowLoginUserName";
- this.NowLoginUserName.Size = new System.Drawing.Size(31, 17);
- this.NowLoginUserName.Text = "N/A";
- //
- // SplitLabel2
- //
- this.SplitLabel2.BorderSides = ((System.Windows.Forms.ToolStripStatusLabelBorderSides)((System.Windows.Forms.ToolStripStatusLabelBorderSides.Left | System.Windows.Forms.ToolStripStatusLabelBorderSides.Right)));
- this.SplitLabel2.Name = "SplitLabel2";
- this.SplitLabel2.Size = new System.Drawing.Size(4, 17);
- //
- // LogInformationToolStrip
- //
- this.LogInformationToolStrip.Name = "LogInformationToolStrip";
- this.LogInformationToolStrip.Size = new System.Drawing.Size(1095, 17);
- this.LogInformationToolStrip.Spring = true;
- this.LogInformationToolStrip.Text = "message";
- //
- // SplitLabel3
- //
- this.SplitLabel3.BorderSides = ((System.Windows.Forms.ToolStripStatusLabelBorderSides)((System.Windows.Forms.ToolStripStatusLabelBorderSides.Left | System.Windows.Forms.ToolStripStatusLabelBorderSides.Right)));
- this.SplitLabel3.Name = "SplitLabel3";
- this.SplitLabel3.Size = new System.Drawing.Size(4, 17);
- //
- // StripLabel2
- //
- this.StripLabel2.Name = "StripLabel2";
- this.StripLabel2.Size = new System.Drawing.Size(68, 17);
- this.StripLabel2.Text = "当前时间:";
- //
- // TimeStripLabel
- //
- this.TimeStripLabel.Name = "TimeStripLabel";
- this.TimeStripLabel.Size = new System.Drawing.Size(31, 17);
- this.TimeStripLabel.Text = "N/A";
- //
- // TimeDisplayTimer
- //
- this.TimeDisplayTimer.Interval = 1000;
- this.TimeDisplayTimer.Tick += new System.EventHandler(this.TimeDisplayTimer_Tick);
- //
// SysConfigStripMenuItem
//
this.SysConfigStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
@@ -378,6 +193,231 @@ namespace HighWayIot.Winform.MainForm
this.MonitorMainPageStripMenuItem.Text = "监控主页面";
this.MonitorMainPageStripMenuItem.Click += new System.EventHandler(this.StripMenuItemClick);
//
+ // ProductionSchedulingStripItem
+ //
+ this.ProductionSchedulingStripItem.Image = global::HighWayIot.Winform.Properties.Resources.生产排程;
+ this.ProductionSchedulingStripItem.Name = "ProductionSchedulingStripItem";
+ this.ProductionSchedulingStripItem.Size = new System.Drawing.Size(84, 22);
+ this.ProductionSchedulingStripItem.Text = "生产排程";
+ this.ProductionSchedulingStripItem.Click += new System.EventHandler(this.StripMenuItemClick);
+ //
+ // MaterialMenuStripItem
+ //
+ this.MaterialMenuStripItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.MaterialConfigStripItem,
+ this.MaterialTypeConfigStripItem});
+ this.MaterialMenuStripItem.Image = global::HighWayIot.Winform.Properties.Resources.物料库存管控;
+ this.MaterialMenuStripItem.Name = "MaterialMenuStripItem";
+ this.MaterialMenuStripItem.Size = new System.Drawing.Size(96, 22);
+ this.MaterialMenuStripItem.Text = "原材料管理";
+ //
+ // MaterialConfigStripItem
+ //
+ this.MaterialConfigStripItem.Image = global::HighWayIot.Winform.Properties.Resources.物料管理;
+ this.MaterialConfigStripItem.Name = "MaterialConfigStripItem";
+ this.MaterialConfigStripItem.Size = new System.Drawing.Size(148, 22);
+ this.MaterialConfigStripItem.Text = "物料管理";
+ this.MaterialConfigStripItem.Click += new System.EventHandler(this.StripMenuItemClick);
+ //
+ // MaterialTypeConfigStripItem
+ //
+ this.MaterialTypeConfigStripItem.Image = global::HighWayIot.Winform.Properties.Resources.物料需求;
+ this.MaterialTypeConfigStripItem.Name = "MaterialTypeConfigStripItem";
+ this.MaterialTypeConfigStripItem.Size = new System.Drawing.Size(148, 22);
+ this.MaterialTypeConfigStripItem.Text = "物料类型管理";
+ this.MaterialTypeConfigStripItem.Click += new System.EventHandler(this.StripMenuItemClick);
+ //
+ // RecipeConfigStripItem
+ //
+ this.RecipeConfigStripItem.Image = global::HighWayIot.Winform.Properties.Resources.业务_配方;
+ this.RecipeConfigStripItem.Name = "RecipeConfigStripItem";
+ this.RecipeConfigStripItem.Size = new System.Drawing.Size(84, 22);
+ this.RecipeConfigStripItem.Text = "配方管理";
+ this.RecipeConfigStripItem.Click += new System.EventHandler(this.StripMenuItemClick);
+ //
+ // EquipMaterialBindingStripItem
+ //
+ this.EquipMaterialBindingStripItem.Image = global::HighWayIot.Winform.Properties.Resources.绑定;
+ this.EquipMaterialBindingStripItem.Name = "EquipMaterialBindingStripItem";
+ this.EquipMaterialBindingStripItem.Size = new System.Drawing.Size(132, 22);
+ this.EquipMaterialBindingStripItem.Text = "机台物料信息绑定";
+ this.EquipMaterialBindingStripItem.Click += new System.EventHandler(this.StripMenuItemClick);
+ //
+ // TestMenuItem
+ //
+ this.TestMenuItem.Image = global::HighWayIot.Winform.Properties.Resources.PLC;
+ this.TestMenuItem.Name = "TestMenuItem";
+ this.TestMenuItem.Size = new System.Drawing.Size(105, 22);
+ this.TestMenuItem.Text = "PLC测试页面";
+ this.TestMenuItem.Click += new System.EventHandler(this.StripMenuItemClick);
+ //
+ // DeviceDataManageToolStripMenuItem
+ //
+ this.DeviceDataManageToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.RFIDParamManageToolStripMenuItem,
+ this.DeviceParamManageToolStripMenuItem});
+ this.DeviceDataManageToolStripMenuItem.Image = global::HighWayIot.Winform.Properties.Resources.参数;
+ this.DeviceDataManageToolStripMenuItem.Name = "DeviceDataManageToolStripMenuItem";
+ this.DeviceDataManageToolStripMenuItem.Size = new System.Drawing.Size(84, 22);
+ this.DeviceDataManageToolStripMenuItem.Text = "参数管理";
+ //
+ // RFIDParamManageToolStripMenuItem
+ //
+ this.RFIDParamManageToolStripMenuItem.Image = global::HighWayIot.Winform.Properties.Resources._165_RFID;
+ this.RFIDParamManageToolStripMenuItem.Name = "RFIDParamManageToolStripMenuItem";
+ this.RFIDParamManageToolStripMenuItem.Size = new System.Drawing.Size(151, 22);
+ this.RFIDParamManageToolStripMenuItem.Text = "RFID参数配置";
+ this.RFIDParamManageToolStripMenuItem.Click += new System.EventHandler(this.StripMenuItemClick);
+ //
+ // DeviceParamManageToolStripMenuItem
+ //
+ this.DeviceParamManageToolStripMenuItem.Image = global::HighWayIot.Winform.Properties.Resources.设备;
+ this.DeviceParamManageToolStripMenuItem.Name = "DeviceParamManageToolStripMenuItem";
+ this.DeviceParamManageToolStripMenuItem.Size = new System.Drawing.Size(151, 22);
+ this.DeviceParamManageToolStripMenuItem.Text = "设备参数配置";
+ this.DeviceParamManageToolStripMenuItem.Click += new System.EventHandler(this.StripMenuItemClick);
+ //
+ // UserControlTabs
+ //
+ this.UserControlTabs.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.UserControlTabs.Cursor = System.Windows.Forms.Cursors.Default;
+ this.UserControlTabs.Location = new System.Drawing.Point(0, 24);
+ this.UserControlTabs.Margin = new System.Windows.Forms.Padding(0);
+ this.UserControlTabs.Name = "UserControlTabs";
+ this.UserControlTabs.SelectedIndex = 0;
+ this.UserControlTabs.Size = new System.Drawing.Size(1476, 817);
+ this.UserControlTabs.TabIndex = 3;
+ //
+ // ClosePageButton
+ //
+ this.ClosePageButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+ this.ClosePageButton.BackColor = System.Drawing.Color.Red;
+ this.ClosePageButton.Cursor = System.Windows.Forms.Cursors.Hand;
+ this.ClosePageButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
+ this.ClosePageButton.ForeColor = System.Drawing.SystemColors.ButtonHighlight;
+ this.ClosePageButton.Location = new System.Drawing.Point(1455, 1);
+ this.ClosePageButton.Name = "ClosePageButton";
+ this.ClosePageButton.Size = new System.Drawing.Size(20, 20);
+ this.ClosePageButton.TabIndex = 4;
+ this.ClosePageButton.Text = "X";
+ this.ClosePageButton.UseVisualStyleBackColor = false;
+ this.ClosePageButton.Click += new System.EventHandler(this.CloseButton_Click);
+ //
+ // statusStrip1
+ //
+ this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.HighWayLogo,
+ this.SplitLabel1,
+ this.StripLabel1,
+ this.NowLoginUserName,
+ this.SplitLabel2,
+ this.LogInformationToolStrip,
+ this.SplitLabel3,
+ this.Label1,
+ this.OpenMixStateLabel,
+ this.Label2,
+ this.MolderStateLabel,
+ this.SplitLabel4,
+ this.StripLabel2,
+ this.TimeStripLabel});
+ this.statusStrip1.Location = new System.Drawing.Point(0, 841);
+ this.statusStrip1.Name = "statusStrip1";
+ this.statusStrip1.Size = new System.Drawing.Size(1475, 22);
+ this.statusStrip1.TabIndex = 5;
+ this.statusStrip1.Text = "statusStrip1";
+ //
+ // HighWayLogo
+ //
+ this.HighWayLogo.Name = "HighWayLogo";
+ this.HighWayLogo.Size = new System.Drawing.Size(143, 17);
+ this.HighWayLogo.Text = "Design by HighWayIOT";
+ //
+ // SplitLabel1
+ //
+ this.SplitLabel1.BorderSides = ((System.Windows.Forms.ToolStripStatusLabelBorderSides)((System.Windows.Forms.ToolStripStatusLabelBorderSides.Left | System.Windows.Forms.ToolStripStatusLabelBorderSides.Right)));
+ this.SplitLabel1.Name = "SplitLabel1";
+ this.SplitLabel1.Size = new System.Drawing.Size(4, 17);
+ //
+ // StripLabel1
+ //
+ this.StripLabel1.Name = "StripLabel1";
+ this.StripLabel1.Size = new System.Drawing.Size(80, 17);
+ this.StripLabel1.Text = "当前登录人:";
+ //
+ // NowLoginUserName
+ //
+ this.NowLoginUserName.Name = "NowLoginUserName";
+ this.NowLoginUserName.Size = new System.Drawing.Size(31, 17);
+ this.NowLoginUserName.Text = "N/A";
+ //
+ // SplitLabel2
+ //
+ this.SplitLabel2.BorderSides = ((System.Windows.Forms.ToolStripStatusLabelBorderSides)((System.Windows.Forms.ToolStripStatusLabelBorderSides.Left | System.Windows.Forms.ToolStripStatusLabelBorderSides.Right)));
+ this.SplitLabel2.Name = "SplitLabel2";
+ this.SplitLabel2.Size = new System.Drawing.Size(4, 17);
+ //
+ // LogInformationToolStrip
+ //
+ this.LogInformationToolStrip.Name = "LogInformationToolStrip";
+ this.LogInformationToolStrip.Size = new System.Drawing.Size(851, 17);
+ this.LogInformationToolStrip.Spring = true;
+ this.LogInformationToolStrip.Text = "message";
+ //
+ // SplitLabel3
+ //
+ this.SplitLabel3.BorderSides = ((System.Windows.Forms.ToolStripStatusLabelBorderSides)((System.Windows.Forms.ToolStripStatusLabelBorderSides.Left | System.Windows.Forms.ToolStripStatusLabelBorderSides.Right)));
+ this.SplitLabel3.Name = "SplitLabel3";
+ this.SplitLabel3.Size = new System.Drawing.Size(4, 17);
+ //
+ // StripLabel2
+ //
+ this.StripLabel2.Name = "StripLabel2";
+ this.StripLabel2.Size = new System.Drawing.Size(68, 17);
+ this.StripLabel2.Text = "当前时间:";
+ //
+ // TimeStripLabel
+ //
+ this.TimeStripLabel.Name = "TimeStripLabel";
+ this.TimeStripLabel.Size = new System.Drawing.Size(31, 17);
+ this.TimeStripLabel.Text = "N/A";
+ //
+ // TimeDisplayTimer
+ //
+ this.TimeDisplayTimer.Interval = 1000;
+ this.TimeDisplayTimer.Tick += new System.EventHandler(this.TimeDisplayTimer_Tick);
+ //
+ // SplitLabel4
+ //
+ this.SplitLabel4.BorderSides = ((System.Windows.Forms.ToolStripStatusLabelBorderSides)((System.Windows.Forms.ToolStripStatusLabelBorderSides.Left | System.Windows.Forms.ToolStripStatusLabelBorderSides.Right)));
+ this.SplitLabel4.Name = "SplitLabel4";
+ this.SplitLabel4.Size = new System.Drawing.Size(4, 17);
+ //
+ // Label1
+ //
+ this.Label1.Name = "Label1";
+ this.Label1.Size = new System.Drawing.Size(89, 17);
+ this.Label1.Text = "开炼PLC状态:";
+ //
+ // Label2
+ //
+ this.Label2.Name = "Label2";
+ this.Label2.Size = new System.Drawing.Size(89, 17);
+ this.Label2.Text = "成型PLC状态:";
+ //
+ // OpenMixStateLabel
+ //
+ this.OpenMixStateLabel.Name = "OpenMixStateLabel";
+ this.OpenMixStateLabel.Size = new System.Drawing.Size(31, 17);
+ this.OpenMixStateLabel.Text = "N/A";
+ //
+ // MolderStateLabel
+ //
+ this.MolderStateLabel.Name = "MolderStateLabel";
+ this.MolderStateLabel.Size = new System.Drawing.Size(31, 17);
+ this.MolderStateLabel.Text = "N/A";
+ //
// BaseForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
@@ -438,5 +478,10 @@ namespace HighWayIot.Winform.MainForm
private ToolStripMenuItem DeviceParamManageToolStripMenuItem;
private ToolStripStatusLabel SplitLabel2;
private ToolStripStatusLabel SplitLabel3;
+ private ToolStripStatusLabel SplitLabel4;
+ private ToolStripStatusLabel Label1;
+ private ToolStripStatusLabel OpenMixStateLabel;
+ private ToolStripStatusLabel Label2;
+ private ToolStripStatusLabel MolderStateLabel;
}
}
\ No newline at end of file
diff --git a/HighWayIot.Winform/MainForm/BaseForm.cs b/HighWayIot.Winform/MainForm/BaseForm.cs
index 328f13e..157725e 100644
--- a/HighWayIot.Winform/MainForm/BaseForm.cs
+++ b/HighWayIot.Winform/MainForm/BaseForm.cs
@@ -1,4 +1,5 @@
using HighWayIot.Log4net;
+using HighWayIot.Plc;
using HighWayIot.Winform.Business;
using HighWayIot.Winform.UserControlPages;
using HighWayIot.Winform.UserControlPages.MaterialConfigPages;
@@ -12,6 +13,7 @@ using System.Diagnostics.Eventing.Reader;
using System.Drawing;
using System.Linq;
using System.Text;
+using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
@@ -45,6 +47,31 @@ namespace HighWayIot.Winform.MainForm
///
public static Action LogRefreshAction;
+ ///
+ /// 开炼机PLC看门狗 0:正常 1:异常 2:未连接
+ ///
+ public static int OpenMixMachineWatchDog = 2;
+
+ ///
+ /// 成型机PLC看门狗 0:正常 1:异常 2:未连接
+ ///
+ public static int MoldingMachineWatchDog = 2;
+
+ ///
+ /// 上一个开炼机看门狗状态
+ ///
+ public int LastOpenMixWatchDogNum = -1;
+
+ ///
+ /// 上一个成型机看门狗状态
+ ///
+ public int LastMoldingMachineWatchDogNum = -1;
+
+ ///
+ /// 看门狗计时器
+ ///
+ private System.Threading.Timer WatchDogTimer;
+
public BaseForm()
{
InitializeComponent();
@@ -61,6 +88,7 @@ namespace HighWayIot.Winform.MainForm
NowLoginUserName.Text = RoleBusiness.LoginUserName;
UserPanelSwitch(typeof(MonitorMainPage), "监控主页面");
RoleControl();
+ WatchDogTimer = new System.Threading.Timer(WarchDogJudge, null, 0, 2000); // 每2秒执行一次
LogRefreshAction += (log) =>
{
LogInformationToolStrip.Text = log;
@@ -251,13 +279,13 @@ namespace HighWayIot.Winform.MainForm
//使用TabControl控件的TabPages属性的Remove方法移除指定的选项卡
UserControlTabs.TabPages.Remove(UserControlTabs.SelectedTab);
- //删除列表里的实例
+ //删除列表里的实例
UserControls.RemoveAll(x => x.Tag.ToString() == selectedStr);
//删除时如果标签没删干净,删完选择最后一个标签
- if(UserControlTabs.TabCount != 0)
+ if (UserControlTabs.TabCount != 0)
{
- if(selectedIndex == 0)
+ if (selectedIndex == 0)
{
UserControlTabs.SelectedTab = UserControlTabs.TabPages[0];
}
@@ -284,7 +312,7 @@ namespace HighWayIot.Winform.MainForm
///
private void RoleControl()
{
- foreach(ToolStripMenuItem i in MainMenu.Items)
+ foreach (ToolStripMenuItem i in MainMenu.Items)
{
TraverseMenuitem(i);
}
@@ -303,5 +331,48 @@ namespace HighWayIot.Winform.MainForm
TraverseMenuitem(i);
}
}
+
+ ///
+ /// PLC看门狗状态判断
+ ///
+ /// 看门狗点位
+ ///
+ private void WarchDogJudge(object state)
+ {
+ //int openMixNow, moldingNow;
+ //if (PlcConnect.IsConnect1)
+ //{
+ // openMixNow = PlcConnect.ReadInt161("D666");
+ // if (openMixNow == LastOpenMixWatchDogNum)
+ // {
+ // OpenMixMachineWatchDog = 0;
+ // }
+ // else
+ // {
+ // OpenMixMachineWatchDog = 1;
+ // }
+ //}
+ //else
+ //{
+ // OpenMixMachineWatchDog = 2;
+ //}
+
+ //if (PlcConnect.IsConnect2)
+ //{
+ // moldingNow = PlcConnect.ReadInt162("D666");
+ // if (moldingNow == LastMoldingMachineWatchDogNum)
+ // {
+ // MoldingMachineWatchDog = 0;
+ // }
+ // else
+ // {
+ // MoldingMachineWatchDog = 1;
+ // }
+ //}
+ //else
+ //{
+ // MoldingMachineWatchDog = 2;
+ //}
+ }
}
}
diff --git a/HighWayIot.Winform/UserControlPages/TestPage.cs b/HighWayIot.Winform/UserControlPages/TestPage.cs
index 1df8098..abcc033 100644
--- a/HighWayIot.Winform/UserControlPages/TestPage.cs
+++ b/HighWayIot.Winform/UserControlPages/TestPage.cs
@@ -1,11 +1,13 @@
using HighWayIot.Log4net;
using HighWayIot.Plc;
using HighWayIot.Winform.Business;
+using HslCommunication;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Net;
+using System.Runtime.InteropServices;
using System.Threading.Tasks;
using System.Windows.Forms;
@@ -41,7 +43,6 @@ namespace HighWayIot.Winform.UserControlPages
XmlUtil xmlUtil = new XmlUtil();
private void button1_Click(object sender, EventArgs e)
{
-
var list = xmlUtil.ConfigReader();
foreach (var item in list)
{