yi eason 3 år sedan
förälder
incheckning
4ea0564862

+ 2 - 0
RailLocalMeter/App.config

@@ -97,5 +97,7 @@
 		<add key="sleepUploadTime" value="10000"/>
 		<!--图片多久未上传则移送到bak文件夹的时间,这里配置的是小时,正常来说网络异常应该处理几小时足够了-->
 		<add key="imgTimeOut" value="5"/>
+		<!--重量变化大于10t时认为是下一个车-->
+		<add key="changeWgt" value="10"/>
 	</appSettings>
 </configuration>

+ 27 - 10
RailLocalMeter/OptionCls/RfidRailWayNo.cs

@@ -69,6 +69,20 @@ namespace RailLocalMeter
             mThread.Start();
         }
 
+        private byte[] ReadPort(byte[] sendData) 
+        {
+            serialPort1.Write(sendData, 0, sendData.Length);
+
+            DateTime dt = DateTime.Now;
+            Thread.Sleep(50);
+            byte[] recData = new byte[serialPort1.BytesToRead];
+            serialPort1.Read(recData, 0, recData.Length);
+
+            return recData;
+        }
+
+
+
         /// <summary>
         /// 扫码信息读取
         /// </summary>
@@ -81,18 +95,21 @@ namespace RailLocalMeter
                 {
                     lock (obj)
                     {
-                        Thread.Sleep(100);
-                        string strtmp = "";
-                        if (serialPort1.BytesToRead > 0)
+                        byte[] bt = ReadPort(new byte[] { 0x11 });
+                        string strtmp = System.Text.Encoding.UTF8.GetString(bt);
+
+                        if (!string.IsNullOrEmpty(strtmp))
                         {
-                            strtmp = serialPort1.ReadExisting();
-                        }
-                        strtmp = strtmp.Split(new char[] { '\r' })[0];
-                        if (strtmp != "")
-                        { 
-                            if (CacleCls.rfidCarNo != strtmp) 
+                            if ((strtmp.IndexOf("T") == 0 || strtmp.IndexOf("Q") == 0 || strtmp.IndexOf("G") == 0) && strtmp.Length > 14)
+                            {
+                                if (CacleCls.rfidCarNo != strtmp && strtmp.Trim() != "")
+                                {
+                                    CacleCls.rfidCarNo = strtmp;
+                                    lg.WriteLog(LogType.RfidLoc, $"获取并提供给界面的读卡器数据:{strtmp}");
+                                }
+                            }
+                            else 
                             {
-                                CacleCls.rfidCarNo = strtmp;
                                 lg.WriteLog(LogType.RfidLoc, $"读卡器读取的数据:{strtmp}");
                             }
                         }

+ 4 - 0
RailLocalMeter/PbCls/AppConfigCache.cs

@@ -269,5 +269,9 @@ namespace RailLocalMeter
         /// </summary>
         public static string plcStart = ConfigurationManager.AppSettings["plcStart"].ToString();
 
+        /// <summary>
+        /// 重量变化大于该值时认为车辆下磅了
+        /// </summary>
+        public static int changeWgt = Convert.ToInt32(ConfigurationManager.AppSettings["changeWgt"].ToString()) * 1000; 
     }
 }

+ 9 - 9
RailLocalMeter/frmMain.Designer.cs

@@ -2548,7 +2548,7 @@ namespace RailLocalMeter
             this.tableLayoutPanel7.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 60F));
             this.tableLayoutPanel7.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 150F));
             this.tableLayoutPanel7.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 60F));
-            this.tableLayoutPanel7.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 76F));
+            this.tableLayoutPanel7.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 81F));
             this.tableLayoutPanel7.Controls.Add(this.lbPointName, 1, 0);
             this.tableLayoutPanel7.Controls.Add(this.txtCarNo, 3, 0);
             this.tableLayoutPanel7.Controls.Add(this.lbPntName, 0, 0);
@@ -2574,14 +2574,14 @@ namespace RailLocalMeter
             this.lbPointName.Location = new System.Drawing.Point(86, 1);
             this.lbPointName.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.lbPointName.Name = "lbPointName";
