浏览代码

Merge branch 'reconfiguration' of http://111.9.47.105:10244/bpa/BPASmartClient into reconfiguration

reconfiguration
lyw 4 个月前
父节点
当前提交
62f2f5f550
共有 3 个文件被更改,包括 47 次插入42 次删除
  1. +1
    -1
      BPASmartClient.Academy/BPASmartClient.Academy.csproj
  2. +1
    -0
      BPASmartClient.Academy/GlobalUsing.cs
  3. +45
    -41
      BPASmartClient.Academy/Model/Simens_PLC.cs

+ 1
- 1
BPASmartClient.Academy/BPASmartClient.Academy.csproj 查看文件

@@ -17,13 +17,13 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="BPA.Communication" Version="1.0.178" />
<PackageReference Include="LiveCharts.Wpf" Version="0.9.7" />
<PackageReference Include="OxyPlot.Wpf" Version="2.1.2" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\BPASmartClient.CustomResource\BPASmartClient.CustomResource.csproj" />
<ProjectReference Include="..\BPASmartClient.S7Net\BPASmartClient.S7Net.csproj" />
<ProjectReference Include="..\BPASmartClient.Update\BPASmartClient.Update.csproj" />
</ItemGroup>



+ 1
- 0
BPASmartClient.Academy/GlobalUsing.cs 查看文件

@@ -14,3 +14,4 @@ global using BPASmartClient.CustomResource.Pages.ViewModel;
global using BPASmartClient.CustomResource.Pages.View;
global using BPASmartClient.CustomResource.Pages.Model;
global using BPASmartClient.CustomResource.Pages.Enums;
global using BPA.Communication;

+ 45
- 41
BPASmartClient.Academy/Model/Simens_PLC.cs 查看文件

