From 9a39c7926a855b8b71f753c6fc50e704890c54a7 Mon Sep 17 00:00:00 2001
From: lu <99954486@qq.com>
Date: 星期五, 09 五月 2025 12:48:12 +0800
Subject: [PATCH] 工序采集
---
DevApp/Gs.DevApp/packages.config | 1
DevApp/Gs.DevApp/XtraForm1.Designer.cs | 42 ++--
DevApp/Gs.DevApp/Gs.DevApp.csproj | 3
DevApp/Gs.DevApp/App.config | 4
DevApp/Gs.DevApp/Program.cs | 4
DevApp/Gs.DevApp/XtraForm1.cs | 166 +++++++++++++++-
DevApp/Gs.DevApp/DevFrm/Work/Frm_Work01.cs | 347 +++++++++++++++++++++++++++++++---
7 files changed, 493 insertions(+), 74 deletions(-)
diff --git a/DevApp/Gs.DevApp/App.config b/DevApp/Gs.DevApp/App.config
index c2dd903..4a5b59e 100644
--- a/DevApp/Gs.DevApp/App.config
+++ b/DevApp/Gs.DevApp/App.config
@@ -28,8 +28,8 @@
</assemblyBinding>
</runtime>
<appSettings>
- <add key="WebApiUrl" value="http://localhost:5263/" />
- <!--<add key="WebApiUrl" value="http://192.168.1.145:81/" />-->
+ <!--<add key="WebApiUrl" value="http://localhost:5263/" />-->
+ <add key="WebApiUrl" value="http://192.168.1.145:81/" />
<add key="LogPath" value="logs" />
<add key="ProductName" value="G-MES V2.0" />
<add key="PageSize" value="50" />
diff --git a/DevApp/Gs.DevApp/DevFrm/Work/Frm_Work01.cs b/DevApp/Gs.DevApp/DevFrm/Work/Frm_Work01.cs
index 105ff5e..1252990 100644
--- a/DevApp/Gs.DevApp/DevFrm/Work/Frm_Work01.cs
+++ b/DevApp/Gs.DevApp/DevFrm/Work/Frm_Work01.cs
@@ -1,36 +1,53 @@
-锘縰sing DevExpress.Utils.MVVM.Services;
+锘縰sing DevExpress.XtraGrid.Columns;
using Gs.DevApp.Entity;
using Gs.DevApp.ToolBox;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
+using System.Collections.Generic;
using System.Data;
+using System.Dynamic;
+using System.IO;
+using System.Text;
using System.Windows.Forms;
+using static DevExpress.XtraPrinting.Native.ExportOptionsPropertiesNames;
namespace Gs.DevApp.DevFrm.Work
{
public partial class Frm_Work01 : DevExpress.XtraEditors.XtraForm
{
string _webServiceName = "WorkCollect/";
- string fGx = "";
- string fBc = "";
+ string dianJianPath = "";//鐢垫鍙栧�艰矾寰�
string goodTag = "鈭�";
string badTag = "脳";
+ string fGxTouRu = "G001:鎶曞叆";
+ string fGxDianJian = "G002:鐢垫";
+ string fGxShouJian = "G003:姘存";
+ string fGxZhongJian = "G004:缁堟";
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="_fGx">宸ュ簭</param>
+ /// <param name="_fBc">鐝</param>
public Frm_Work01(string _fGx, string _fBc)
{
InitializeComponent();
- this.fGx = _fGx;
- this.fBc = _fBc;
- this.Text = "宸ュ簭閲囬泦 - " + fGx + " - " + fBc;
- txt_gx.Text = fGx;
- txt_bc.Text = fBc;
+ txt_gx.Text = _fGx;
+ txt_bc.Text = _fBc;
+ this.Text = "宸ュ簭閲囬泦 - " + _fGx + " - " + _fBc;
+ if (!getConfig())
+ {
+ Gs.DevApp.ToolBox.MsgHelper.ShowError("璇诲彇閰嶇疆鏂囦欢澶辫触锛岃鑱旂郴绠$悊鍛橈紒");
+ }
+ addColumn();
txt_barCode.KeyDown += (s, e) =>
{
- if (e.KeyCode == Keys.Enter) { getModel("", goodTag); };
+ if (e.KeyCode == Keys.Enter) { addModel(goodTag); };
};
btnGood.Click += (s, e) =>
{
- getModel("", goodTag);
+ addModel(goodTag);
};
btnBad.Click += (s, e) =>
{
@@ -52,22 +69,141 @@
vm.Show();
}
else
- getModel("", badTag, _txt);
+ addModel(badTag, _txt);
};
frm.ShowDialog();
};
}
-
+ /// <summary>
+ /// 鍏堣鍙栭厤缃�
+ /// </summary>
+ /// <returns></returns>
+ private bool getConfig()
+ {
+ string _where = " and 1=1 and defect_code='7001'";
+ var pgq = new PageQueryModel(1, 999999, "a.defect_code", "asc", "", _where);
+ var json = JsonConvert.SerializeObject(pgq);
+ try
+ {
+ var strReturn = UtilityHelper.HttpPost("", "MesDefectCodeManager/GetListPage", json);
+ var dd = UtilityHelper.ReturnToTablePage(strReturn);
+ var dt = dd.rtnData.list;
+ if (dt != null && dt.Rows.Count > 0)
+ {
+ dianJianPath = dt.Rows[0]["defectName"].ToString();
+ return true;
+ }
+ return false;
+ }
+ catch (Exception ex)
+ {
+ MsgHelper.Warning("鎻愮ず锛�" + ex.Message);
+ return false;
+ }
+ }
/// <summary>
- ///
+ /// 璇诲彇瀹炰綋
/// </summary>
- /// <param name="_checkVal">妫�娴嬪��</param>
- /// <param name="_checkResult">妫�娴嬬粨鏋�</param>
- /// <param name="_badReson">涓嶈壇鍘熷洜</param>
- /// <param name="_inBz">澶囨敞</param>
- private void getModel(string _checkVal, string _checkResult, string _badReson = "", string _inBz = "")
+ /// <param name="_barCode"></param>
+ /// <param name="_checkResult"></param>
+ /// <param name="_badReson"></param>
+ /// <returns></returns>
+ private dynamic getObj(string _barCode, string _checkResult, string _badReson = "")
+ {
+ dynamic _obj = new ExpandoObject();
+ _obj.barCode = _barCode;
+ _obj.checkResult = _checkResult;//妫�娴嬬粨鏋�
+ _obj.processNo = txt_gx.Text.Trim();//宸ュ簭
+ _obj.banCi = txt_bc.Text.Trim();//鐝
+ _obj.gongWei = txt_gw.Text.Trim();//宸ヤ綅
+ _obj.badReson = _badReson.Trim();//涓嶈壇鍘熷洜
+ if (txt_gx.Text.Trim() == fGxTouRu)
+ {
+ return _obj;
+ }
+ if (txt_gx.Text.Trim() == fGxDianJian)
+ {
+ string TM = "";
+ string JD = "";
+ string JY = "";
+ string JN = "";
+ string XL = "";
+ string GV = "";
+ string JDV = "";
+ string JYV = "";
+ string JNV = "";
+ string XLV = "";
+ string GVV = "";
+ string myStr = File.ReadAllText(dianJianPath, Encoding.Default);
+ if (myStr == "")
+ {
+ return null;
+ }
+ File.WriteAllText(dianJianPath, "");
+ JArray dsTemp = JArray.Parse(myStr);
+ foreach (var ss in dsTemp) //鏌ユ壘鏌愪釜瀛楁涓庡��
+ {
+ TM = (((JObject)ss)["TiaoMa"] == null) ? "" : ((JObject)ss)["TiaoMa"].ToString();
+ JD = (((JObject)ss)["JieDi"] == null) ? "" : ((JObject)ss)["JieDi"]["state"].ToString();
+ JY = (((JObject)ss)["JueYuan"] == null) ? "" : ((JObject)ss)["JueYuan"]["state"].ToString();
+ JN = (((JObject)ss)["JiaoNai"] == null) ? "" : ((JObject)ss)["JiaoNai"]["state"].ToString();
+ XL = (((JObject)ss)["XieLou"] == null) ? "" : ((JObject)ss)["XieLou"]["state"].ToString();
+ GV = (((JObject)ss)["GongLv"] == null) ? "" : ((JObject)ss)["GongLv"]["state"].ToString();
+ JDV = (((JObject)ss)["JieDi"] == null) ? "" : ((JObject)ss)["JieDi"]["value"].ToString().Replace(" ", ", ");
+ JYV = (((JObject)ss)["JueYuan"] == null) ? "" : ((JObject)ss)["JueYuan"]["value"].ToString().Replace(" ", ", ");
+ JNV = (((JObject)ss)["JiaoNai"] == null) ? "" : ((JObject)ss)["JiaoNai"]["value"].ToString().Replace(" ", ", ");
+ XLV = (((JObject)ss)["XieLou"] == null) ? "" : ((JObject)ss)["XieLou"]["value"].ToString().Replace(" ", ", ");
+ GVV = (((JObject)ss)["GongLv"] == null) ? "" : ((JObject)ss)["GongLv"]["value"].ToString().Replace(" ", ", ");
+ }
+ _obj.t001 = TM;
+ _obj.t002 = JD;
+ _obj.t003 = JY;
+ _obj.t004 = JN;
+ _obj.t005 = XL;
+ _obj.t006 = GV;
+ _obj.t007 = JDV;
+ _obj.t008 = JYV;
+ _obj.t009 = JNV;
+ _obj.t010 = XLV;
+ _obj.t011 = GVV;
+ return _obj;
+ }
+
+ if (txt_gx.Text.Trim() == fGxShouJian)
+ {
+ string strCsl1 = "strCsl1";
+ string strSw1 = "strSw1";
+ string strCsl2 = "strCsl2";
+ string strSw2 = "strSw2";
+ string strCsl3 = "strCsl3";
+ string strSw3 = "strSw3";
+ string strCsl4 = "strCsl4";
+ string strSw4 = "strSw4";
+ string strCsl5 = "strCsl5";
+ string strSw5 = "strSw5";
+ _obj.t002 = strCsl1;
+ _obj.t003 = strSw1;
+ _obj.t004 = strCsl2;
+ _obj.t005 = strSw2;
+ _obj.t006 = strCsl3;
+ _obj.t007 = strSw3;
+ _obj.t008 = strCsl4;
+ _obj.t009 = strSw4;
+ _obj.t010 = strCsl5;
+ _obj.t011 = strSw5;
+ return _obj;
+ }
+ return null;
+ }
+
+ /// <summary>
+ /// 涓婃姤瀹炰綋
+ /// </summary>
+ /// <param name="_checkResult">鍒ゅ畾缁撴灉</param>
+ /// <param name="_badReson">涓嶈壇鍘熷洜锛屽彲绌�</param>
+ private void addModel(string _checkResult, string _badReson = "")
{
string _barCode = txt_barCode.Text.Trim();
if (string.IsNullOrEmpty(_barCode))
@@ -76,17 +212,13 @@
vm.Show();
return;
}
- var _obj = new
+ dynamic _obj = getObj(_barCode, _checkResult, _badReson);
+ if (_obj == null)
{
- barCode = _barCode,
- inBz = _inBz.Trim(),
- checkVal = _checkVal,
- checkResult = _checkResult,
- processNo = txt_gx.Text.Trim(),//宸ュ簭
- banCi = txt_bc.Text.Trim(),//鐝
- gongWei = txt_gw.Text.Trim(),//宸ヤ綅
- badReson = _badReson.Trim()
- };
+ Toast vm = new Toast(-1, "~璇诲彇鏁版嵁澶辫触锛岃妫�鏌ヨ澶噡");
+ vm.Show();
+ return;
+ }
try
{
string strJson = UtilityHelper.HttpPost("", _webServiceName + "GetModel", JsonConvert.SerializeObject(_obj));
@@ -94,14 +226,14 @@
if (_rtn.rtnCode > 0)
{
dynamic dy = _rtn.rtnData;
- //澶磋〃鍜屾眹鎬�
+ //琛ㄥご鍜屾眹鎬�
UtilityHelper.SetValueByObj(this.layoutMx1.Controls, dy, false);
lbSum1.Text = dy.lbSum1;
lbSum2.Text = dy.lbSum2;
lbSum3.Text = dy.lbSum3;
lbSum4.Text = dy.lbSum4;
prog1.Position = dy.jd;
- //鑹搧
+ //鑹搧鍒楄〃
txt_barCode.ReadOnly = false;
JObject _job = JObject.Parse(strJson);
JArray array = new JArray();
@@ -122,7 +254,7 @@
{
Gs.DevApp.ToolBox.UtilityHelper.SetDefaultTable(gcMx1, gvMx1);
}
- //涓嶈壇鍝�
+ //涓嶈壇鍝佸垪琛�
JArray array2 = new JArray();
foreach (var a in _job["rtnData"]["list2"])
{
@@ -144,7 +276,6 @@
string _msg = _rtn.rtnMsg;
if (!string.IsNullOrEmpty(_msg))
{
-
Toast vm = new Toast((goodTag == "鈭�" ? 1 : -1), _msg);
vm.Show();
};
@@ -161,5 +292,157 @@
vm.Show();
}
}
+
+ /// <summary>
+ /// 澧炲姞鐢垫鍙栨暟鐨勫垪
+ /// </summary>
+ public void addColumn()
+ {
+ List<dynamic> _lst = new List<dynamic>();
+ if (txt_gx.Text.Trim() == fGxDianJian)
+ {
+ _lst.Add(new
+ {
+ ziduan = "t002",
+ wenben = "鎺ュ湴",
+ kejian = true,
+ visibleIndex = 1,
+ });
+ _lst.Add(new
+ {
+ ziduan = "t004",
+ wenben = "浜よ��",
+ kejian = true,
+ visibleIndex = 1,
+ });
+ _lst.Add(new
+ {
+ ziduan = "t005",
+ wenben = "娉勬紡",
+ kejian = true,
+ visibleIndex = 1,
+ });
+ _lst.Add(new
+ {
+ ziduan = "t006",
+ wenben = "鍔熺巼",
+ kejian = true,
+ visibleIndex = 1,
+ });
+ _lst.Add(new
+ {
+ ziduan = "t007",
+ wenben = "鎺ュ湴缁撴灉",
+ kejian = true,
+ visibleIndex = 1,
+ });
+ _lst.Add(new
+ {
+ ziduan = "t009",
+ wenben = "浜よ�愮粨鏋�",
+ kejian = true,
+ visibleIndex = 1,
+ });
+ _lst.Add(new
+ {
+ ziduan = "t010",
+ wenben = "娉勬紡缁撴灉",
+ kejian = true,
+ visibleIndex = 1,
+ });
+
+ _lst.Add(new
+ {
+ ziduan = "t011",
+ wenben = "鍔熺巼缁撴灉",
+ kejian = true,
+ visibleIndex = 1,
+ });
+ }
+ if (txt_gx.Text.Trim() == fGxShouJian)
+ {
+ _lst.Add(new
+ {
+ ziduan = "t002",
+ wenben = "鍑烘按閲�1",
+ kejian = true,
+ visibleIndex = 1,
+ });
+ _lst.Add(new
+ {
+ ziduan = "t003",
+ wenben = "姘存俯1",
+ kejian = true,
+ visibleIndex = 1,
+ });
+ _lst.Add(new
+ {
+ ziduan = "t004",
+ wenben = "鍑烘按閲�2",
+ kejian = true,
+ visibleIndex = 1,
+ });
+ _lst.Add(new
+ {
+ ziduan = "t005",
+ wenben = "姘存俯2",
+ kejian = true,
+ visibleIndex = 1,
+ });
+ _lst.Add(new
+ {
+ ziduan = "t006",
+ wenben = "鍑烘按閲�3",
+ kejian = true,
+ visibleIndex = 1,
+ });
+ _lst.Add(new
+ {
+ ziduan = "t007",
+ wenben = "姘存俯3",
+ kejian = true,
+ visibleIndex = 1,
+ });
+ _lst.Add(new
+ {
+ ziduan = "t008",
+ wenben = "鍑烘按閲�4",
+ kejian = true,
+ visibleIndex = 1,
+ });
+ _lst.Add(new
+ {
+ ziduan = "t009",
+ wenben = "姘存俯4",
+ kejian = true,
+ visibleIndex = 1,
+ });
+
+ _lst.Add(new
+ {
+ ziduan = "t010",
+ wenben = "鍑烘按閲�5",
+ kejian = true,
+ visibleIndex = 1,
+ });
+ _lst.Add(new
+ {
+ ziduan = "t011",
+ wenben = "姘存俯5",
+ kejian = true,
+ visibleIndex = 1,
+ });
+ }
+ foreach (var item in _lst)
+ {
+ GridColumn newColumn = new GridColumn();
+ newColumn.FieldName = item.ziduan; // 璁剧疆涓庢暟鎹簮瀵瑰簲鐨勫瓧娈靛悕
+ newColumn.Caption = item.wenben; // 璁剧疆鍒楃殑鏍囬
+ //newColumn.Visible = item.visibleIndex; // 璁剧疆鍒楁槸鍚﹀彲瑙�
+ newColumn.VisibleIndex = item.visibleIndex; // 璁剧疆鍒楃殑鏄剧ず椤哄簭
+ gvMx1.Columns.Add(newColumn);
+ }
+ }
+
}
}
\ No newline at end of file
diff --git a/DevApp/Gs.DevApp/Gs.DevApp.csproj b/DevApp/Gs.DevApp/Gs.DevApp.csproj
index 38858df..d62c873 100644
--- a/DevApp/Gs.DevApp/Gs.DevApp.csproj
+++ b/DevApp/Gs.DevApp/Gs.DevApp.csproj
@@ -118,6 +118,9 @@
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
+ <Reference Include="NModbus, Version=3.0.81.0, Culture=neutral, processorArchitecture=MSIL">
+ <HintPath>..\packages\NModbus.3.0.81\lib\net46\NModbus.dll</HintPath>
+ </Reference>
<Reference Include="Oracle.ManagedDataAccess, Version=4.122.23.1, Culture=neutral, PublicKeyToken=89b483f429c47342, processorArchitecture=MSIL">
<HintPath>..\packages\Oracle.ManagedDataAccess.23.6.0\lib\net472\Oracle.ManagedDataAccess.dll</HintPath>
</Reference>
diff --git a/DevApp/Gs.DevApp/Program.cs b/DevApp/Gs.DevApp/Program.cs
index 6832ec6..7d213a8 100644
--- a/DevApp/Gs.DevApp/Program.cs
+++ b/DevApp/Gs.DevApp/Program.cs
@@ -38,8 +38,8 @@
/// </summary>
private static void _startLogin()
{
- //Application.Run(new XtraForm1());
- //return;
+ Application.Run(new XtraForm1());
+ return;
CefSettings settings = new CefSettings();
settings.Locale = "zh-CN";
Cef.Initialize(settings);
diff --git a/DevApp/Gs.DevApp/XtraForm1.Designer.cs b/DevApp/Gs.DevApp/XtraForm1.Designer.cs
index 507a269..53a4eb5 100644
--- a/DevApp/Gs.DevApp/XtraForm1.Designer.cs
+++ b/DevApp/Gs.DevApp/XtraForm1.Designer.cs
@@ -28,46 +28,44 @@
/// </summary>
private void InitializeComponent()
{
- this.splitContainerControl1 = new DevExpress.XtraEditors.SplitContainerControl();
- ((System.ComponentModel.ISupportInitialize)(this.splitContainerControl1)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.splitContainerControl1.Panel1)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.splitContainerControl1.Panel2)).BeginInit();
- this.splitContainerControl1.SuspendLayout();
+ this.simpleButton1 = new DevExpress.XtraEditors.SimpleButton();
+ this.simpleButton2 = new DevExpress.XtraEditors.SimpleButton();
this.SuspendLayout();
//
- // splitContainerControl1
+ // simpleButton1
//
- this.splitContainerControl1.Location = new System.Drawing.Point(192, 205);
- this.splitContainerControl1.Name = "splitContainerControl1";
+ this.simpleButton1.Location = new System.Drawing.Point(146, 51);
+ this.simpleButton1.Name = "simpleButton1";
+ this.simpleButton1.Size = new System.Drawing.Size(94, 29);
+ this.simpleButton1.TabIndex = 0;
+ this.simpleButton1.Text = "simpleButton1";
+ this.simpleButton1.Click += new System.EventHandler(this.simpleButton1_Click_1);
//
- // splitContainerControl1.Panel1
+ // simpleButton2
//
- this.splitContainerControl1.Panel1.Text = "Panel1";
- //
- // splitContainerControl1.Panel2
- //
- this.splitContainerControl1.Panel2.Text = "Panel2";
- this.splitContainerControl1.Size = new System.Drawing.Size(200, 100);
- this.splitContainerControl1.TabIndex = 0;
+ this.simpleButton2.Location = new System.Drawing.Point(146, 234);
+ this.simpleButton2.Name = "simpleButton2";
+ this.simpleButton2.Size = new System.Drawing.Size(94, 29);
+ this.simpleButton2.TabIndex = 1;
+ this.simpleButton2.Text = "姘存鎸夐挳";
+ this.simpleButton2.Click += new System.EventHandler(this.simpleButton2_Click);
//
// XtraForm1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 18F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(887, 659);
- this.Controls.Add(this.splitContainerControl1);
+ this.Controls.Add(this.simpleButton2);
+ this.Controls.Add(this.simpleButton1);
this.Name = "XtraForm1";
this.Text = "XtraForm1";
- ((System.ComponentModel.ISupportInitialize)(this.splitContainerControl1.Panel1)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.splitContainerControl1.Panel2)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.splitContainerControl1)).EndInit();
- this.splitContainerControl1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
- private DevExpress.XtraEditors.SplitContainerControl splitContainerControl1;
+ private DevExpress.XtraEditors.SimpleButton simpleButton1;
+ private DevExpress.XtraEditors.SimpleButton simpleButton2;
}
}
\ No newline at end of file
diff --git a/DevApp/Gs.DevApp/XtraForm1.cs b/DevApp/Gs.DevApp/XtraForm1.cs
index ad5953f..8e9c7c2 100644
--- a/DevApp/Gs.DevApp/XtraForm1.cs
+++ b/DevApp/Gs.DevApp/XtraForm1.cs
@@ -1,5 +1,10 @@
-锘縰sing DevExpress.Utils;
+锘縰sing Newtonsoft.Json.Linq;
+using NModbus;
using System;
+using System.Data;
+using System.IO;
+using System.Net.Sockets;
+using System.Text;
namespace Gs.DevApp
{
@@ -10,23 +15,152 @@
InitializeComponent();
}
+ /// <summary>
+ /// 鏄惁绗竴娆℃姇鍏�,0涓虹涓�娆℃姇鍏ワ紝1涓虹淮淇繃鏉ヨ鎶ュ簾鐨�2涓哄凡缁忔姤搴熻繃浜嗙殑锛�3杩斿伐杩囨潵閲嶆姇鐨�4娓呭熬宸ュ崟鐨勬姤搴�
+ /// </summary>
+ private string flagFirst = "0"; //鏄惁绗竴娆℃姇鍏�
- private void simpleButton1_Click(object sender, EventArgs e)
+
+ private void simpleButton1_Click_1(object sender, EventArgs e)
{
- //toastNotificationsManager1 = new ToastNotificationsManager();
- //VanishingMessage vm = new VanishingMessage(System.Drawing.Color.OrangeRed, "鎿嶄綔鎴愭槬鏍戞毊浜戦《鎴存");
- //vm.Show();
- ToolTipControllerShowEventArgs aa = new ToolTipControllerShowEventArgs();
- aa.AllowHtmlText = DefaultBoolean.True;
- aa.Title = "璇︽儏"; //HTML, 绮椾綋
- aa.ToolTip = "浣犲ソ鐖变綘鐨勫厠鏍煎媰"; //鏂
- aa.ShowBeak = true;
- aa.Rounded = true; ////鍦嗚
- aa.RoundRadius = 7; //鍦嗚鐜�
- aa.ToolTipType = ToolTipType.SuperTip; //瓒呯骇鏍峰紡锛屽彲澶氳鎴栨樉绀哄浘鏍�
- aa.ToolTipType = ToolTipType.Standard;//鏍囧噯鏍峰紡锛屽彲鏄剧ず楦熷槾銆�
- aa.IconType = ToolTipIconType.Information; //娑堟伅鍥炬爣
- aa.IconSize = ToolTipIconSize.Small; //澶у浘鏍�
+ AddDianJian();
+ }
+
+ //娣诲姞鐢垫鏁版嵁
+ private string AddDianJian()
+ {
+ string TM = "";
+ string JD = "";
+ string JY = "";
+ string JN = "";
+ string XL = "";
+ string GV = "";
+ string JDV = "";
+ string JYV = "";
+ string JNV = "";
+ string XLV = "";
+ string GVV = "";
+ //if (imaQAB009.EditValue.ToString() != VSLoginInfo.SystemParam["DianJianNo"].ToString())
+ //{
+ // return "";
+ //}
+ //string sql = string.Format(@" select MIG006 from BASMIG(nolock) where MIG001='DianJianQuShu' and MIG003='{0}' and MIG005='Y'", txtDAA042.EditValue.ToString());
+ //DataTable dt = manager.GetDataTable(sql, "tmpBASMIG");
+ //if (dt == null || dt.Rows.Count <= 0)
+ //{
+ // return "";
+ //}
+ try
+ {
+ //FileStream fs = new FileStream(dt.Rows[0][0].ToString(), FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
+ //int fsLen = (int)fs.Length;
+ //byte[] heByte = new byte[fsLen];
+ //fs.Read(heByte, 0, heByte.Length);
+ //string myStr = System.Text.Encoding.Default.GetString(heByte);
+ //fs.Close();
+ string strPath = @"D:\uploadData.txt";
+ string myStr = File.ReadAllText(strPath, Encoding.Default);
+ if (myStr == "")
+ {
+ return "NULL";
+ }
+ File.WriteAllText(strPath, "");
+ JArray dsTemp = JArray.Parse(myStr);
+
+ foreach (var ss in dsTemp) //鏌ユ壘鏌愪釜瀛楁涓庡��
+ {
+ TM = (((JObject)ss)["TiaoMa"] == null) ? "" : ((JObject)ss)["TiaoMa"].ToString();
+ JD = (((JObject)ss)["JieDi"] == null) ? "" : ((JObject)ss)["JieDi"]["state"].ToString();
+ JY = (((JObject)ss)["JueYuan"] == null) ? "" : ((JObject)ss)["JueYuan"]["state"].ToString();
+ JN = (((JObject)ss)["JiaoNai"] == null) ? "" : ((JObject)ss)["JiaoNai"]["state"].ToString();
+ XL = (((JObject)ss)["XieLou"] == null) ? "" : ((JObject)ss)["XieLou"]["state"].ToString();
+ GV = (((JObject)ss)["GongLv"] == null) ? "" : ((JObject)ss)["GongLv"]["state"].ToString();
+ JDV = (((JObject)ss)["JieDi"] == null) ? "" : ((JObject)ss)["JieDi"]["value"].ToString().Replace(" ", ", ");
+ JYV = (((JObject)ss)["JueYuan"] == null) ? "" : ((JObject)ss)["JueYuan"]["value"].ToString().Replace(" ", ", ");
+ JNV = (((JObject)ss)["JiaoNai"] == null) ? "" : ((JObject)ss)["JiaoNai"]["value"].ToString().Replace(" ", ", ");
+ XLV = (((JObject)ss)["XieLou"] == null) ? "" : ((JObject)ss)["XieLou"]["value"].ToString().Replace(" ", ", ");
+ GVV = (((JObject)ss)["GongLv"] == null) ? "" : ((JObject)ss)["GongLv"]["value"].ToString().Replace(" ", ", ");
+
+ Gs.DevApp.ToolBox.LogHelper.Debug("TM", TM);
+ Gs.DevApp.ToolBox.LogHelper.Debug("JD", JD);
+ Gs.DevApp.ToolBox.LogHelper.Debug("JY", JY);
+ Gs.DevApp.ToolBox.LogHelper.Debug("XL", XL);
+ Gs.DevApp.ToolBox.LogHelper.Debug("XLV", XLV);
+ Gs.DevApp.ToolBox.LogHelper.Debug("GVV", GVV);
+ }
+ return "宸查噰闆�";
+ }
+ catch (Exception e)
+ {
+ return "鏂囦欢鎵撳紑澶辫触," + e.Message;
+ }
+ }
+
+ private void simpleButton2_Click(object sender, EventArgs e)
+ {
+ string strCsl1 = "";
+ string strSw1 = "";
+ string strCsl2 = "";
+ string strSw2 = "";
+ string strCsl3 = "";
+ string strSw3 = "";
+ string strCsl4 = "";
+ string strSw4 = "";
+ string strCsl5 = "";
+ string strSw5 = "";
+ string SJJG = "";
+ try//姘存鍙栨暟锛屽悗闈㈣ˉ鍏�
+ {
+ string hostname = "192.168.1.5";
+ ModbusFactory modbusFactory = new ModbusFactory();
+ IModbusMaster master = modbusFactory.CreateMaster(new TcpClient(hostname, 26));
+ master.Transport.ReadTimeout = 10000;
+ master.Transport.Retries = 10000;
+ DataTable dt = new DataTable();
+ //鍙傛暟(鍒嗗埆涓轰粠绔欏湴鍧�,璧峰鍦板潃,闀垮害)
+ byte slaveAddress = byte.Parse(dt.Rows[0][0].ToString());
+ ushort numberOfPoints = ushort.Parse("1");
+ float fsw = 0;
+ DataTable dt1 = new DataTable();
+ ushort[] csl1 = master.ReadHoldingRegisters(slaveAddress, ushort.Parse(dt1.Rows[0]["MIG003"].ToString()), numberOfPoints);
+ strCsl1 = csl1[0].ToString();
+
+ ushort[] sw1 = master.ReadHoldingRegisters(slaveAddress, ushort.Parse(dt1.Rows[1]["MIG003"].ToString()), numberOfPoints);
+ strSw1 = (float.Parse(sw1[0].ToString()) / 10).ToString();
+
+ ushort[] csl2 = master.ReadHoldingRegisters(slaveAddress, ushort.Parse(dt1.Rows[2]["MIG003"].ToString()), numberOfPoints);
+ strCsl2 = csl2[0].ToString();
+
+ ushort[] sw2 = master.ReadHoldingRegisters(slaveAddress, ushort.Parse(dt1.Rows[3]["MIG003"].ToString()), numberOfPoints);
+ strSw2 = (float.Parse(sw2[0].ToString()) / 10).ToString();
+
+ ushort[] csl3 = master.ReadHoldingRegisters(slaveAddress, ushort.Parse(dt1.Rows[4]["MIG003"].ToString()), numberOfPoints);
+ strCsl3 = csl3[0].ToString();
+
+ ushort[] sw3 = master.ReadHoldingRegisters(slaveAddress, ushort.Parse(dt1.Rows[5]["MIG003"].ToString()), numberOfPoints);
+ strSw3 = (float.Parse(sw3[0].ToString()) / 10).ToString();
+
+ ushort[] csl4 = master.ReadHoldingRegisters(slaveAddress, ushort.Parse(dt1.Rows[6]["MIG003"].ToString()), numberOfPoints);
+ strCsl4 = csl4[0].ToString();
+
+ ushort[] sw4 = master.ReadHoldingRegisters(slaveAddress, ushort.Parse(dt1.Rows[7]["MIG003"].ToString()), numberOfPoints);
+ strSw4 = (float.Parse(sw4[0].ToString()) / 10).ToString();
+
+ ushort[] csl5 = master.ReadHoldingRegisters(slaveAddress, ushort.Parse(dt1.Rows[8]["MIG003"].ToString()), numberOfPoints);
+ strCsl5 = csl5[0].ToString();
+
+ ushort[] sw5 = master.ReadHoldingRegisters(slaveAddress, ushort.Parse(dt1.Rows[9]["MIG003"].ToString()), numberOfPoints);
+ strSw5 = (float.Parse(sw5[0].ToString()) / 10).ToString();
+
+ bool[] sjjg = master.ReadCoils(slaveAddress, ushort.Parse(dt1.Rows[10]["MIG003"].ToString()), numberOfPoints);
+ SJJG = sjjg[0].ToString();
+ }
+ catch (Exception ex)
+ {
+ //VisiblePanel(txtDQBarCode.EditValue.ToString(), ex.Message, "NG", Color.Yellow);
+ //txtGWM.EditValue = "";
+ return;
+ }
}
}
diff --git a/DevApp/Gs.DevApp/packages.config b/DevApp/Gs.DevApp/packages.config
index 6d952a5..461862c 100644
--- a/DevApp/Gs.DevApp/packages.config
+++ b/DevApp/Gs.DevApp/packages.config
@@ -8,6 +8,7 @@
<package id="Microsoft.Bcl.AsyncInterfaces" version="8.0.0" targetFramework="net48" />
<package id="Microsoft.Web.WebView2" version="1.0.2592.51" targetFramework="net48" />
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net48" />
+ <package id="NModbus" version="3.0.81" targetFramework="net48" />
<package id="Oracle.ManagedDataAccess" version="23.6.0" targetFramework="net48" />
<package id="System.Buffers" version="4.5.1" targetFramework="net48" />
<package id="System.Configuration.ConfigurationManager" version="8.0.0" targetFramework="net48" />
--
Gitblit v1.9.3