- 删除无用文件
- plc读写形式由单点读取转化为统一读取在解析
master
SoulStar 2 months ago
parent a530c77826
commit 0ea79d69a9

@ -50,9 +50,7 @@
<Compile Include="EndianConvert.cs" />
<Compile Include="PlcConnect.cs" />
<Compile Include="PlcEntity\RgvStationEnum.cs" />
<Compile Include="PlcHelper\BasePlcHelper.cs" />
<Compile Include="PlcHelper\RecipeParaHelper.cs" />
<Compile Include="PlcHelper\RfidResult.cs" />
<Compile Include="PlcHelper\WorkStationHelper.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>

@ -20,14 +20,15 @@ namespace HighWayIot.Plc
private static LogHelper logHelper = LogHelper.Instance;
/// <summary>
/// 静态懒加载MelsecMcNet1
/// 静态懒加载MelsecMcNet1 开炼机CPU
/// </summary>
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");
/// <summary>
/// 静态懒加载MelsecMcNet2
/// 静态懒加载MelsecMcNet2 成型机CPU
/// </summary>
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;
}
/// <summary>
/// 字符串读取1
/// </summary>

@ -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()
//{
//}
}
}

@ -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
/// </summary>
public List<ZxRecipePositionParaEntity> DownLoadFormPlc(ref ZxRecipeParaEntity paraEntity)
{
//一次性读取
OperateResult<byte[]> result = PlcConnect.MelsecInstance1.Read("D290", 120);
byte[] data;
if (result.IsSuccess)
{
data = result.Content;
}
else
{
return new List<ZxRecipePositionParaEntity>();
}
//读取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<ZxRecipePositionParaEntity> positionEntitys = SelectReadPositionPara();
List<ZxRecipePositionParaEntity> 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,18 +228,18 @@ namespace HighWayIot.Plc.PlcHelper
/// </summary>
/// <param name=""></param>
/// <returns></returns>
private List<ZxRecipePositionParaEntity> SelectReadPositionPara()
private List<ZxRecipePositionParaEntity> SelectReadPositionPara(byte[] data)
{
List<ZxRecipePositionParaEntity> e = new List<ZxRecipePositionParaEntity>
{
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)
};
@ -242,23 +253,23 @@ namespace HighWayIot.Plc.PlcHelper
/// <param name="entity"></param>
/// <param name="add"></param>
/// <returns></returns>
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++;
}

@ -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
{
}
}

@ -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<byte[]> 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;

@ -81,13 +81,19 @@ namespace HighWayIot.Winform.Business
}
/// <summary>
/// 自动监视
/// 自动监视 获取PLC信号
/// </summary>
/// <param name="o"></param>
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)

@ -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;
}
}

@ -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
/// </summary>
public static Action<string> LogRefreshAction;
/// <summary>
/// 开炼机PLC看门狗 0正常 1异常 2未连接
/// </summary>
public static int OpenMixMachineWatchDog = 2;
/// <summary>
/// 成型机PLC看门狗 0正常 1异常 2未连接
/// </summary>
public static int MoldingMachineWatchDog = 2;
/// <summary>
/// 上一个开炼机看门狗状态
/// </summary>
public int LastOpenMixWatchDogNum = -1;
/// <summary>
/// 上一个成型机看门狗状态
/// </summary>
public int LastMoldingMachineWatchDogNum = -1;
/// <summary>
/// 看门狗计时器
/// </summary>
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
/// </summary>
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);
}
}
/// <summary>
/// PLC看门狗状态判断
/// </summary>
/// <param name="WatchDogPoint">看门狗点位</param>
/// <returns></returns>
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;
//}
}
}
}

@ -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)
{

Loading…
Cancel
Save