@@ -1,5 +1,4 @@
using BPA.Helper;
using BPASmartClient.S7Net;
using LiveCharts;
using Microsoft.Windows.Input;
using Newtonsoft.Json.Linq;
@@ -21,27 +20,32 @@ namespace BPASmartClient.Academy.Model
private Simens_PLC() { }
public DataFeedback dataFeedback { get; set; } = new DataFeedback();
public string id { get; set; } = "";
public SiemensHelper siemens { get; set; } = new SiemensHelper();
public DeviceCtrl deviceCtrl { get; set; }= new DeviceCtrl();
public bool IsConnected { get; set; }=false;
bool heart=false;
public void Connect()
//public SiemensHelper siemens { get; set; } = new SiemensHelper();
public ICommSiemens siemens { get; set; } = CommHelper.Siemens;
public DeviceCtrl deviceCtrl { get; set; } = new DeviceCtrl();
public bool IsConnected { get; set; } = false;
bool heart = false;
public void Connect()
{
Task.Factory.StartNew(() =>
{
var x = (NameValueCollection)ConfigurationManager.GetSection("FlexBatchSystem/PLCInfo");
if (x != null)
{
siemens.Connect(S7.Net.CpuType.S7200Smart, x.Get("IpAddress"), Convert.ToInt32(x.Get("Port")));
//siemens.Connect(S7.Net.CpuType.S7200Smart, x.Get("IpAddress"), Convert.ToInt32(x.Get("Port")));
CommHelper.CreateSiemens(CpuType.S7200Smart, x.Get("IpAddress"));
}
});



}
public void Init()
public void Init()
{
ThreadManage.GetInstance.StartLong(() =>
ThreadManage.GetInstance.StartLong(() =>
{
ReadStatus();
},"状态读取");
}, "状态读取");
ThreadManage.GetInstance.StartLong(() =>
{
Heartbeat();
@@ -51,45 +55,45 @@ namespace BPASmartClient.Academy.Model
ChartDataRead();
}, "曲线数据");
}
public void ReadStatus()
public void ReadStatus()
{
if (IsConnected)
{
deviceCtrl.M101 = siemens.Read<bool>("V2000.0");
deviceCtrl.M102 = siemens.Read<bool>("V2000.1");
deviceCtrl.M103 = siemens.Read<bool>("V2000.2");
deviceCtrl.VX100 = siemens.Read<bool>("V2000.3");
deviceCtrl.VX101 = siemens.Read<bool>("V2000.4");
deviceCtrl.VX102 = siemens.Read<bool>("V2000.5");
deviceCtrl.VX103 = siemens.Read<bool>("V2000.6");
deviceCtrl.VX104 = siemens.Read<bool>("V2000.7");
deviceCtrl.VX105 = siemens.Read<bool>("V2001.0");
heart = siemens.Read<bool>("V1003.7");
deviceCtrl.M101 = siemens.Read<bool>("V2000.0").Content;
deviceCtrl.M102 = siemens.Read<bool>("V2000.1").Content;
deviceCtrl.M103 = siemens.Read<bool>("V2000.2").Content;
deviceCtrl.VX100 = siemens.Read<bool>("V2000.3").Content;
deviceCtrl.VX101 = siemens.Read<bool>("V2000.4").Content;
deviceCtrl.VX102 = siemens.Read<bool>("V2000.5").Content;
deviceCtrl.VX103 = siemens.Read<bool>("V2000.6").Content;
deviceCtrl.VX104 = siemens.Read<bool>("V2000.7").Content;
deviceCtrl.VX105 = siemens.Read<bool>("V2001.0").Content;
heart = siemens.Read<bool>("V1003.7").Content;
Thread.Sleep(100);
}
}
public void ChartDataRead()
public void ChartDataRead()
{
if (id!="")
if (id != "")
{
SaveData saveData = new SaveData()
{
Id = id,
Name = dataFeedback.Name,
Date = DateTime.Now,
M101_Speed = siemens.Read<double>("VD2006"),
M102_Speed = siemens.Read<double>("VD2010"),
M103_Speed = siemens.Read<double>("VD2014"),
OpenValve = siemens.Read<double>("VD2018"),
TempWok = siemens.Read<double>("VD2022"),
TempMaterial = siemens.Read<double>("VD2026"),
TempVent = siemens.Read<double>("VD2030"),
PressureWok = siemens.Read<double>("VD2034"),
WeightWok = siemens.Read<double>("VD2038"),
M101_Speed = siemens.Read<double>("VD2006").Content,
M102_Speed = siemens.Read<double>("VD2010").Content,
M103_Speed = siemens.Read<double>("VD2014").Content,
OpenValve = siemens.Read<double>("VD2018").Content,
TempWok = siemens.Read<double>("VD2022").Content,
TempMaterial = siemens.Read<double>("VD2026").Content,
TempVent = siemens.Read<double>("VD2030").Content,
PressureWok = siemens.Read<double>("VD2034").Content,
WeightWok = siemens.Read<double>("VD2038").Content,
};


DataView(dataFeedback.M101_Speed, new DataValue() { DateTime = saveData.Date,Value = saveData.M101_Speed});
DataView(dataFeedback.M101_Speed, new DataValue() { DateTime = saveData.Date, Value = saveData.M101_Speed });
DataView(dataFeedback.M102_Speed, new DataValue() { DateTime = saveData.Date, Value = saveData.M102_Speed });
DataView(dataFeedback.M103_Speed, new DataValue() { DateTime = saveData.Date, Value = saveData.M103_Speed });
DataView(dataFeedback.OpenValve, new DataValue() { DateTime = saveData.Date, Value = saveData.OpenValve });
@@ -119,10 +123,10 @@ namespace BPASmartClient.Academy.Model
WeightWok = random.Next(0, 50),
};
Sqlite.GetInstance.saveDatas.Add(saveData);
DataView(dataFeedback.M101_Speed, new DataValue() { DateTime = date, Value =saveData.M101_Speed });
DataView(dataFeedback.M101_Speed, new DataValue() { DateTime = date, Value = saveData.M101_Speed });
DataView(dataFeedback.M102_Speed, new DataValue() { DateTime = date, Value = saveData.M102_Speed });
DataView(dataFeedback.M103_Speed, new DataValue() { DateTime = date, Value = saveData.M103_Speed});
DataView(dataFeedback.TempWok, new DataValue() { DateTime = date, Value =saveData.TempWok});
DataView(dataFeedback.M103_Speed, new DataValue() { DateTime = date, Value = saveData.M103_Speed });
DataView(dataFeedback.TempWok, new DataValue() { DateTime = date, Value = saveData.TempWok });
DataView(dataFeedback.TempMaterial, new DataValue() { DateTime = date, Value = saveData.TempMaterial });
DataView(dataFeedback.TempVent, new DataValue() { DateTime = date, Value = saveData.TempVent });
DataView(dataFeedback.OpenValve, new DataValue() { DateTime = date, Value = saveData.OpenValve });
@@ -130,13 +134,13 @@ namespace BPASmartClient.Academy.Model
DataView(dataFeedback.WeightWok, new DataValue() { DateTime = date, Value = saveData.WeightWok });


}
Thread.Sleep(1000);
}
public void DataView<T>(ChartValues<T> values,T value)
public void DataView<T>(ChartValues<T> values, T value)
{
if (values.Count>=100)
if (values.Count >= 100)
{
values.RemoveAt(0);
values.Add(value);
@@ -146,7 +150,7 @@ namespace BPASmartClient.Academy.Model
values.Add(value);
}
}
public void Heartbeat()
public void Heartbeat()
{
if (!heart)
{
@@ -158,7 +162,7 @@ namespace BPASmartClient.Academy.Model
GetInstance.Connect();
}

if (deviceCtrl.M101)
if (deviceCtrl.M101)
{
deviceCtrl.M101 = false;
}


正在加载...
取消
保存