Quellcode durchsuchen

设备状态修改

WIN-GH9CEESPLTB\Administrator vor 1 Monat
Ursprung
Commit
35270f854b

+ 7 - 0
MainForm/ClassFile/XiaomiAPI_IOT/XiaomiDeviceState.cs

@@ -39,4 +39,11 @@ namespace MainForm.ClassFile.XiaomiAPI
         /// </summary>
         /// </summary>
         Alarm = 7,
         Alarm = 7,
     }
     }
+
+
+    public class XiaomiDeviceStateData
+    {
+        public XiaomiDeviceState left { get; set; } = 0;
+        public XiaomiDeviceState right { get; set; } = 0;
+    }
 }
 }

+ 34 - 0
MainForm/FaForm/Form_Home.Designer.cs

@@ -79,6 +79,8 @@
             this.colTime = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.colTime = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.colMessage = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.colMessage = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.imageListState = new System.Windows.Forms.ImageList(this.components);
             this.imageListState = new System.Windows.Forms.ImageList(this.components);
+            this.uiLabel1 = new Sunny.UI.UILabel();
+            this.uiLabel3 = new Sunny.UI.UILabel();
             this.panel1.SuspendLayout();
             this.panel1.SuspendLayout();
             this.groupBox3.SuspendLayout();
             this.groupBox3.SuspendLayout();
             this.panel2.SuspendLayout();
             this.panel2.SuspendLayout();
@@ -124,6 +126,8 @@
             // 
             // 
             // groupBox3
             // groupBox3
             // 
             // 
+            this.groupBox3.Controls.Add(this.uiLabel3);
+            this.groupBox3.Controls.Add(this.uiLabel1);
             this.groupBox3.Controls.Add(this.lblDeviceStates);
             this.groupBox3.Controls.Add(this.lblDeviceStates);
             this.groupBox3.Controls.Add(this.uiLabel2);
             this.groupBox3.Controls.Add(this.uiLabel2);
             this.groupBox3.Controls.Add(this.txt_CurSupplierCode);
             this.groupBox3.Controls.Add(this.txt_CurSupplierCode);
@@ -673,6 +677,34 @@
             this.imageListState.Images.SetKeyName(1, "light_green.png");
             this.imageListState.Images.SetKeyName(1, "light_green.png");
             this.imageListState.Images.SetKeyName(2, "light_red.png");
             this.imageListState.Images.SetKeyName(2, "light_red.png");
             // 
             // 
+            // uiLabel1
+            // 
+            this.uiLabel1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+            this.uiLabel1.Font = new System.Drawing.Font("宋体", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.uiLabel1.ForeColor = System.Drawing.SystemColors.InfoText;
+            this.uiLabel1.Location = new System.Drawing.Point(976, 106);
+            this.uiLabel1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.uiLabel1.Name = "uiLabel1";
+            this.uiLabel1.Size = new System.Drawing.Size(177, 50);
+            this.uiLabel1.TabIndex = 98;
+            this.uiLabel1.Text = "设备状态:";
+            this.uiLabel1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
+            this.uiLabel1.Visible = false;
+            // 
+            // uiLabel3
+            // 
+            this.uiLabel3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+            this.uiLabel3.Font = new System.Drawing.Font("宋体", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.uiLabel3.ForeColor = System.Drawing.Color.Blue;
+            this.uiLabel3.Location = new System.Drawing.Point(1134, 106);
+            this.uiLabel3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.uiLabel3.Name = "uiLabel3";
+            this.uiLabel3.Size = new System.Drawing.Size(261, 50);
+            this.uiLabel3.TabIndex = 99;
+            this.uiLabel3.Text = "未初始状态";
+            this.uiLabel3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
+            this.uiLabel3.Visible = false;
+            // 
             // Form_Home
             // Form_Home
             // 
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F);
             this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F);
@@ -769,5 +801,7 @@
         private System.Windows.Forms.PictureBox picAgvMqtt;
         private System.Windows.Forms.PictureBox picAgvMqtt;
         private Sunny.UI.UILabel lblDeviceStates;
         private Sunny.UI.UILabel lblDeviceStates;
         private Sunny.UI.UILabel uiLabel2;
         private Sunny.UI.UILabel uiLabel2;
+        private Sunny.UI.UILabel uiLabel3;
+        private Sunny.UI.UILabel uiLabel1;
     }
     }
 }
 }

+ 62 - 5
MainForm/FaForm/Form_Home.cs

@@ -122,7 +122,8 @@ namespace MainForm
         /// <summary>
         /// <summary>
         /// 单机用-设备状态
         /// 单机用-设备状态
         /// </summary>
         /// </summary>
-        XiaomiDeviceState xmDeviceState = XiaomiDeviceState.Uninitialized;
+        //XiaomiDeviceState xmDeviceState = XiaomiDeviceState.Uninitialized;
+        XiaomiDeviceStateData xmDeviceStateData=new XiaomiDeviceStateData();
 
 
         #endregion 变量
         #endregion 变量
 
 
