From 948af42a47bb601a33d53f9083566651c9798d7d Mon Sep 17 00:00:00 2001 From: wangsr Date: Sun, 8 Oct 2023 15:49:40 +0800 Subject: [PATCH] =?UTF-8?q?add=20-=20=E6=89=8B=E5=8A=A8=E6=8E=A7=E5=88=B6?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BF=9D=E5=AD=98=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ManualControl/ManualControlAction.cs | 86 ++++++++++-- .../ManualControl/Setting.Designer.cs | 122 ++++++++++++++++++ .../ManualControl/Setting.settings | 30 +++++ .../Mesnac.Action.ChemicalWeighing.csproj | 10 ++ .../Mesnac.Action.ChemicalWeighing/app.config | 36 ++++++ .../MCProject/nodeForm/ManualWaterControl.xml | 48 +++++++ 6 files changed, 321 insertions(+), 11 deletions(-) create mode 100644 Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/ManualControl/Setting.Designer.cs create mode 100644 Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/ManualControl/Setting.settings create mode 100644 Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/app.config diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/ManualControl/ManualControlAction.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/ManualControl/ManualControlAction.cs index 83823a4..027a00f 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/ManualControl/ManualControlAction.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/ManualControl/ManualControlAction.cs @@ -1,7 +1,9 @@ using DataBlockHelper; +using DevExpress.DataAccess.Native.Json; using DevExpress.Utils.About; using ICSharpCode.Core; using Mesnac.Action.Base; +using Mesnac.Action.ChemicalWeighing.Entity; using Mesnac.Action.ChemicalWeighing.FreeDb; using Mesnac.Action.ChemicalWeighing.InterfaceDocking; using Mesnac.Action.ChemicalWeighing.InterfaceDocking.DockingEntity; @@ -118,6 +120,8 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl MCButton WetRequest8; MCButton Focus; + MCButton SaveSetting; + MCButton LoadSetting; #endregion @@ -135,7 +139,14 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl BottomSelect(runtime); - + SetWaterValue1.MCValue = Setting.Default.SetWaterValue1; + SetWaterValue2.MCValue = Setting.Default.SetWaterValue2; + SetWaterValue3.MCValue = Setting.Default.SetWaterValue3; + SetWaterValue4.MCValue = Setting.Default.SetWaterValue4; + SetSpiralValue1.MCValue = Setting.Default.SetSpiralValue1; + SetSpiralValue2.MCValue = Setting.Default.SetSpiralValue2; + SetSpiralValue3.MCValue = Setting.Default.SetSpiralValue3; + SetSpiralValue4.MCValue = Setting.Default.SetSpiralValue4; } /// @@ -227,6 +238,9 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl WetRequest8 = GetButtonControl("WetRequest8"); Focus = GetButtonControl("Focus"); + + SaveSetting = GetButtonControl("SaveSetting"); + LoadSetting = GetButtonControl("LoadSetting"); } /// @@ -1161,24 +1175,74 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl ManualLogControl("湿混机8返回数据 " + returnTest); MesnacServiceManager.Instance.LoggingService.Info("湿混机8返回数据" + returnTest); } - } + if(SaveSetting == runtime.Sender) + { + short value1; + short value2; + short value3; + short value4; + short value5; + short value6; + short value7; + short value8; + if (short.TryParse(Convert.ToString(SetWaterValue1.MCValue), out value1) && + short.TryParse(Convert.ToString(SetWaterValue2.MCValue), out value2) && + short.TryParse(Convert.ToString(SetWaterValue3.MCValue), out value3) && + short.TryParse(Convert.ToString(SetWaterValue4.MCValue), out value4) && + short.TryParse(Convert.ToString(SetSpiralValue1.MCValue), out value5) && + short.TryParse(Convert.ToString(SetSpiralValue2.MCValue), out value6) && + short.TryParse(Convert.ToString(SetSpiralValue3.MCValue), out value7) && + short.TryParse(Convert.ToString(SetSpiralValue4.MCValue), out value8)) + { + if (MessageBox.Show("是否保存当前配置?", "保存确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) + { + return; + } + + Setting.Default.SetWaterValue1 = value1; + Setting.Default.SetWaterValue2 = value2; + Setting.Default.SetWaterValue3 = value3; + Setting.Default.SetWaterValue4 = value4; + Setting.Default.SetSpiralValue1 = value1; + Setting.Default.SetSpiralValue2 = value2; + Setting.Default.SetSpiralValue3 = value3; + Setting.Default.SetSpiralValue4 = value4; + MesnacServiceManager.Instance.LoggingService.Info("配置已保存"); + ManualLogControl("配置已保存 " + value1 + value2 + value3 + value4 + value5 + value6 + value7 + value8); + } + } + + if (LoadSetting == runtime.Sender) + { + if (MessageBox.Show("是否加载上次保存的配置?", "加载确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) + { + return; + } + SetWaterValue1.MCValue = Setting.Default.SetWaterValue1; + SetWaterValue2.MCValue = Setting.Default.SetWaterValue2; + SetWaterValue3.MCValue = Setting.Default.SetWaterValue3; + SetWaterValue4.MCValue = Setting.Default.SetWaterValue4; + SetSpiralValue1.MCValue = Setting.Default.SetSpiralValue1; + SetSpiralValue2.MCValue = Setting.Default.SetSpiralValue2; + SetSpiralValue3.MCValue = Setting.Default.SetSpiralValue3; + SetSpiralValue4.MCValue = Setting.Default.SetSpiralValue4; + MesnacServiceManager.Instance.LoggingService.Info("配置已加载"); + ManualLogControl("配置已加载 "); + } + } private void PlcControl(string address, short binNo) - { + { PlcConnect.Instance.Write(address, binNo); - } - + } private void PlcControl(string address, bool state) { PlcConnect.Instance.Write(address, state); } - - private IBaseControl GetBaseControl(string name) - { - return _McControllist.Where(t => t.BaseControl.MCKey != null && t.BaseControl.MCKey == name).FirstOrDefault().BaseControl; - } - + { + return _McControllist.Where(t => t.BaseControl.MCKey != null && t.BaseControl.MCKey == name).FirstOrDefault().BaseControl; + } private MCButton GetButtonControl(string name) { return McControllist.Where(t => t.BaseControl.MCKey != null && t.BaseControl.MCKey == name).FirstOrDefault().BaseControl as MCButton; diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/ManualControl/Setting.Designer.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/ManualControl/Setting.Designer.cs new file mode 100644 index 0000000..9b5da84 --- /dev/null +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/ManualControl/Setting.Designer.cs @@ -0,0 +1,122 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本:4.0.30319.42000 +// +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 +// +//------------------------------------------------------------------------------ + +namespace Mesnac.Action.ChemicalWeighing.ManualControl { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.6.0.0")] + internal sealed partial class Setting : global::System.Configuration.ApplicationSettingsBase { + + private static Setting defaultInstance = ((Setting)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Setting()))); + + public static Setting Default { + get { + return defaultInstance; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("190")] + public short SetWaterValue1 { + get { + return ((short)(this["SetWaterValue1"])); + } + set { + this["SetWaterValue1"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("205")] + public short SetWaterValue2 { + get { + return ((short)(this["SetWaterValue2"])); + } + set { + this["SetWaterValue2"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("190")] + public short SetWaterValue3 { + get { + return ((short)(this["SetWaterValue3"])); + } + set { + this["SetWaterValue3"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("205")] + public short SetWaterValue4 { + get { + return ((short)(this["SetWaterValue4"])); + } + set { + this["SetWaterValue4"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("480")] + public short SetSpiralValue1 { + get { + return ((short)(this["SetSpiralValue1"])); + } + set { + this["SetSpiralValue1"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("480")] + public short SetSpiralValue2 { + get { + return ((short)(this["SetSpiralValue2"])); + } + set { + this["SetSpiralValue2"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("480")] + public short SetSpiralValue3 { + get { + return ((short)(this["SetSpiralValue3"])); + } + set { + this["SetSpiralValue3"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("480")] + public short SetSpiralValue4 { + get { + return ((short)(this["SetSpiralValue4"])); + } + set { + this["SetSpiralValue4"] = value; + } + } + } +} diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/ManualControl/Setting.settings b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/ManualControl/Setting.settings new file mode 100644 index 0000000..d31535c --- /dev/null +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/ManualControl/Setting.settings @@ -0,0 +1,30 @@ + + + + + + 190 + + + 205 + + + 190 + + + 205 + + + 480 + + + 480 + + + 480 + + + 480 + + + \ No newline at end of file diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj index 86d782b..7934dd0 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj @@ -503,6 +503,11 @@ + + True + True + Setting.settings + Component @@ -853,6 +858,11 @@ + + + SettingsSingleFileGenerator + Setting.Designer.cs + diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/app.config b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/app.config new file mode 100644 index 0000000..02a7457 --- /dev/null +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/app.config @@ -0,0 +1,36 @@ + + + + +
+ + + + + + 190 + + + 205 + + + 190 + + + 205 + + + 480 + + + 480 + + + 480 + + + 480 + + + + \ No newline at end of file diff --git a/Main/MCEdit/Data/MCProject/nodeForm/ManualWaterControl.xml b/Main/MCEdit/Data/MCProject/nodeForm/ManualWaterControl.xml index 209554d..97d11a8 100644 --- a/Main/MCEdit/Data/MCProject/nodeForm/ManualWaterControl.xml +++ b/Main/MCEdit/Data/MCProject/nodeForm/ManualWaterControl.xml @@ -1,5 +1,53 @@ + + + AAEAAAD/////AQAAAAAAAAAMAgAAAEtNZXNuYWMuQ29udHJvbHMuQmFzZSwgVmVyc2lvbj0xLjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPW51bGwEAQAAAJMBU3lzdGVtLkNvbGxlY3Rpb25zLkdlbmVyaWMuTGlzdGAxW1tNZXNuYWMuQ29udHJvbHMuQmFzZS5EZXNpZ25BY3Rpb24sIE1lc25hYy5Db250cm9scy5CYXNlLCBWZXJzaW9uPTEuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49bnVsbF1dAwAAAAZfaXRlbXMFX3NpemUIX3ZlcnNpb24EAAAjTWVzbmFjLkNvbnRyb2xzLkJhc2UuRGVzaWduQWN0aW9uW10CAAAACAgJAwAAAAEAAAAEAAAABwMAAAAAAQAAAAQAAAAEIU1lc25hYy5Db250cm9scy5CYXNlLkRlc2lnbkFjdGlvbgIAAAAJBAAAAA0DBQQAAAAhTWVzbmFjLkNvbnRyb2xzLkJhc2UuRGVzaWduQWN0aW9uAwAAABU8R1VJRD5rX19CYWNraW5nRmllbGQVPE5hbWU+a19fQmFja2luZ0ZpZWxkFzxSZW1hcms+a19fQmFja2luZ0ZpZWxkAQEBAgAAAAYFAAAAIDhBNkE3NzM4OTg2NDRFQjlBQ0FGQkRDOEZENjZERjNDBgYAAAAM5oyJ6ZKu5LqL5Lu2BgcAAAAM5oyJ6ZKu5LqL5Lu2Cw== + + LoadSetting + + False + + + + Query + True + True + False + + + Red + DarkGray + 加载配置 + 732, 601 + MCButton23 + 85, 47 + 29 + + + + AAEAAAD/////AQAAAAAAAAAMAgAAAEtNZXNuYWMuQ29udHJvbHMuQmFzZSwgVmVyc2lvbj0xLjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPW51bGwEAQAAAJMBU3lzdGVtLkNvbGxlY3Rpb25zLkdlbmVyaWMuTGlzdGAxW1tNZXNuYWMuQ29udHJvbHMuQmFzZS5EZXNpZ25BY3Rpb24sIE1lc25hYy5Db250cm9scy5CYXNlLCBWZXJzaW9uPTEuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49bnVsbF1dAwAAAAZfaXRlbXMFX3NpemUIX3ZlcnNpb24EAAAjTWVzbmFjLkNvbnRyb2xzLkJhc2UuRGVzaWduQWN0aW9uW10CAAAACAgJAwAAAAEAAAACAAAABwMAAAAAAQAAAAQAAAAEIU1lc25hYy5Db250cm9scy5CYXNlLkRlc2lnbkFjdGlvbgIAAAAJBAAAAA0DBQQAAAAhTWVzbmFjLkNvbnRyb2xzLkJhc2UuRGVzaWduQWN0aW9uAwAAABU8R1VJRD5rX19CYWNraW5nRmllbGQVPE5hbWU+a19fQmFja2luZ0ZpZWxkFzxSZW1hcms+a19fQmFja2luZ0ZpZWxkAQEBAgAAAAYFAAAAIDhBNkE3NzM4OTg2NDRFQjlBQ0FGQkRDOEZENjZERjNDBgYAAAAM5oyJ6ZKu5LqL5Lu2BgcAAAAM5oyJ6ZKu5LqL5Lu2Cw== + + SaveSetting + + False + + + + Query + True + True + False + + + Red + DarkGray + 保存配置 + 732, 508 + MCButton22 + 85, 47 + 8 +