Kaynağa Gözat

测试版本

一拖四味魔方配料系统
yaowen liu 1 yıl önce
ebeveyn
işleme
e6ac665fdf
5 değiştirilmiş dosya ile 25 ekleme ve 62 silme
  1. +1
    -0
      DosingSystem/BPASmartClient.DosingSystem.csproj
  2. +15
    -43
      DosingSystem/ExcuteControl .cs
  3. +2
    -4
      Test/MainWindow.xaml
  4. +6
    -15
      Test/MainWindow.xaml.cs
  5. +1
    -0
      Test/Test.csproj

+ 1
- 0
DosingSystem/BPASmartClient.DosingSystem.csproj Dosyayı Görüntüle

@@ -29,6 +29,7 @@
<Aliases>aliyun</Aliases>
</PackageReference>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="7.0.0" />
</ItemGroup>

<ItemGroup>


+ 15
- 43
DosingSystem/ExcuteControl .cs Dosyayı Görüntüle

@@ -1406,7 +1406,7 @@ namespace BPASmartClient.DosingSystem
index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == RecipeNames.ElementAt(recipeNameNum));
if (index >= 0 && index < Recipes.Count)
{
MessageNotify.GetInstance.runLogs.Add(new RunLog() { RunLogInfo = $"下发配方{RecipeNames.ElementAt(recipeNameNum)}到设备{DeviceInquire.GetInstance.devices[i].DeviceName}",Time = DateTime.Now.ToString()});
int maxPail = 0;
foreach (var rawMaterial in Recipes.ElementAt(index).RawMaterials)
{
@@ -1488,6 +1488,7 @@ namespace BPASmartClient.DosingSystem
DeviceParModel deviceSet = Json<DevicePar>.Data.deviceParModels?.ToList().Find(a => a.MaterialName == DeviceInquire.GetInstance.devices[i].DeviceName);
if (deviceSet != null && DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].IsConnected == true)
{
MessageNotify.GetInstance.runLogs.Add(new RunLog() { RunLogInfo = $"下发配料信息{Recipes.ElementAt(doCount).RecipeName}到设备{DeviceInquire.GetInstance.devices[i].DeviceName}",Time = DateTime.Now.ToString() });
//传送带停止
DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), 0);
//设置下料重量
@@ -1531,9 +1532,11 @@ namespace BPASmartClient.DosingSystem
{
if (DeviceInquire.GetInstance.devices[i].IpAddress == "192.168.2.90")
{

if (DeviceInquire.GetInstance.DeviceLists[ DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.PailArrive == 1)
{
SimensSend.GetInstance.SendSimens.Write("DB1.DBX702.0", 0);
MessageNotify.GetInstance.runLogs.Add(new RunLog() { RunLogInfo = $"中转料仓正在配料,传送带停止", Time = DateTime.Now.ToString() });
}
else
{
@@ -1541,7 +1544,7 @@ namespace BPASmartClient.DosingSystem
SimensSend.GetInstance.SendSimens.Write("DB1.DBX702.0", 1);
}
}
if (DeviceInquire.GetInstance.devices[i].IpAddress != $"192.168.2.{Json<DevicePar>.Data.BaseParModel.StockCount * 10}"&& DeviceInquire.GetInstance.devices[i].IpAddress != $"192.168.2.{(Json<DevicePar>.Data.BaseParModel.StockCount-1) * 10}")
if (DeviceInquire.GetInstance.devices[i].IpAddress != $"192.168.2.{Json<DevicePar>.Data.BaseParModel.StockCount * 10}")
{

ushort deviceNum = DeviceInquire.GetInstance.DeviceLists[DeviceInquire.GetInstance.devices[i].IpAddress].deviceStatus.DeviceNum;
@@ -1598,50 +1601,19 @@ namespace BPASmartClient.DosingSystem
}
else
{
string x = $"192.168.2.{(Json<DevicePar>.Data.BaseParModel.StockCount - 1) * 10}";
if (DeviceInquire.GetInstance.DeviceLists.ContainsKey($"192.168.2.{ Json<DevicePar>.Data.BaseParModel.StockCount * 10}") && DeviceInquire.GetInstance.DeviceLists.ContainsKey($"192.168.2.{(Json<DevicePar>.Data.BaseParModel.StockCount - 1) * 10}"))
if (SimensSend.GetInstance.sendCtrlModel.SendInfo&& DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{(Json<DevicePar>.Data.BaseParModel.StockCount) * 10}"].deviceStatus.PailArrive == 1)
{
if (SimensSend.GetInstance.sendCtrlModel.SendInfo)
{
DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{Json<DevicePar>.Data.BaseParModel.StockCount * 10}"].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), (ushort)0);
if (DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{(Json<DevicePar>.Data.BaseParModel.StockCount - 1) * 10}"].deviceStatus.PailArrive == 1)
{
DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{(Json<DevicePar>.Data.BaseParModel.StockCount - 1) * 10}"].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), (ushort)0);
}
else
{
DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{(Json<DevicePar>.Data.BaseParModel.StockCount - 1) * 10}"].modbusTcp.Write<ushort>(DeviceAddress.TranspportSp.ToAdd(), 600);
DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{(Json<DevicePar>.Data.BaseParModel.StockCount - 1) * 10}"].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), (ushort)1);
}

}
else
{
if (DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{ Json<DevicePar>.Data.BaseParModel.StockCount * 10}"].deviceStatus.RunStatus != 2)
{
DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{ Json<DevicePar>.Data.BaseParModel.StockCount * 10}"].modbusTcp.Write<ushort>(DeviceAddress.TranspportSp.ToAdd(), 600);
DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{ Json<DevicePar>.Data.BaseParModel.StockCount * 10}"].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), (ushort)1);
}
else
{
DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{ Json<DevicePar>.Data.BaseParModel.StockCount * 10}"].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), (ushort)0);
}
if (DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{(Json<DevicePar>.Data.BaseParModel.StockCount) * 10}"].deviceStatus.PailArrive == 1|| DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{(Json<DevicePar>.Data.BaseParModel.StockCount - 1) * 10}"].deviceStatus.RunStatus == 2)
{
DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{(Json<DevicePar>.Data.BaseParModel.StockCount - 1) * 10}"].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), (ushort)0);
}
else
{
DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{(Json<DevicePar>.Data.BaseParModel.StockCount - 1) * 10}"].modbusTcp.Write<ushort>(DeviceAddress.TranspportSp.ToAdd(), 600);
DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{(Json<DevicePar>.Data.BaseParModel.StockCount - 1) * 10}"].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), (ushort)1);
}
}
DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{Json<DevicePar>.Data.BaseParModel.StockCount * 10}"].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), (ushort)0);
MessageNotify.GetInstance.runLogs.Add(new RunLog() { RunLogInfo = $"设备{DeviceInquire.GetInstance.devices[i].DeviceName}检测到有桶,并且料仓输送阻塞" +
$"" +
$"", Time = DateTime.Now.ToString() });
}
else
{
DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{Json<DevicePar>.Data.BaseParModel.StockCount * 10}"].modbusTcp.Write<ushort>(DeviceAddress.TranspportSp.ToAdd(), 600);
DeviceInquire.GetInstance.DeviceLists[$"192.168.2.{Json<DevicePar>.Data.BaseParModel.StockCount * 10}"].modbusTcp.Write<ushort>(DeviceAddress.TranspportSwitch.ToAdd(), (ushort)1);
}
}


}
}



+ 2
- 4
Test/MainWindow.xaml Dosyayı Görüntüle

@@ -15,12 +15,10 @@
HorizontalAlignment="Center"
VerticalAlignment="Center">

<Button
<TextBox
Width="150"
Height="30"
Margin="0 10"
Click="Button_Click"
Content="写入数据" />
Margin="0 10" x:Name="textBox"/>

<Button
Width="150"


+ 6
- 15
Test/MainWindow.xaml.cs Dosyayı Görüntüle

@@ -31,26 +31,17 @@ namespace Test
ICommunication mySiemens = new Siemens();
byte bit = 0;

private void Button_Click(object sender, RoutedEventArgs e)
{
bit++;
for (int i = 0; i < 32; i++)
{
int data = 0;
int item = data.SetBitValue(bit, true).ToBytes(BPA.Helper.DataFormat.BADC).ToInt();
mySiemens.Write($"DB4.DBD{2 + i * 4}", item).OnFail(s =>
{
MessageBox.Show(s);
});
}
MessageBox.Show("写入完成");
}

private void Button_Click_1(object sender, RoutedEventArgs e)
{
mySiemens.WithSiemens(CpuType.S71200, "192.168.1.13").UseConnected(() =>

mySiemens.WithSiemens(CpuType.S71200, "192.168.100.162").UseConnected(() =>
{
MessageBox.Show("设备连接成功");
//System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
byte[] bytes = Encoding.Unicode.GetBytes(textBox.Text);
mySiemens.Write<byte[]>("DB1.DBB0", bytes);
});
}
}


+ 1
- 0
Test/Test.csproj Dosyayı Görüntüle

@@ -11,6 +11,7 @@
<PackageReference Include="BPA.Communication" Version="1.0.116" />
<PackageReference Include="BPA.PahoMQ" Version="1.0.6" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="7.0.0" />
</ItemGroup>

</Project>

Yükleniyor…
İptal
Kaydet