pengliangyang пре 2 година
родитељ
комит
c0ac4821ff
8 измењених фајлова са 126 додато и 52 уклоњено
  1. +3
    -0
      BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs
  2. +56
    -34
      BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs
  3. +2
    -2
      BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceCurrentStatus.cs
  4. +17
    -6
      BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs
  5. +34
    -6
      BPASmartClient.JXJFoodSmallStation/View/HardwareStatusView.xaml
  6. +7
    -2
      BPASmartClient.Modbus/ModbusTcp.cs
  7. +6
    -1
      BPASmartClient.S7Net/SiemensHelper.cs
  8. +1
    -1
      DosingSystem/Model/DeviceInquire.cs

+ 3
- 0
BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs Прегледај датотеку

@@ -37,6 +37,9 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
/// Tray2的柔性味魔方配料标志
/// </summary>
public bool DosingTray2 { get; set; } = true;

public int DosingTray1Loc { get; set; } = 0;
public int DosingTray2Loc { get; set; } = 0;
/// <summary>
/// 配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方
/// </summary>


+ 56
- 34
BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs Прегледај датотеку

@@ -691,6 +691,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
//HKDevice.HK_PLC_S7.Write("DB3.DBX50.0", false);
}
GVL_SmallStation.GetInstance.DosingTray1 = true;
GVL_SmallStation.GetInstance.DosingTray1Loc = (int)loc;
MessageLog.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},1号桶,{(int)loc}号仓,配料完成");
}
}
@@ -709,6 +710,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
//HKDevice.HK_PLC_S7.Write("DB3.DBX50.1", false);
}
GVL_SmallStation.GetInstance.DosingTray1 = true;
GVL_SmallStation.GetInstance.DosingTray1Loc = (int)loc;
MessageLog.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},2号桶,{(int)loc}号仓,配料完成");
}
}
@@ -727,6 +729,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
//HKDevice.HK_PLC_S7.Write("DB3.DBX50.2", false);
}
GVL_SmallStation.GetInstance.DosingTray1 = true;
GVL_SmallStation.GetInstance.DosingTray1Loc = (int)loc;
MessageLog.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},3号桶,{(int)loc}号仓,配料完成");
}
}
@@ -745,30 +748,34 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
//HKDevice.HK_PLC_S7.Write("DB3.DBX50.3", false);
}
GVL_SmallStation.GetInstance.DosingTray1 = true;
GVL_SmallStation.GetInstance.DosingTray1Loc = (int)loc;
MessageLog.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},4号桶,{(int)loc}号仓,配料完成");
}
}
if (GVL_SmallStation.GetInstance.DosingTray1)
if (GVL_SmallStation.GetInstance.DosingTray1 && GVL_SmallStation.GetInstance.DosingTray1Loc > 0 && GVL_SmallStation.GetInstance.DosingTray1Loc < 16)
{
for (int i = 1; i < 16; i++)
int i = GVL_SmallStation.GetInstance.DosingTray1Loc;
if (RTrig.GetInstance("Tray1StatusDevice" + i).Start(DeviceInquire.GetInstance.GetDevice(i).deviceStatus.RunStatus == 3))
{
if (RTrig.GetInstance("Tray1StatusDevice" + i).Start(DeviceInquire.GetInstance.GetDevice(i).deviceStatus.RunStatus == 3))
MessageLog.GetInstance.ShowRunLog($"柔性味魔方,托盘1,配方:{recipeName},{i}号仓,配料完成");
int res = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == i);
RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight = DeviceInquire.GetInstance.GetDevice(i).deviceStatus.CutWeightFeedback;
string info = DeviceInquire.GetInstance.GetDevice(i).StatusReset();
MessageLog.GetInstance.ShowRunLog(info);
if (i >= 1 && i <= 8)
{
MessageLog.GetInstance.ShowRunLog($"柔性味魔方,托盘1,配方:{recipeName},{i}号仓,配料完成");
int res = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == i);
RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight = DeviceInquire.GetInstance.GetDevice(i).deviceStatus.CutWeightFeedback;
DeviceInquire.GetInstance.GetDevice(i).StatusReset();
if (i >= 1 && i <= 8)
{
HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true);
}
else if (i >= 9 && i <= 15)
{
HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true);
}
GVL_SmallStation.GetInstance.DosingTray1 = false;
string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true);
MessageLog.GetInstance.ShowRunLog(commInfo);
}
else if (i >= 9 && i <= 15)
{
string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true);
MessageLog.GetInstance.ShowRunLog(commInfo1);
}
GVL_SmallStation.GetInstance.DosingTray1 = false;
GVL_SmallStation.GetInstance.DosingTray1Loc = 0;
}
}
if (RTrig.GetInstance("配方配料完成").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.1")) && (GVL_SmallStation.GetInstance.WindSendDosingFinish || !GVL_SmallStation.GetInstance.IsUseWindSend))
{
@@ -847,6 +854,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
//HKDevice.HK_PLC_S7.Write("DB3.DBX50.0", false);
}
GVL_SmallStation.GetInstance.DosingTray2 = true;
GVL_SmallStation.GetInstance.DosingTray2Loc = (int)loc;
MessageLog.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},1号桶,{(int)loc}号仓,配料完成");
}
}
@@ -865,6 +873,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
//HKDevice.HK_PLC_S7.Write("DB3.DBX50.5", false);
}
GVL_SmallStation.GetInstance.DosingTray2 = true;
GVL_SmallStation.GetInstance.DosingTray2Loc = (int)loc;
MessageLog.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},2号桶,{(int)loc}号仓,配料完成");
}
}
@@ -875,7 +884,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
if (res > 0 && res is float loc)
{
int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight;
double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeightW;
if (loc_index >= 0)
{
DeviceInquire.GetInstance.GetDevice((int)loc)?.Start((uint)weight);//启动并写入每个原料重量
@@ -883,6 +892,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
//HKDevice.HK_PLC_S7.Write("DB3.DBX50.6", false);
}
GVL_SmallStation.GetInstance.DosingTray2 = true;
GVL_SmallStation.GetInstance.DosingTray2Loc = (int)loc;
MessageLog.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},3号桶,{(int)loc}号仓,配料完成");
}
}
@@ -901,29 +911,32 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
//HKDevice.HK_PLC_S7.Write("DB3.DBX50.7", false);
}
GVL_SmallStation.GetInstance.DosingTray2 = true;
GVL_SmallStation.GetInstance.DosingTray2Loc = (int)loc;
MessageLog.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},4号桶,{(int)loc}号仓,配料完成");
}
}
if (GVL_SmallStation.GetInstance.DosingTray2 == true)
if (GVL_SmallStation.GetInstance.DosingTray2 == true && GVL_SmallStation.GetInstance.DosingTray1 == false && GVL_SmallStation.GetInstance.DosingTray2Loc > 0 && GVL_SmallStation.GetInstance.DosingTray2Loc < 16)
{
for (int i = 1; i < 16; i++)
int i = GVL_SmallStation.GetInstance.DosingTray2Loc;
if (RTrig.GetInstance("Tray2StatusDevice" + i).Start(DeviceInquire.GetInstance.GetDevice(i).deviceStatus.RunStatus == 3))
{
if (RTrig.GetInstance("Tray2StatusDevice" + i).Start(DeviceInquire.GetInstance.GetDevice(i).deviceStatus.RunStatus == 3))
MessageLog.GetInstance.ShowRunLog($"柔性味魔方,托盘2,配方:{recipeName},{i}号仓,配料完成");
int res = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == i);
RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight = DeviceInquire.GetInstance.GetDevice(i).deviceStatus.CutWeightFeedback;
string info = DeviceInquire.GetInstance.GetDevice(i).StatusReset();
MessageLog.GetInstance.ShowRunLog(info);
if (i >= 1 && i <= 8)
{
MessageLog.GetInstance.ShowRunLog($"柔性味魔方,托盘2,配方:{recipeName},{i}号仓,配料完成");
int res = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == i);
RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight = DeviceInquire.GetInstance.GetDevice(i).deviceStatus.CutWeightFeedback;
DeviceInquire.GetInstance.GetDevice(i).StatusReset();
if (i >= 1 && i <= 8)
{
HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true);
}
else if (i >= 9 && i <= 15)
{
HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true);
}
GVL_SmallStation.GetInstance.DosingTray2 = false;
string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true);
MessageLog.GetInstance.ShowRunLog(commInfo);
}
else if (i >= 9 && i <= 15)
{
string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true);
MessageLog.GetInstance.ShowRunLog(commInfo1);
}
GVL_SmallStation.GetInstance.DosingTray2 = false;
GVL_SmallStation.GetInstance.DosingTray2Loc = 0;
}
}
if (RTrig.GetInstance("DB3.DBX1.2").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.2")))
@@ -957,7 +970,16 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
}
}
}

