change - 加载时读取配置,修改配置

dep_nodyang
wangsr 1 year ago
parent 5b71bd3012
commit dc63fbdaf4

@ -27,6 +27,7 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl
DB2103Helper DB2103;
List<DbMCControl> McControllist;
List<DbMCControl> _McControllist;
OperateResult<byte[]> Read;
@ -63,6 +64,15 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl
IBaseControl SpiralState3;
IBaseControl SpiralState4;
IBaseControl SetWaterValue1;
IBaseControl SetWaterValue2;
IBaseControl SetWaterValue3;
IBaseControl SetWaterValue4;
IBaseControl SetSpiralValue1;
IBaseControl SetSpiralValue2;
IBaseControl SetSpiralValue3;
IBaseControl SetSpiralValue4;
bool State1;
bool State2;
byte Byt;
@ -76,6 +86,7 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl
base.RunIni(runtime); //必须要调用的
McControllist = GetAllDbMCControlsByOption(DbOptionTypes.InitData);
_McControllist = GetAllDbMCControlsByOption(DbOptionTypes.Modify);
WaterActualValue1 = GetBaseControl("WaterActualValue1");
WaterActualValue2 = GetBaseControl("WaterActualValue2");
@ -102,10 +113,30 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl
SpiralState3 = GetBaseControl("SpiralState3");
SpiralState4 = GetBaseControl("SpiralState4");
SetWaterValue1 = _GetBaseControl("SetWaterValue1");
SetWaterValue2 = _GetBaseControl("SetWaterValue2");
SetWaterValue3 = _GetBaseControl("SetWaterValue3");
SetWaterValue4 = _GetBaseControl("SetWaterValue4");
SetSpiralValue1 = _GetBaseControl("SetSpiralValue1");
SetSpiralValue2 = _GetBaseControl("SetSpiralValue2");
SetSpiralValue3 = _GetBaseControl("SetSpiralValue3");
SetSpiralValue4 = _GetBaseControl("SetSpiralValue4");
materialGridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "ManualLogGridView").FirstOrDefault();
LogInsertToDatabase();
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("配置已加载 ");
timer = new Timer();
timer.Interval = 1000;
timer.Enabled = true;
@ -356,6 +387,11 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl
return McControllist.Where(t => t.BaseControl.MCKey != null && t.BaseControl.MCKey == name).FirstOrDefault().BaseControl;
}
private IBaseControl _GetBaseControl(string name)
{
return _McControllist.Where(t => t.BaseControl.MCKey != null && t.BaseControl.MCKey == name).FirstOrDefault().BaseControl;
}
private void LogInsertToDatabase()
{
DataTable table = DBHelp.GetTable(@"select top 100 id, logtext, logtime from Manual_Log order by id desc");
@ -370,5 +406,17 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl
ICSharpCode.Core.LoggingService<InitAction>.Warn("手动操作日志信息控件为Null...");
}
}
private void ManualLogControl(string logName)
{
var Log = new ManualLogEntity()
{
logtext = logName,
logtime = DateTime.Now,
userid = string.IsNullOrWhiteSpace(UserInfo.Instance.UserName) ? "Edit" : UserInfo.Instance.UserName
};
FreeSqlUnit.Instance.Insert<ManualLogEntity>(Log).ExecuteIdentity();
}
}
}

@ -139,14 +139,6 @@ 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;
}
/// <summary>
@ -1204,10 +1196,10 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl
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;
Setting.Default.SetSpiralValue1 = value5;
Setting.Default.SetSpiralValue2 = value6;
Setting.Default.SetSpiralValue3 = value7;
Setting.Default.SetSpiralValue4 = value8;
MesnacServiceManager.Instance.LoggingService.Info("配置已保存");
ManualLogControl("配置已保存 " + value1 + value2 + value3 + value4 + value5 + value6 + value7 + value8);
}

@ -13,7 +13,7 @@
</Connection>
</Main>
<Group>
<Group name="B1" block="2107" start="0" len="1032" access="ReadWrite" remark="ParametersWithPc" isautoread="False">
<Group name="B1" block="2107" start="0" len="1032" access="ReadWrite" remark="ParametersWithPc" isautoread="True">
<Data>
<Data name="FirstWord" runname="FirstWord" start="0" len="1" method="Default_Bit(0,1)" max="" issave="False" subtractor="" remark="FirstWord" />
<Data name="WatchDog" runname="WatchDog" start="1" len="1" method="Default_ShortDiv()" max="" issave="False" subtractor="" remark="系统通用参数" />
@ -2810,7 +2810,7 @@
<Data name="wetMixingH_9_actTolerence" runname="wetMixingH_9_actTolerence" start="2822" len="2" method="Default_Float()" max="" issave="False" subtractor="" remark="称量误差" />
</Data>
</Group>
<Group name="RecipeDataFromPC" block="2104" start="0" len="1789" access="ReadWrite" remark="" isautoread="False">
<Group name="RecipeDataFromPC" block="2104" start="0" len="1789" access="ReadWrite" remark="" isautoread="True">
<Data>
<Data name="FirstWord" runname="FirstWord" start="0" len="1" method="Default_ShortDiv()" max="" issave="False" subtractor="" remark="预留" />
<Data name="RecipeCode" runname="RecipeCode" start="1" len="1" method="Default_ShortDiv()" max="" issave="False" subtractor="" remark="配方代码" />
@ -3958,7 +3958,7 @@
<Data name="WeterM8Step9_Tolerance" runname="WeterM8Step9_Tolerance" start="1787" len="2" method="Default_Float()" max="" issave="False" subtractor="" remark="设定公差" />
</Data>
</Group>
<Group name="DB2102-valveInitDB" block="2102" start="0" len="107" access="ReadWrite" remark="valveInitDB" isautoread="False">
<Group name="DB2102-valveInitDB" block="2102" start="0" len="107" access="ReadWrite" remark="valveInitDB" isautoread="True">
<Data>
<Data name="BU1ASF01_ManualMode" runname="BU1ASF01_ManualMode" start="0" len="1" method="Default_Bit(0,1)" max="" issave="True" subtractor="" remark="手动模式" />
<Data name="BU1ASF01_AutoMode" runname="BU1ASF01_AutoMode" start="0" len="1" method="Default_Bit(1,1)" max="" issave="True" subtractor="" remark="自动模式" />
@ -5395,7 +5395,7 @@
<Data name="BU8GEB02_P" runname="BU8GEB02_P" start="106" len="1" method="Default_Bit(12,1)" max="" issave="True" subtractor="" remark="状态态志" />
</Data>
</Group>
<Group name="DB2103-motorInitDB" block="2103" start="0" len="209" access="ReadWrite" remark="motorInitDB" isautoread="False">
<Group name="DB2103-motorInitDB" block="2103" start="0" len="209" access="ReadWrite" remark="motorInitDB" isautoread="True">
<Data>
<Data name="DM1ASI01_ManualMode" runname="DM1ASI01_ManualMode" start="0" len="1" method="Default_Bit(0,1)" max="" issave="True" subtractor="" remark="手动模式" />
<Data name="DM1ASI01_AutoMode" runname="DM1ASI01_AutoMode" start="0" len="1" method="Default_Bit(1,1)" max="" issave="True" subtractor="" remark="自动模式" />

Loading…
Cancel
Save