@@ -639,6 +640,9 @@ namespace MainForm
         private string _DeviceStates = "未知状态";
         private string _DeviceStates = "未知状态";
         private string _DeviceStates_Old = "未知状态";
         private string _DeviceStates_Old = "未知状态";
 
 
+        private string _DeviceStates2 = "未知状态";
+        private string _DeviceStates_Old2 = "未知状态";
+
         /// <summary>
         /// <summary>
         /// 获取设备报警数据与获取设备运行信息
         /// 获取设备报警数据与获取设备运行信息
         /// </summary>
         /// </summary>
@@ -668,8 +672,8 @@ namespace MainForm
                         {
                         {
                             if (plcEIP.IsConnected)
                             if (plcEIP.IsConnected)
                             {
                             {
-                                #region 主页展示设备运行状态并上传到IOT中
-                                switch (xmDeviceState)
+                                #region 主页展示设备运行状态并上传到IOT中,有双工位left就是左工位,没有双工位left就是单工位
+                                switch (xmDeviceStateData.left)
                                 {
                                 {
                                     case XiaomiDeviceState.Uninitialized:  // 未初始化状态(未初始状态,需先初始化装备才能运行)
                                     case XiaomiDeviceState.Uninitialized:  // 未初始化状态(未初始状态,需先初始化装备才能运行)
                                         _DeviceStates = "未初始化状态";
                                         _DeviceStates = "未初始化状态";
@@ -703,7 +707,7 @@ namespace MainForm
 
 
                                 if (!_DeviceStates.Equals(_DeviceStates_Old))
                                 if (!_DeviceStates.Equals(_DeviceStates_Old))
                                 {
                                 {
-                                    var iotResult = SaveDeviceStateData(stationNameStr, xmDeviceState);  // 上传+保存
+                                    var iotResult = SaveDeviceStateData(stationNameStr, xmDeviceStateData.left,"left");  // 上传+保存
                                     if (iotResult.Item1 == 1)
                                     if (iotResult.Item1 == 1)
                                     {
                                     {
                                         _DeviceStates_Old = _DeviceStates;
                                         _DeviceStates_Old = _DeviceStates;
@@ -712,7 +716,60 @@ namespace MainForm
                                     else
                                     else
                                         AddMessage_Station(stationNameStr, LogType.Info, stationNameStr + $"_上传设备状态到Iot失败!报错信息:[{iotResult.Item1}]_{iotResult.Item2}");
                                         AddMessage_Station(stationNameStr, LogType.Info, stationNameStr + $"_上传设备状态到Iot失败!报错信息:[{iotResult.Item1}]_{iotResult.Item2}");
                                 }
                                 }
+
                                 #endregion 主页展示设备运行状态并上传到IOT中
                                 #endregion 主页展示设备运行状态并上传到IOT中
+
+
+                                #region 右工位
+                                if (GlobalContext.IsUsePLC3 || GlobalContext.IsUsePLC7)
+                                {
+                                    switch (xmDeviceStateData.right)
+                                    {
+                                        case XiaomiDeviceState.Uninitialized:  // 未初始化状态(未初始状态,需先初始化装备才能运行)
+                                            _DeviceStates2 = "未初始化状态";
+                                            lblDeviceStates.Text = _DeviceStates2;
+                                            break;
+                                        case XiaomiDeviceState.Initializing:   // 初始化状态(初始化进行中)
+                                            _DeviceStates2 = "初始化状态";
+                                            lblDeviceStates.Text = _DeviceStates2;
+                                            break;
+                                        case XiaomiDeviceState.Initialized:    // 初始化完成状态(初始化完成)
+                                            _DeviceStates2 = "初始化完成状态";
+                                            lblDeviceStates.Text = _DeviceStates2;
+                                            break;
+                                        case XiaomiDeviceState.Running:        // 运行状态(正常运行中)
+                                            _DeviceStates2 = "运行状态";
+                                            lblDeviceStates.Text = _DeviceStates2;
+                                            break;
+                                        case XiaomiDeviceState.Paused:         // 暂停状态(设备运行中人工操作暂停,进入此状态)
+                                            _DeviceStates2 = "暂停状态";
+                                            lblDeviceStates.Text = _DeviceStates2;
+                                            break;
+                                        case XiaomiDeviceState.Fault:          // 故障状态(发生故障后进入此状态,同时停止运行)
+                                            _DeviceStates2 = "故障状态";
+                                            lblDeviceStates.Text = _DeviceStates2;
+                                            break;
+                                        case XiaomiDeviceState.Alarm:          // 警报状态(产生报警后进入此状态,同时停止运行)
+                                            _DeviceStates2 = "警报状态";
+                                            lblDeviceStates.Text = _DeviceStates2;
+                                            break;
+                                    }
+
+                                    if (!_DeviceStates2.Equals(_DeviceStates_Old2))
+                                    {
+                                        var iotResult = SaveDeviceStateData(stationNameStr, xmDeviceStateData.left,"right");  // 上传+保存
+                                        if (iotResult.Item1 == 1)
+                                        {
+                                            _DeviceStates_Old2 = _DeviceStates2;
+                                            AddMessage_Station(stationNameStr, LogType.Info, stationNameStr + $"_上传设备状态到Iot成功!");
+                                        }
+                                        else
+                                            AddMessage_Station(stationNameStr, LogType.Info, stationNameStr + $"_上传设备状态到Iot失败!报错信息:[{iotResult.Item1}]_{iotResult.Item2}");
+                                    }
+                                }
+                                
+                                #endregion 右工位
+
                             }
                             }
                         }
                         }
                     }
                     }
@@ -1956,7 +2013,7 @@ namespace MainForm
                             //richTextBox1.AppendText("\n" + "读取成功");
                             //richTextBox1.AppendText("\n" + "读取成功");
                             //设备状态
                             //设备状态
                             int xmDeviceStateInt = stPLC_MesData.iotData.machineState;
                             int xmDeviceStateInt = stPLC_MesData.iotData.machineState;
-                            xmDeviceState = (xmDeviceStateInt < 0 || xmDeviceStateInt > 7) ? XiaomiDeviceState.Unknown : (XiaomiDeviceState)xmDeviceStateInt;
+                            xmDeviceStateData.left = (xmDeviceStateInt < 0 || xmDeviceStateInt > 7) ? XiaomiDeviceState.Unknown : (XiaomiDeviceState)xmDeviceStateInt;
 
 
                             s1PLCData["a1OEEPartNo"] = stPLC_MesData.BarcodeSet.strProductBarcode;  // 物料码(物料码还未绑定载具SN时必填)
                             s1PLCData["a1OEEPartNo"] = stPLC_MesData.BarcodeSet.strProductBarcode;  // 物料码(物料码还未绑定载具SN时必填)
                             s1PLCData["a1OEEVehicleCode"] = stPLC_MesData.BarcodeSet.strCarrierBarcode;  // 载具SN
                             s1PLCData["a1OEEVehicleCode"] = stPLC_MesData.BarcodeSet.strCarrierBarcode;  // 载具SN

Datei-Diff unterdrückt, da er zu groß ist
+ 8029 - 8317
MainForm/FaForm/Form_Home.resx


+ 3 - 2
MainForm/FaForm/Form_Home_SaveData.cs

@@ -729,10 +729,11 @@ namespace MainForm
         /// </summary>
         /// </summary>
         /// <param name="stationNameStr">工站信息</param>
         /// <param name="stationNameStr">工站信息</param>
         /// <param name="deviceState">设备状态</param>
         /// <param name="deviceState">设备状态</param>
+        /// <param name="flag">左右工位标识</param>
         /// <param name="fault_code">故障编码</param>
         /// <param name="fault_code">故障编码</param>
         /// <param name="fault_tm">故障发⽣时间</param>
         /// <param name="fault_tm">故障发⽣时间</param>
         /// <returns>上位机发送1代表OK;2代表上传客户MES失败;3代表上位机保存数据失败;4代表上位机报警;</returns>
         /// <returns>上位机发送1代表OK;2代表上传客户MES失败;3代表上位机保存数据失败;4代表上位机报警;</returns>
-        public (int, string) SaveDeviceStateData(string stationNameStr, XiaomiDeviceState deviceState, string fault_code = "A40000", string fault_tm = "")
+        public (int, string) SaveDeviceStateData(string stationNameStr, XiaomiDeviceState deviceState,string flag, string fault_code = "A40000", string fault_tm = "")
         {
         {
             int result = 0;
             int result = 0;
             string msg = "";
             string msg = "";
@@ -752,7 +753,7 @@ namespace MainForm
                         request.station = GlobalContext.S2_station;    // 工位ID(可配置)
                         request.station = GlobalContext.S2_station;    // 工位ID(可配置)
                     if (GlobalContext.IsUsePLC3)
                     if (GlobalContext.IsUsePLC3)
                         request2.left.station = GlobalContext.s3_1_station;    // 工位ID(可配置)
                         request2.left.station = GlobalContext.s3_1_station;    // 工位ID(可配置)
-                        request2.left.station = GlobalContext.s3_2_station;  // ⼯位ID(可配置)
+                        request2.right.station = GlobalContext.s3_2_station;  // ⼯位ID(可配置)
                     if (GlobalContext.IsUsePLC4)
                     if (GlobalContext.IsUsePLC4)
                         request.station = GlobalContext.s4_station;    // 工位ID(可配置)
                         request.station = GlobalContext.s4_station;    // 工位ID(可配置)
                     if (GlobalContext.IsUsePLC5)
                     if (GlobalContext.IsUsePLC5)