private void StockBinInit()
{
for (int i = 1; i < 16; i++)
{
if (DeviceInquire.GetInstance.GetDevice(i).deviceStatus.RunStatus == 3)
{
DeviceInquire.GetInstance.GetDevice(i).StatusReset();
}
}
}
private void DosingDevice(int Index,int DeviceID)
{
if (RTrig.GetInstance("Tray2StatusDevice" + DeviceID).Start(DeviceInquire.GetInstance.GetDevice(DeviceID).deviceStatus.RunStatus == 3))


+ 2
- 2
BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceCurrentStatus.cs Прегледај датотеку

@@ -14,8 +14,8 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
private double _mWeight;


public bool RunStatus { get { return _mRunStatus; } set { _mRunStatus = value; OnPropertyChanged(); } }
private bool _mRunStatus;
public ushort RunStatus { get { return _mRunStatus; } set { _mRunStatus = value; OnPropertyChanged(); } }
private ushort _mRunStatus;


public int DeviceNum { get { return _mDeviceNum; } set { _mDeviceNum = value; OnPropertyChanged(); } }


+ 17
- 6
BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs Прегледај датотеку

@@ -43,12 +43,14 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
TopDeviceCurrentStatuses.ElementAt(TopIndex).Weight = DeviceLists.ElementAt(i).Value.deviceStatus.WeightFeedback;
TopDeviceCurrentStatuses.ElementAt(TopIndex).DeviceNum = DeviceLists.ElementAt(i).Value.deviceStatus.DeviceNum;
TopDeviceCurrentStatuses.ElementAt(TopIndex).RunStatus = DeviceLists.ElementAt(i).Value.deviceStatus.RunStatus;
}