-            this.lbPointName.Size = new System.Drawing.Size(506, 36);
+            this.lbPointName.Size = new System.Drawing.Size(501, 36);
             this.lbPointName.TabIndex = 3;
             this.lbPointName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
             // 
             // txtCarNo
             // 
             this.txtCarNo.Font = new System.Drawing.Font("宋体", 16F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.txtCarNo.Location = new System.Drawing.Point(661, 3);
+            this.txtCarNo.Location = new System.Drawing.Point(656, 3);
             this.txtCarNo.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.txtCarNo.Name = "txtCarNo";
             this.txtCarNo.Size = new System.Drawing.Size(144, 32);
@@ -2610,7 +2610,7 @@ namespace RailLocalMeter
             this.label2.Dock = System.Windows.Forms.DockStyle.Fill;
             this.label2.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.label2.ForeColor = System.Drawing.Color.Blue;
-            this.label2.Location = new System.Drawing.Point(601, 1);
+            this.label2.Location = new System.Drawing.Point(596, 1);
             this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.label2.Name = "label2";
             this.label2.Size = new System.Drawing.Size(52, 36);
@@ -2625,7 +2625,7 @@ namespace RailLocalMeter
             this.label1.Dock = System.Windows.Forms.DockStyle.Fill;
             this.label1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.label1.ForeColor = System.Drawing.Color.Blue;
-            this.label1.Location = new System.Drawing.Point(813, 1);
+            this.label1.Location = new System.Drawing.Point(808, 1);
             this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.label1.Name = "label1";
             this.label1.Size = new System.Drawing.Size(52, 36);
@@ -2636,7 +2636,7 @@ namespace RailLocalMeter
             // pbLineOn
             // 
             this.pbLineOn.Image = ((System.Drawing.Image)(resources.GetObject("pbLineOn.Image")));
-            this.pbLineOn.Location = new System.Drawing.Point(873, 4);
+            this.pbLineOn.Location = new System.Drawing.Point(868, 4);
             this.pbLineOn.Name = "pbLineOn";
             this.pbLineOn.Size = new System.Drawing.Size(39, 30);
             this.pbLineOn.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
@@ -2646,10 +2646,10 @@ namespace RailLocalMeter
             // plImgShow
             // 
             this.plImgShow.Controls.Add(this.pictureShow);
-            this.plImgShow.Location = new System.Drawing.Point(268, 487);
+            this.plImgShow.Location = new System.Drawing.Point(268, 405);
             this.plImgShow.Margin = new System.Windows.Forms.Padding(2);
             this.plImgShow.Name = "plImgShow";
-            this.plImgShow.Size = new System.Drawing.Size(900, 500);
+            this.plImgShow.Size = new System.Drawing.Size(1132, 582);
             this.plImgShow.TabIndex = 46;
             this.plImgShow.Visible = false;
             // 
@@ -2660,7 +2660,7 @@ namespace RailLocalMeter
             this.pictureShow.Location = new System.Drawing.Point(0, 0);
             this.pictureShow.Margin = new System.Windows.Forms.Padding(2);
             this.pictureShow.Name = "pictureShow";
-            this.pictureShow.Size = new System.Drawing.Size(900, 500);
+            this.pictureShow.Size = new System.Drawing.Size(1132, 582);
             this.pictureShow.TabIndex = 2;
             this.pictureShow.TabStop = false;
             this.pictureShow.DoubleClick += new System.EventHandler(this.pictureShow_DoubleClick);

+ 34 - 5
RailLocalMeter/frmMain.cs

@@ -94,6 +94,7 @@ namespace RailLocalMeter
 
         private void frmMain_Load(object sender, EventArgs e)
         {
+            txtMsgInfo.Focus();
             if (AppConfigCache.openCom == "0")
             {
                 rfid.StartThreadSweep(out string msg);
@@ -256,16 +257,40 @@ namespace RailLocalMeter
                         ucWeightT1.setStable(CacleCls.isWd != 1 ? true : false);
                         ucWeightT1.setExceed(CacleCls.weight > AppConfigCache.maxRange * 1000 ? false : true);
 
+                        if (isMeasureSuccess && Math.Abs(CacleCls.lockWgt - CacleCls.weight) > AppConfigCache.changeWgt)
+                        {
+                            isMeasureSuccess = false;
+                            txtCarNo.Text = "";
+                            CacleCls.rfidCarNo = "";
+                            CacleCls.lockCarNo = "";
+                            CacleCls.carType = "";
+                            txtMsgInfo.Focus();
+
+                            BindTable<MeterWorkRailwayActFirst>(ultraGridFirst, dataTableFirst, "firstx");
+
+                            //查询预报数据
+                            BindTable<PreRailwayScale>(ultraGridPre, dataTablePre, "prex");
+                        }
+                        /*
+                        if (isMeasureSuccess && CacleCls.lockCarNo != CacleCls.rfidCarNo && !string.IsNullOrEmpty(CacleCls.rfidCarNo)) 
+                        {
+                            txtCarNo.Text = "";
+                        }
+                        //*/
                         if (txtCarNo.Text.Trim() != "" && !txtCarNo.Focused)
                         {
                             CacleCls.lockCarNo = txtCarNo.Text.Trim();
                         }
                         else if (!string.IsNullOrEmpty(CacleCls.rfidCarNo))
                         {
-                            if (CacleCls.rfidCarNo.Length > 14) 
+                            if (CacleCls.rfidCarNo.Length > 14)
                             {
-                                CacleCls.lockCarNo = CacleCls.rfidCarNo.Substring(7, 7);
-                                CacleCls.carType = CacleCls.rfidCarNo.Substring(1, 5).Trim().ToUpper();
+                                string strRailNo = CacleCls.rfidCarNo.Substring(7, 7);
+                                if (strRailNo.Trim().Length == 7)
+                                {
+                                    CacleCls.lockCarNo = strRailNo;
+                                    CacleCls.carType = CacleCls.rfidCarNo.Substring(1, 5).Trim().ToUpper();
+                                }
                             }
                         }
 
@@ -309,6 +334,7 @@ namespace RailLocalMeter
                             #region 如果是自动计量
                             if (!CacleCls.isLock && !CacleCls.isJg && CacleCls.btnState == "1" && CacleCls.isWd == 0)
                             {
+                                /*
                                 if (string.IsNullOrEmpty(CacleCls.lockCarNo)) 
                                 {
                                     txtMsgInfo.Text = "车号未识别";
@@ -317,6 +343,7 @@ namespace RailLocalMeter
                                     return;
                                 }
 
+                                
                                 if (CacleCls.lockCarNo.Length != 7) 
                                 {
                                     txtMsgInfo.Text = "车号不为7位";
@@ -324,8 +351,9 @@ namespace RailLocalMeter
                                     led_controler?.setStaticLineMsg(AppConfigCache.ledIp, "车号不为7位");
                                     return;
                                 }
+                                //*/
 
-                                    //重量最后一位不为0也是超量程
+                                //重量最后一位不为0也是超量程
                                 if ((AppConfigCache.maxRange * 1000 < CacleCls.weight) || CacleCls.weight.ToString().Substring(CacleCls.weight.ToString().Length - 1, 1) != "0")
                                 {
                                     //超量程
@@ -400,6 +428,7 @@ namespace RailLocalMeter
                                 txtGroess.Text = "";
                                 txtTare.Text = "";
                                 txtNet.Text = "";
+                                txtMsgInfo.Focus();
 
                                 iError = 33;
                                 //释放一次内存
@@ -1000,7 +1029,7 @@ namespace RailLocalMeter
                 case "firstWait":
                     if (CacleCls.serverFlag)
                     {
-                        rmWaitFirstList = firstService.getWaitSubmitBySpotNo(new MeterWorkRailwayActFirst { baseSpotNo = AppConfigCache.pointNo, flag = "1", createTime1 = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss"), createTime2 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") });
+                        rmWaitFirstList = firstService.getWaitSubmitBySpotNo(new MeterWorkRailwayActFirst { baseSpotNo = AppConfigCache.pointNo, flag = "1", startTime = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss"), endTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") });
                         if (rmWaitFirstList.Succeed)
                         {
                             lm = rmWaitFirstList.Data as List<T>;