瀏覽代碼

调整修改

JXJAgvReake
pry 1 年之前
父節點
當前提交
8aab8e3ef7
共有 3 個文件被更改,包括 42 次插入53 次删除
  1. +8
    -1
      BPASmartClient.CustomResource/Pages/Model/AlarmHelper.cs
  2. +30
    -48
      DosingSystem/Model/DeviceInquire.cs
  3. +4
    -4
      DosingSystem/ViewModel/RecipeControlViewModel.cs

+ 8
- 1
BPASmartClient.CustomResource/Pages/Model/AlarmHelper.cs 查看文件

@@ -108,7 +108,14 @@ namespace BPASmartClient.CustomResource.Pages.Model
};

var res = Sqlite<BPASmartClient.Model.Alarm>.GetInstance.Base.Add(tempAlarm);
Sqlite<BPASmartClient.Model.Alarm>.GetInstance.Save();
try
{
Sqlite<BPASmartClient.Model.Alarm>.GetInstance.Save();
}
catch (Exception)
{
}


if (Alarms.FirstOrDefault(p => p.Info == AlarmInfo) == null)
{


+ 30
- 48
DosingSystem/Model/DeviceInquire.cs 查看文件

@@ -347,12 +347,36 @@ namespace BPASmartClient.DosingSystem
{
TaskManage.GetInstance.StartLong(new Action(() =>
{
this.DeviceName = modbusTcp.Read<string>(DeviceAddress.DeviceName.ToAdd(), 20).Content.Trim().Replace(" ", "");
deviceStatus.RunStatus = (ushort)this.modbusTcp.Read<ushort>(DeviceAddress.RunStatus.ToAdd()).Content; //获取设备运行状态
deviceStatus.WeightFeedback = (float)this.modbusTcp.Read<uint>(DeviceAddress.WeightFeedback.ToAdd()).Content;//获取设备料仓剩余重量
deviceStatus.NowWeightFeedback = this.modbusTcp.Read<float>(DeviceAddress.CutWeightFeedback.ToAdd()).Content;//获取下料重量
deviceStatus.DeviceNum = (ushort)this.modbusTcp.Read<ushort>(DeviceAddress.DeviceNum.ToAdd()).Content;//获取设备编号
deviceStatus.DeviceAlarmCode = (ushort)this.modbusTcp.Read<ushort>(DeviceAddress.DeviceAlarmCode.ToAdd()).Content;//获取设备故障编码
var dn = modbusTcp.Read<string>(DeviceAddress.DeviceName.ToAdd(), 20);
if (dn.IsSuccess) this.DeviceName = dn.Content.Trim().Replace(" ", "");

//获取设备运行状态
var rs = this.modbusTcp.Read<ushort>(DeviceAddress.RunStatus.ToAdd());
if (rs.IsSuccess) deviceStatus.RunStatus = rs.Content;

////获取设备料仓剩余重量
var wf = this.modbusTcp.Read<uint>(DeviceAddress.WeightFeedback.ToAdd());
if (wf.IsSuccess) deviceStatus.WeightFeedback = (float)(wf.Content);

////获取下料重量
var nwf = this.modbusTcp.Read<float>(DeviceAddress.CutWeightFeedback.ToAdd());
if (nwf.IsSuccess) deviceStatus.NowWeightFeedback = nwf.Content;

////获取设备编号
var dnum = this.modbusTcp.Read<ushort>(DeviceAddress.DeviceNum.ToAdd());
if (dnum.IsSuccess) deviceStatus.DeviceNum = dnum.Content;

////获取设备故障编码
var dac = this.modbusTcp.Read<ushort>(DeviceAddress.DeviceAlarmCode.ToAdd());
if (dac.IsSuccess) deviceStatus.DeviceAlarmCode = dac.Content;


//this.DeviceName = modbusTcp.Read<string>(DeviceAddress.DeviceName.ToAdd(), 20).Content.Trim().Replace(" ", "");
//deviceStatus.RunStatus = (ushort)this.modbusTcp.Read<ushort>(DeviceAddress.RunStatus.ToAdd()).Content; //获取设备运行状态
//deviceStatus.WeightFeedback = (float)this.modbusTcp.Read<uint>(DeviceAddress.WeightFeedback.ToAdd()).Content;//获取设备料仓剩余重量
//deviceStatus.NowWeightFeedback = this.modbusTcp.Read<float>(DeviceAddress.CutWeightFeedback.ToAdd()).Content;//获取下料重量
//deviceStatus.DeviceNum = (ushort)this.modbusTcp.Read<ushort>(DeviceAddress.DeviceNum.ToAdd()).Content;//获取设备编号
//deviceStatus.DeviceAlarmCode = (ushort)this.modbusTcp.Read<ushort>(DeviceAddress.DeviceAlarmCode.ToAdd()).Content;//获取设备故障编码

AlarmHelper<AlarmInfo>.GetInstance(DeviceName).EStop1 = deviceStatus.DeviceAlarmCode.GetBitValue(1);
AlarmHelper<AlarmInfo>.GetInstance(DeviceName).Servo = deviceStatus.DeviceAlarmCode.GetBitValue(2);
@@ -389,40 +413,6 @@ namespace BPASmartClient.DosingSystem
var res = Json<DevicePar>.Data.deviceParModels.FirstOrDefault(p => p.MaterialName == DeviceName);
if (res != null)
{
//prop1:
//modbusTcp.SetReal(DeviceAddress.SlowlyAddWeight, res.SlowlyAddWeight);
//var Value1 = (float)this.modbusTcp.GetReal(DeviceAddress.SlowlyAddWeight);
//if (Value1 != null && Value1.ToString() != res.SlowlyAddWeight.ToString()) goto prop1;
//prop2:
//modbusTcp.SetReal(DeviceAddress.PreCloseValveWeight, res.PreCloseValveWeight);
//var Value2 = (float)this.modbusTcp.GetReal(DeviceAddress.PreCloseValveWeight);
//if (Value2 != null && Value2.ToString() != res.PreCloseValveWeight.ToString()) goto prop2;
//prop3:
//modbusTcp.SetUint(DeviceAddress.RapidAcceleration, (uint)res.RapidAcceleration);
//var Value3 = this.modbusTcp.GetUint(DeviceAddress.RapidAcceleration);
//if (Value3 != null && Value3.ToString() != res.RapidAcceleration.ToString()) goto prop3;
//prop4:
//modbusTcp.SetUint(DeviceAddress.SlowAcceleration, (uint)res.SlowAcceleration);
//var Value4 = this.modbusTcp.GetUint(DeviceAddress.SlowAcceleration);
//if (Value4 != null && Value4.ToString() != res.SlowAcceleration.ToString()) goto prop4;
//prop5:
//modbusTcp.SetUint(DeviceAddress.ServoManualSpeed, (uint)res.ServoManualSpeed);
//var Value5 = this.modbusTcp.GetUint(DeviceAddress.ServoManualSpeed);
//if (Value5 != null && Value5.ToString() != res.ServoManualSpeed.ToString()) goto prop5;
//prop6:
//modbusTcp.SetUint(DeviceAddress.SiloUpperLimitWeight, (uint)res.SiloUpperLimitWeight);
//var Value6 = this.modbusTcp.GetUint(DeviceAddress.SiloUpperLimitWeight);
//if (Value6 != null && Value6.ToString() != res.SiloUpperLimitWeight.ToString()) goto prop6;
//prop7:
//modbusTcp.SetUint(DeviceAddress.LowerLimitWeightOfSilo, (uint)res.LowerLimitWeightOfSilo);
//var Value7 = this.modbusTcp.GetUint(DeviceAddress.LowerLimitWeightOfSilo);
//if (Value7 != null && Value7.ToString() != res.LowerLimitWeightOfSilo.ToString()) goto prop7;
//prop8:
//modbusTcp.SetUint(DeviceAddress.StirringSpeed, (uint)res.StirringSpeed);
//var Value8 = this.modbusTcp.GetUint(DeviceAddress.StirringSpeed);
//if (Value8 != null && Value8.ToString() != res.StirringSpeed.ToString()) goto prop8;
//MessageNotify.GetInstance.ShowRunLog($"{res.MaterialName},配料参数下发完成");

modbusTcp.Write(DeviceAddress.SlowlyAddWeight.ToAdd(), res.SlowlyAddWeight);
modbusTcp.Write(DeviceAddress.PreCloseValveWeight.ToAdd(), res.PreCloseValveWeight);
modbusTcp.Write(DeviceAddress.RapidAcceleration.ToAdd(), (uint)res.RapidAcceleration);
@@ -433,14 +423,6 @@ namespace BPASmartClient.DosingSystem
modbusTcp.Write(DeviceAddress.StirringSpeed.ToAdd(), (uint)res.StirringSpeed);
MessageNotify.GetInstance.ShowRunLog($"{res.MaterialName},配料参数下发完成");
}
//prop9:
// modbusTcp.SetReal(DeviceAddress.WeightSet, Value);//写入配方重量
// var Value9 = this.modbusTcp.GetReal(DeviceAddress.WeightSet);
// if (Value9 != null && Value9.ToString() != Value.ToString()) goto prop9;
//prop10:
// modbusTcp.Write(DeviceAddress.Start, (ushort)1);//设备启动写入
// var Value10 = (short[])this.modbusTcp.Read(DeviceAddress.Start);
// if (Value10 != null && Value10[0] != 1) goto prop10;
modbusTcp.Write(DeviceAddress.WeightSet.ToAdd(), Value);//写入配方重量
modbusTcp.Write(DeviceAddress.Start.ToAdd(), (ushort)1);//设备启动写入
MessageNotify.GetInstance.ShowRunLog($"{DeviceName},设置重量:{Value},味魔方启动配料");


+ 4
- 4
DosingSystem/ViewModel/RecipeControlViewModel.cs 查看文件

@@ -144,11 +144,11 @@ namespace BPASmartClient.DosingSystem.ViewModel
/*data = data.SetBitValue((byte)tempDevice.DeviceNum, true);*/
if (tempDevice.DeviceNum > 0)
{
int a = data.SetBitValue((byte)tInfo.ElementAt(i).ElementAt(m).Loc, true);
byte[] test1 = a.ToBytes(BPA.Helper.DataFormat.BADC);
int item = test1.ToInt();
//int a = data.SetBitValue((byte)tInfo.ElementAt(i).ElementAt(m).Loc, true);
//byte[] test1 = a.ToBytes(BPA.Helper.DataFormat.BADC);
//int item = test1.ToInt();
int item = data.SetBitValue((byte)tInfo.ElementAt(i).ElementAt(m).Loc, true).ToBytes(BPA.Helper.DataFormat.BADC).ToInt();
var RE = SiemensDevice.GetInstance.MySiemens.Write($"DB4.DBD{2 + (tempDevice.DeviceNum - 1) * 4}", item);
//var RE = SiemensDevice.GetInstance.MySiemens.Write($"DB4.DBX2.0", true);
if (RE.IsSuccess)
MessageNotify.GetInstance.ShowRunLog($"下发配方DB4.DBD{2 + (tempDevice.DeviceNum - 1) * 4} :{(byte)tInfo.ElementAt(i).ElementAt(m).Loc}-{item}-{item.ToBinString()}");
else


Loading…
取消
儲存