if (BottomIndex >= 0 && BottomIndex < BottomDeviceCurrentStatuses.Count)
{
BottomDeviceCurrentStatuses.ElementAt(BottomIndex).Weight = DeviceLists.ElementAt(i).Value.deviceStatus.WeightFeedback;
BottomDeviceCurrentStatuses.ElementAt(BottomIndex).DeviceNum = DeviceLists.ElementAt(i).Value.deviceStatus.DeviceNum;
BottomDeviceCurrentStatuses.ElementAt(BottomIndex).RunStatus = DeviceLists.ElementAt(i).Value.deviceStatus.RunStatus;
}

int deviceIndex = Array.FindIndex(devices.ToArray(), p => p.IpAddress == DeviceLists.ElementAt(i).Key && p.DeviceName != DeviceLists.ElementAt(i).Value.DeviceName);
@@ -68,7 +70,9 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
DeviceName = $"测试设备{i + 1}",
DeviceNum = i + 1,
RunStatus = 1,
Weight = new Random().Next(100, 10000) / 100.0
});

devices.Add(new Devices()
@@ -84,6 +88,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
DeviceName = $"测试设备{i + 1}",
DeviceNum = i + 1,
RunStatus = 1,
Weight = new Random().Next(100, 10000) / 100.0
});

@@ -293,7 +298,6 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
this.DeviceName = DeviceName;
AlarmHelper<AlarmInfo>.Init();
AlarmHelper<AlarmInfo>.Alarm.EStop1 = true;
if (modbusTcp.Connected)
{
ThreadManage.GetInstance().StartLong(new Action(() =>
@@ -310,7 +314,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
deviceStatus.DeviceNum = (ushort)this.modbusTcp.ReadShort(DeviceAddress.DeviceNum);//获取设备编号
deviceStatus.DeviceAlarmCode = (ushort)this.modbusTcp.ReadShort(DeviceAddress.DeviceAlarmCode);//获取设备故障编码

//AlarmHelper<AlarmInfo>.Alarm.EStop1 = deviceStatus.DeviceAlarmCode.Get16bitValue(1);
AlarmHelper<AlarmInfo>.Alarm.EStop1 = deviceStatus.DeviceAlarmCode.Get16bitValue(1);
AlarmHelper<AlarmInfo>.Alarm.Servo = deviceStatus.DeviceAlarmCode.Get16bitValue(2);
AlarmHelper<AlarmInfo>.Alarm.Inverter = deviceStatus.DeviceAlarmCode.Get16bitValue(3);
AlarmHelper<AlarmInfo>.Alarm.EStop2 = deviceStatus.DeviceAlarmCode.Get16bitValue(7);
@@ -328,9 +332,9 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
this.modbusTcp.SetString(DeviceAddress.DeviceName, name);
}

public void StatusReset()
public string StatusReset()
{
this.modbusTcp.Write(DeviceAddress.FinfishStatus, (ushort)1);
return this.modbusTcp.Write(DeviceAddress.FinfishStatus, (ushort)1);
//var res = modbusTcp.Read(DeviceAddress.RunStatus);
}

@@ -344,8 +348,15 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
if (modbusTcp.Connected)
{
modbusTcp.SetReal(DeviceAddress.WeightSet, Value);//写入配方量
modbusTcp.Write(DeviceAddress.Start, (ushort)1);//设备启动写入
MessageLog.GetInstance.ShowRunLog($"开始配料");
string returnValue = modbusTcp.Write(DeviceAddress.Start, (ushort)1);//设备启动写入
if (returnValue.Substring(0, 2) == "成功")
{
MessageLog.GetInstance.ShowRunLog("发送成功" + returnValue);
}
else
{
MessageLog.GetInstance.ShowRunLog("发送失败" + returnValue);
}
//配料设备参数写入
var res = Json<DevicePar>.Data.deviceParModels.FirstOrDefault(p => p.MaterialName == DeviceName);
if (res != null)


+ 34
- 6
BPASmartClient.JXJFoodSmallStation/View/HardwareStatusView.xaml Прегледај датотеку

@@ -62,7 +62,7 @@

<StackPanel
Grid.Row="1"
Margin="0,25,0,0"
Margin="0,10,0,0"
HorizontalAlignment="Center"
Orientation="Horizontal">
<TextBlock
@@ -76,10 +76,9 @@
Text=" kg" />
</StackPanel>


<StackPanel
Grid.Row="1"
Margin="0,70,0,0"
Margin="0,40,0,0"
HorizontalAlignment="Center"
Orientation="Horizontal">
<TextBlock
@@ -92,6 +91,22 @@
Foreground="#FF0084FF"
Text=" 号仓" />
</StackPanel>
<StackPanel
Grid.Row="1"
Margin="0,70,0,0"
HorizontalAlignment="Center"
Orientation="Horizontal">
<TextBlock
FontSize="20"
Foreground="#FF0084FF"
Text="运行状态:" />
<TextBlock
FontSize="20"
Foreground="#FF0084FF"
Text="{Binding RunStatus}" />

</StackPanel>

<Image
Grid.RowSpan="2"
@@ -157,7 +172,7 @@

<StackPanel
Grid.Row="1"
Margin="0,25,0,0"
Margin="0,10,0,0"
HorizontalAlignment="Center"
Orientation="Horizontal">
<TextBlock
@@ -174,7 +189,7 @@

<StackPanel
Grid.Row="1"
Margin="0,70,0,0"
Margin="0,40,0,0"
HorizontalAlignment="Center"
Orientation="Horizontal">
<TextBlock
@@ -187,7 +202,20 @@
Foreground="#FF0084FF"
Text=" 号仓" />
</StackPanel>

<StackPanel
Grid.Row="1"
Margin="0,70,0,0"
HorizontalAlignment="Center"
Orientation="Horizontal">
<TextBlock
FontSize="20"
Foreground="#FF0084FF"
Text="运行状态:" />
<TextBlock
FontSize="20"
Foreground="#FF0084FF"
Text="{Binding RunStatus}" />
</StackPanel>
<Image
Grid.RowSpan="2"
Source="/BPASmartClient.CustomResource;component/Image/光柱.png"


+ 7
- 2
BPASmartClient.Modbus/ModbusTcp.cs Прегледај датотеку

@@ -253,9 +253,9 @@ namespace BPASmartClient.Modbus


public void Write<T>(string address, T value, byte slaveAddress = 1)
public string Write<T>(string address, T value, byte slaveAddress = 1)
{
if (address == null || tcpClient == null) return;
if (address == null || tcpClient == null) return "失败,地址为空或断开连接";
ushort startAddress = (ushort)GetAddress(address);
CommandType commandType = CommandType.Coils;
try
@@ -305,11 +305,16 @@ namespace BPASmartClient.Modbus
{
commandType = CommandType.Inputs;
}

return $"成功,地址:{address},值:{value}";
}
catch (Exception ex)
{
MessageLog.GetInstance.ShowEx($"写入地址:【{address}:= {startAddress}】,写入类型:【{commandType.ToString()}】出错,{ex.ToString()}");

ExceptionHandling(ex);

return $"异常,地址:{address},值:{value},发送异常";
}
}



+ 6
- 1
BPASmartClient.S7Net/SiemensHelper.cs Прегледај датотеку

@@ -58,11 +58,16 @@ namespace BPASmartClient.S7Net
return myPlc?.Read(dataType, db, address, varType, count);
}

public void Write<TValue>(string address, TValue value)
public string Write<TValue>(string address, TValue value)
{
if (IsConnected)
{
myPlc?.Write(address, value);
return $"成功,地址:{address},值:{value}";
}
else
{
return $"失败,地址:{address},值:{value},断开连接";
}
}



+ 1
- 1
DosingSystem/Model/DeviceInquire.cs Прегледај датотеку

@@ -337,7 +337,7 @@ namespace BPASmartClient.DosingSystem.Model
if (modbusTcp.Connected)
{
modbusTcp.SetReal(DeviceAddress.WeightSet, Value);//写入配方量
modbusTcp.Write(DeviceAddress.Start, (ushort)1);//设备启动写入
string returnValue = modbusTcp.Write(DeviceAddress.Start, (ushort)1);//设备启动写入
//配料设备参数写入
var res = Json<DevicePar>.Data.deviceParModels.FirstOrDefault(p => p.MaterialName == DeviceName);
if (res != null)


Loading…
Откажи
Сачувај