@@ -13,6 +13,7 @@ | |||
<section name="StockInfo6" type="System.Configuration.NameValueSectionHandler"/> | |||
<section name="Services" type="System.Configuration.NameValueSectionHandler"/> | |||
<section name="MQTTParam" type="System.Configuration.NameValueSectionHandler"/> | |||
<section name="PLCInfo" type="System.Configuration.NameValueSectionHandler"/> | |||
</sectionGroup> | |||
</configSections> | |||
<FlexBatchSystem> | |||
@@ -66,5 +67,9 @@ | |||
<add key="IpAddress" value="111.9.47.105"/> | |||
<add key="Port" value="18883"/> | |||
</MQTTParam> | |||
<PLCInfo> | |||
<add key="IpAddress" value="192.168.2.11"/> | |||
<add key="Port" value="502"/> | |||
</PLCInfo> | |||
</FlexBatchSystem> | |||
</configuration> |
@@ -3,6 +3,7 @@ | |||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
xmlns:con="clr-namespace:BPASmartClient.CustomResource.Converters;assembly=BPASmartClient.CustomResource" | |||
xmlns:convert ="clr-namespace:BPASmartClient.Academy.Converter" | |||
xmlns:local="clr-namespace:BPASmartClient.Academy"> | |||
<Application.Resources> | |||
<ResourceDictionary> | |||
@@ -36,6 +37,9 @@ | |||
<ImageBrush x:Key="hbl" ImageSource="/BPASmartClient.CustomResource;component/Image/HBL.png" /> | |||
<ImageBrush x:Key="dbxt" ImageSource="/BPASmartClient.CustomResource;component/Image/顶部线条.png" /> | |||
</ResourceDictionary> | |||
<ResourceDictionary> | |||
<convert:DeviceCtrlConvert x:Key="deviceConvert"/> | |||
</ResourceDictionary> | |||
</ResourceDictionary.MergedDictionaries> | |||
</ResourceDictionary> | |||
@@ -1,4 +1,6 @@ | |||
using System.Configuration; | |||
using LiveCharts; | |||
using System.Collections.Specialized; | |||
using System.Configuration; | |||
using System.Data; | |||
using System.Windows; | |||
@@ -229,6 +231,11 @@ namespace BPASmartClient.Academy | |||
Json<LocalRecipe>.Read(); | |||
Json<DevicePar>.Read(); | |||
Json<LocaMaterial>.Read(); | |||
Sqlite.GetInstance.Init(); | |||
Simens_PLC.GetInstance.Connect(); | |||
Simens_PLC.GetInstance.Init(); | |||
} | |||
} | |||
@@ -16,8 +16,14 @@ | |||
<Content Include="hbl.ico" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<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> | |||
@@ -0,0 +1,101 @@ | |||
using BPASmartClient.CustomResource.UserControls.Enum; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Globalization; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using System.Windows.Data; | |||
using System.Windows.Media; | |||
namespace BPASmartClient.Academy.Converter | |||
{ | |||
public class DeviceCtrlConvert : IValueConverter | |||
{ | |||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | |||
{ | |||
if (parameter.ToString() == "1") | |||
{ | |||
if (value is bool) | |||
{ | |||
bool value_get = (bool)value; | |||
if (value_get) | |||
{ | |||
return 1; | |||
} | |||
else | |||
{ | |||
return 0; | |||
} | |||
} | |||
else | |||
{ | |||
return 0; | |||
} | |||
} | |||
else if (parameter.ToString() == "2") | |||
{ | |||
if (value is bool) | |||
{ | |||
bool value_get = (bool)value; | |||
if (value_get) | |||
{ | |||
return Color.FromRgb(227,26,26); | |||
} | |||
else | |||
{ | |||
return Color.FromRgb(255,255,255); | |||
} | |||
} | |||
else | |||
{ | |||
return Color.FromRgb(255, 255, 255); | |||
} | |||
} | |||
else if(parameter.ToString() == "3") | |||
{ | |||
if (value is bool) | |||
{ | |||
bool value_get = (bool)value; | |||
if (value_get) | |||
{ | |||
return MotorColor.Green; | |||
} | |||
else | |||
{ | |||
return MotorColor.Gray; | |||
} | |||
} | |||
else | |||
{ | |||
return MotorColor.Gray; | |||
} | |||
} | |||
else | |||
{ | |||
if (value is bool) | |||
{ | |||
bool value_get = (bool)value; | |||
if (value_get) | |||
{ | |||
return new SolidColorBrush(Color.FromRgb(227, 26, 26)); | |||
} | |||
else | |||
{ | |||
return new SolidColorBrush(Color.FromRgb(255, 255, 255)); | |||
} | |||
} | |||
else | |||
{ | |||
return new SolidColorBrush(Color.FromRgb(255, 255, 255)); | |||
} | |||
} | |||
} | |||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | |||
{ | |||
throw new NotImplementedException(); | |||
} | |||
} | |||
} |
@@ -0,0 +1,69 @@ | |||
using LiveCharts; | |||
using LiveCharts.SeriesAlgorithms; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.Academy.Model | |||
{ | |||
public class DataFeedback:NotifyBase | |||
{ | |||
private string _id = Guid.NewGuid().ToString(); | |||
public string Id | |||
{ | |||
get { return _id; } | |||
set { _id = value;OnPropertyChanged(); } | |||
} | |||
private string _name; | |||
public string Name | |||
{ | |||
get { return _name; } | |||
set { _name = value;OnPropertyChanged(); } | |||
} | |||
/// <summary> | |||
/// M101 速度曲线 | |||
/// </summary> | |||
public ChartValues<DataValue> M101_Speed { get; set; }= new ChartValues<DataValue>(); | |||
/// <summary> | |||
/// M102 速度曲线 | |||
/// </summary> | |||
public ChartValues<DataValue> M102_Speed { get; set; } = new ChartValues<DataValue>(); | |||
/// <summary> | |||
/// M102 速度曲线 | |||
/// </summary> | |||
public ChartValues<DataValue> M103_Speed { get; set; } = new ChartValues<DataValue>(); | |||
/// <summary> | |||
/// 比例阀开度曲线 | |||
/// </summary> | |||
public ChartValues<DataValue> OpenValve { get; set; } = new ChartValues<DataValue>(); | |||
/// <summary> | |||
/// 反应釜温度 | |||
/// </summary> | |||
public ChartValues<DataValue> TempWok { get; set; } = new ChartValues<DataValue>(); | |||
/// <summary> | |||
/// 配料罐温度 | |||
/// </summary> | |||
public ChartValues<DataValue> TempMaterial { get; set; } = new ChartValues<DataValue>(); | |||
/// <summary> | |||
/// 反应釜排气温度 | |||
/// </summary> | |||
public ChartValues<DataValue> TempVent { get; set; } = new ChartValues<DataValue>(); | |||
/// <summary> | |||
/// 反应釜压力 | |||
/// </summary> | |||
public ChartValues<DataValue> PressureWok { get; set; } = new ChartValues<DataValue>(); | |||
/// <summary> | |||
/// 反应釜重量 | |||
/// </summary> | |||
public ChartValues<DataValue> WeightWok { get; set; } = new ChartValues<DataValue>(); | |||
} | |||
} |
@@ -0,0 +1,38 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.Academy.Model | |||
{ | |||
public class DeviceCtrl:NotifyBase | |||
{ | |||
public bool M101 { get { return _m101; } set { _m101 = value;OnPropertyChanged(); } } | |||
private bool _m101 = false; | |||
private int myVar; | |||
public int MyProperty | |||
{ | |||
get { return myVar; } | |||
set { myVar = value; } | |||
} | |||
public bool M102 { get { return _m102; } set { _m102 = value; OnPropertyChanged(); } } | |||
private bool _m102 = false; | |||
public bool M103 { get { return _m103; } set { _m103 = value; OnPropertyChanged(); } } | |||
private bool _m103 = false; | |||
public bool VX100 { get { return _vx100; } set { _vx100 = value; OnPropertyChanged(); } } | |||
private bool _vx100 = false; | |||
public bool VX101 { get { return _vx101; } set { _vx101 = value; OnPropertyChanged(); } } | |||
private bool _vx101 = false; | |||
public bool VX102 { get { return _vx102; } set { _vx102 = value; OnPropertyChanged(); } } | |||
private bool _vx102 = false; | |||
public bool VX103 { get { return _vx103; } set { _vx103 = value; OnPropertyChanged(); } } | |||
private bool _vx103 = false; | |||
public bool VX104 { get { return _vx104; } set { _vx104 = value; OnPropertyChanged(); } } | |||
private bool _vx104 = false; | |||
public bool VX105 { get { return _vx100; } set { _vx100 = value; OnPropertyChanged(); } } | |||
private bool _vx105 = false; | |||
} | |||
} |
@@ -0,0 +1,53 @@ | |||
using LiveCharts; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.Academy.Model | |||
{ | |||
public class SaveData:NotifyBase | |||
{ | |||
public string Id { get; set; } | |||
public string Name { get; set; } | |||
public DateTime Date { get; set; } | |||
/// <summary> | |||
/// M101 速度曲线 | |||
/// </summary> | |||
public double M101_Speed { get; set; } | |||
/// <summary> | |||
/// M102 速度曲线 | |||
/// </summary> | |||
public double M102_Speed { get; set; } | |||
/// <summary> | |||
/// M102 速度曲线 | |||
/// </summary> | |||
public double M103_Speed { get; set; } | |||
/// <summary> | |||
/// 比例阀开度曲线 | |||
/// </summary> | |||
public double OpenValve { get; set; } | |||
/// <summary> | |||
/// 反应釜温度 | |||
/// </summary> | |||
public double TempWok { get; set; } | |||
/// <summary> | |||
/// 配料罐温度 | |||
/// </summary> | |||
public double TempMaterial { get; set; } | |||
/// <summary> | |||
/// 反应釜排气温度 | |||
/// </summary> | |||
public double TempVent { get; set; } | |||
/// <summary> | |||
/// 反应釜压力 | |||
/// </summary> | |||
public double PressureWok { get; set; } | |||
/// <summary> | |||
/// 反应釜重量 | |||
/// </summary> | |||
public double WeightWok { get; set; } | |||
} | |||
} |
@@ -0,0 +1,222 @@ | |||
using BPA.Helper; | |||
using BPASmartClient.S7Net; | |||
using LiveCharts; | |||
using Microsoft.Windows.Input; | |||
using Newtonsoft.Json.Linq; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Collections.Specialized; | |||
using System.Configuration; | |||
using System.Data; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.Academy.Model | |||
{ | |||
public class Simens_PLC | |||
{ | |||
private static Simens_PLC _instance; | |||
public static Simens_PLC GetInstance { get; set; } = _instance ??= new Simens_PLC(); | |||
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() | |||
{ | |||
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"))); | |||
} | |||
}); | |||
} | |||
public void Init() | |||
{ | |||
ThreadManage.GetInstance.StartLong(() => | |||
{ | |||
ReadStatus(); | |||
},"状态读取"); | |||
ThreadManage.GetInstance.StartLong(() => | |||
{ | |||
Heartbeat(); | |||
}, "心跳监听"); | |||
ThreadManage.GetInstance.StartLong(() => | |||
{ | |||
ChartDataRead(); | |||
}, "曲线数据"); | |||
} | |||
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"); | |||
Thread.Sleep(100); | |||
} | |||
} | |||
public void ChartDataRead() | |||
{ | |||
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"), | |||
}; | |||
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 }); | |||
DataView(dataFeedback.TempWok, new DataValue() { DateTime = saveData.Date, Value = saveData.TempWok }); | |||
DataView(dataFeedback.TempMaterial, new DataValue() { DateTime = saveData.Date, Value = saveData.TempMaterial }); | |||
DataView(dataFeedback.TempVent, new DataValue() { DateTime = saveData.Date, Value = saveData.TempVent }); | |||
DataView(dataFeedback.PressureWok, new DataValue() { DateTime = saveData.Date, Value = saveData.PressureWok }); | |||
DataView(dataFeedback.WeightWok, new DataValue() { DateTime = saveData.Date, Value = saveData.WeightWok }); | |||
} | |||
else | |||
{ | |||
DateTime date = DateTime.Now; | |||
Random random = new Random(); | |||
SaveData saveData = new SaveData() | |||
{ | |||
Id = id, | |||
Name = dataFeedback.Name, | |||
Date = DateTime.Now, | |||
M101_Speed = random.Next(0, 2000), | |||
M102_Speed = random.Next(0, 2000), | |||
M103_Speed = random.Next(0, 2000), | |||
OpenValve = random.Next(0, 5), | |||
TempWok = random.Next(-10, 150), | |||
TempMaterial = random.Next(-10, 150), | |||
TempVent = random.Next(-10, 150), | |||
PressureWok = random.NextDouble(), | |||
WeightWok = random.Next(0, 50), | |||
}; | |||
Sqlite.GetInstance.saveDatas.Add(saveData); | |||
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.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 }); | |||
DataView(dataFeedback.PressureWok, new DataValue() { DateTime = date, Value = saveData.PressureWok }); | |||
DataView(dataFeedback.WeightWok, new DataValue() { DateTime = date, Value = saveData.WeightWok }); | |||
} | |||
Thread.Sleep(1000); | |||
} | |||
public void DataView<T>(ChartValues<T> values,T value) | |||
{ | |||
if (values.Count>=100) | |||
{ | |||
values.RemoveAt(0); | |||
values.Add(value); | |||
} | |||
else | |||
{ | |||
values.Add(value); | |||
} | |||
} | |||
public void Heartbeat() | |||
{ | |||
if (!heart) | |||
{ | |||
siemens.Write<bool>("V1003.7", true); | |||
} | |||
else | |||
{ | |||
IsConnected = false; | |||
GetInstance.Connect(); | |||
} | |||
if (deviceCtrl.M101) | |||
{ | |||
deviceCtrl.M101 = false; | |||
} | |||
else | |||
{ | |||
deviceCtrl.M101 = true; | |||
} | |||
if (deviceCtrl.VX100) | |||
{ | |||
deviceCtrl.VX100 = false; | |||
} | |||
else | |||
{ | |||
deviceCtrl.VX100 = true; | |||
} | |||
if (deviceCtrl.M102) | |||
{ | |||
deviceCtrl.M102 = false; | |||
} | |||
else | |||
{ | |||
deviceCtrl.M102 = true; | |||
} | |||
if (deviceCtrl.VX101) | |||
{ | |||
deviceCtrl.VX101 = false; | |||
} | |||
else | |||
{ | |||
deviceCtrl.VX101 = true; | |||
} | |||
if (deviceCtrl.VX102) | |||
{ | |||
deviceCtrl.VX102 = false; | |||
} | |||
else | |||
{ | |||
deviceCtrl.VX102 = true; | |||
} | |||
if (deviceCtrl.VX103) | |||
{ | |||
deviceCtrl.VX103 = false; | |||
deviceCtrl.VX104 = false; | |||
deviceCtrl.VX105 = false; | |||
} | |||
else | |||
{ | |||
deviceCtrl.VX103 = true; | |||
deviceCtrl.VX104 = true; | |||
deviceCtrl.VX105 = true; | |||
} | |||
Thread.Sleep(3000); | |||
} | |||
} | |||
} |
@@ -0,0 +1,73 @@ | |||
using SqlSugar; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.IO; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.Academy.Model | |||
{ | |||
public class Sqlite | |||
{ | |||
private static Sqlite instance; | |||
public static Sqlite GetInstance { get; set; } = instance ??= new Sqlite(); | |||
private Sqlite() { } | |||
public List<SaveData> saveDatas { get; set; } = new List<SaveData>(); | |||
static string path | |||
{ | |||
get | |||
{ | |||
Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory); | |||
return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "AccessFile\\DB\\data.db"); | |||
} | |||
} | |||
public SqlSugarScope Db = new SqlSugarScope(new ConnectionConfig() | |||
{ | |||
ConnectionString = $"Data Source = {path}", | |||
DbType = DbType.Sqlite, | |||
IsAutoCloseConnection = true, | |||
}); | |||
public void Init() | |||
{ | |||
try | |||
{ | |||
if (!File.Exists(path)) | |||
{ | |||
Db.DbMaintenance.CreateDatabase(); | |||
Db.CodeFirst.SetStringDefaultLength(100).InitTables<SaveData>(); | |||
} | |||
else | |||
{ | |||
MessageNotify.GetInstance.ShowRunLog("创建失败"); | |||
} | |||
} | |||
catch (Exception) | |||
{ | |||
throw; | |||
} | |||
} | |||
public bool AddData(SaveData dfb) | |||
{ | |||
try | |||
{ | |||
return Db.Insertable(dfb).ExecuteCommand() > 0; | |||
} | |||
catch (Exception) | |||
{ | |||
return false; | |||
} | |||
} | |||
public List<String> SelectAllName() | |||
{ | |||
return Db.Queryable<SaveData>() | |||
.Select(x => x.Name) | |||
.Distinct() | |||
.ToList(); | |||
} | |||
} | |||
} |
@@ -11,7 +11,11 @@ | |||
mc:Ignorable="d"> | |||
<Viewbox Stretch="Uniform"> | |||
<Canvas Width="800" Height="450"> | |||
<TextBlock | |||
Canvas.Left="10" | |||
Canvas.Top="20" | |||
Foreground="White" | |||
Text="配料搅拌" /> | |||
<StackPanel | |||
Canvas.Left="56" | |||
Canvas.Top="35" | |||
@@ -63,14 +67,62 @@ | |||
</bpa:HandValve> | |||
</StackPanel> | |||
<bpa:PipeLineH Width="198" Height="8" Canvas.Left="229" Canvas.Top="208" Direction="0"/> | |||
<bpa:PipeLineTL Width="16" Margin="0 0 0 -8" Canvas.Left="427" Canvas.Top="200" Direction="0" /> | |||
<bpa:PipeLineV Width="8" Height="23" Canvas.Left="435" Canvas.Top="177" Direction="0" /> | |||
<bpa:PipeLineV Width="8" Height="100" Canvas.Left="584" Canvas.Top="185" Direction="0" /> | |||
<bpa:PipeLineV Width="8" Height="50" Canvas.Left="596" Canvas.Top="300" Direction="0" /> | |||
<bpa:Tanks Width="60" Height="60" Margin="0 -5 -15 0" Canvas.Left="570" Canvas.Top="250"/> | |||
<bpa:HandValve Width="25" Canvas.Left="591" Canvas.Top="350" RenderTransformOrigin="0.5,0.5"> | |||
<bpa:PipeLineH | |||
Canvas.Left="229" | |||
Canvas.Top="208" | |||
Width="198" | |||
Height="8" | |||
Direction="0" /> | |||
<bpa:PipeLineTL | |||
Canvas.Left="427" | |||
Canvas.Top="200" | |||
Width="16" | |||
Margin="0,0,0,-8" | |||
Direction="0" /> | |||
<bpa:PipeLineV | |||
Canvas.Left="435" | |||
Canvas.Top="177" | |||
Width="8" | |||
Height="23" | |||
Direction="0" /> | |||
<bpa:PipeLineV | |||
Canvas.Left="584" | |||
Canvas.Top="185" | |||
Width="8" | |||
Height="100" | |||
Direction="0" /> | |||
<bpa:HandValve | |||
Canvas.Left="579" | |||
Canvas.Top="240" | |||
Width="25" | |||
RenderTransformOrigin="0.5,0.5"> | |||
<bpa:HandValve.RenderTransform> | |||
<TransformGroup> | |||
<ScaleTransform ScaleX="0.926" ScaleY="1.08" /> | |||
<SkewTransform /> | |||
<RotateTransform Angle="90" /> | |||
<TranslateTransform /> | |||
</TransformGroup> | |||
</bpa:HandValve.RenderTransform> | |||
</bpa:HandValve> | |||
<bpa:PipeLineV | |||
Canvas.Left="596" | |||
Canvas.Top="330" | |||
Width="8" | |||
Height="50" | |||
Direction="0" /> | |||
<bpa:Tanks | |||
Canvas.Left="570" | |||
Canvas.Top="280" | |||
Width="60" | |||
Height="60" | |||
Margin="0,-5,-15,0" /> | |||
<bpa:HandValve | |||
Canvas.Left="591" | |||
Canvas.Top="350" | |||
Width="25" | |||
RenderTransformOrigin="0.5,0.5"> | |||
<bpa:HandValve.RenderTransform> | |||
<TransformGroup> | |||
<ScaleTransform ScaleX="0.926" ScaleY="1.08" /> | |||
@@ -81,35 +133,121 @@ | |||
</bpa:HandValve.RenderTransform> | |||
</bpa:HandValve> | |||
<StackPanel Orientation="Horizontal" Canvas.Left="435" Canvas.Top="160"> | |||
<bpa:PipeLineBR Width="16" Margin="0 0 0 -8" Direction="0" /> | |||
<bpa:PipeLineH Width="50" Height="8" Direction="0"/> | |||
<bpa:HandValve Width="25" Margin="-1 -7 0 0" Panel.ZIndex="1"/> | |||
<bpa:PipeLineH Width="50" Height="8" Margin="-6 0 0 0" Panel.ZIndex="0" Direction="0"/> | |||
<StackPanel | |||
Canvas.Left="435" | |||
Canvas.Top="160" | |||
Orientation="Horizontal"> | |||
<bpa:PipeLineBR | |||
Width="16" | |||
Margin="0,0,0,-8" | |||
Direction="0" /> | |||
<bpa:PipeLineH | |||
Width="50" | |||
Height="8" | |||
Direction="0" /> | |||
<bpa:HandValve | |||
Width="25" | |||
Margin="-1,-7,0,0" | |||
Panel.ZIndex="1" /> | |||
<bpa:PipeLineH | |||
Width="50" | |||
Height="8" | |||
Margin="-6,0,0,0" | |||
Panel.ZIndex="0" | |||
Direction="0" /> | |||
</StackPanel> | |||
<StackPanel Orientation="Horizontal" Canvas.Left="427" Canvas.Top="200"> | |||
<bpa:PipeLineH Width="73" Height="8" Direction="0"/> | |||
<bpa:HandValve Width="25" Margin="-1 -7 0 0" Panel.ZIndex="1"/> | |||
<bpa:PipeLineH Width="120" Height="8" Margin="-6 0 0 0" Panel.ZIndex="0" Direction="0"/> | |||
<bpa:PipeLineTL Width="16" Margin="0 0 0 8" Direction="0" /> | |||
<StackPanel | |||
Canvas.Left="427" | |||
Canvas.Top="200" | |||
Orientation="Horizontal"> | |||
<bpa:PipeLineH | |||
Width="73" | |||
Height="8" | |||
Direction="0" /> | |||
<bpa:HandValve | |||
Width="25" | |||
Margin="-1,-7,0,0" | |||
Panel.ZIndex="1" /> | |||
<bpa:PipeLineH | |||
Width="120" | |||
Height="8" | |||
Margin="-6,0,0,0" | |||
Panel.ZIndex="0" | |||
Direction="0" /> | |||
<bpa:PipeLineTL | |||
Width="16" | |||
Margin="0,0,0,8" | |||
Direction="0" /> | |||
</StackPanel> | |||
<bpa:PipeLineV Width="8" Height="30" Canvas.Left="646" Canvas.Top="170" Direction="0" /> | |||
<bpa:PipeLineBL Width="16" Canvas.Left="638" Canvas.Top="154" Direction="0" /> | |||
<bpa:PipeLineH Width="31" Height="8" Canvas.Left="607" Canvas.Top="154" Direction="0"/> | |||
<bpa:PipeLineH Width="65" Height="15" Canvas.Left="144" Canvas.Top="244" Direction="0"/> | |||
<bpa:PipeLineH Width="65" Height="15" Canvas.Left="258" Canvas.Top="244" Direction="0"/> | |||
<bpa:PipeLineTL Width="30" Canvas.Left="321" Canvas.Top="229" Direction="0" /> | |||
<bpa:PipeLineV Width="15" Height="50" Canvas.Left="336" Canvas.Top="180" Direction="0" /> | |||
<bpa:PipeLineV Width="15" Height="110" Canvas.Left="336" Canvas.Top="40" Direction="0" /> | |||
<bpa:PipeLineBR Width="30" Canvas.Left="336" Canvas.Top="10" Direction="0" /> | |||
<bpa:PipeLineH Width="200" Height="15" Canvas.Left="366" Canvas.Top="10" Direction="0"/> | |||
<bpa:HandValve Width="45" Height="65" Canvas.Left="327" Canvas.Top="136" RenderTransformOrigin="0.5,0.5"> | |||
<bpa:PipeLineV | |||
Canvas.Left="646" | |||
Canvas.Top="170" | |||
Width="8" | |||
Height="30" | |||
Direction="0" /> | |||
<bpa:PipeLineBL | |||
Canvas.Left="638" | |||
Canvas.Top="154" | |||
Width="16" | |||
Direction="0" /> | |||
<bpa:PipeLineH | |||
Canvas.Left="607" | |||
Canvas.Top="154" | |||
Width="31" | |||
Height="8" | |||
Direction="0" /> | |||
<bpa:PipeLineH | |||
Canvas.Left="144" | |||
Canvas.Top="244" | |||
Width="65" | |||
Height="15" | |||
Direction="0" /> | |||
<bpa:PipeLineH | |||
Canvas.Left="258" | |||
Canvas.Top="244" | |||
Width="65" | |||
Height="15" | |||
Direction="0" /> | |||
<bpa:PipeLineTL | |||
Canvas.Left="321" | |||
Canvas.Top="229" | |||
Width="30" | |||
Direction="0" /> | |||
<bpa:PipeLineV | |||
Canvas.Left="336" | |||
Canvas.Top="180" | |||
Width="15" | |||
Height="50" | |||
Direction="0" /> | |||
<bpa:PipeLineV | |||
Canvas.Left="336" | |||
Canvas.Top="40" | |||
Width="15" | |||
Height="110" | |||
Direction="0" /> | |||
<bpa:PipeLineBR | |||
Canvas.Left="336" | |||
Canvas.Top="10" | |||
Width="30" | |||
Direction="0" /> | |||
<bpa:PipeLineH | |||
Canvas.Left="366" | |||
Canvas.Top="10" | |||
Width="200" | |||
Height="15" | |||
Direction="0" /> | |||
<bpa:HandValve | |||
Canvas.Left="327" | |||
Canvas.Top="136" | |||
Width="45" | |||
Height="65" | |||
RenderTransformOrigin="0.5,0.5"> | |||
<bpa:HandValve.RenderTransform> | |||
<TransformGroup> | |||
<ScaleTransform ScaleX="0.926" ScaleY="1.08" /> | |||
@@ -121,10 +259,20 @@ | |||
</bpa:HandValve> | |||
<StackPanel Canvas.Left="555" Canvas.Top="10"> | |||
<bpa:PipeLineBL Width="30" Direction="0" /> | |||
<bpa:Condenser Width="65" Height="80" Margin="0 0 -15 0"/> | |||
<bpa:PipeLineV Width="8" Height="20" Margin="0 -4 -15 0" Direction="0" /> | |||
<bpa:Tanks Width="60" Height="60" Margin="0 -5 -15 0" /> | |||
<bpa:PipeLineBL Width="30" Direction="0" /> | |||
<bpa:Condenser | |||
Width="65" | |||
Height="80" | |||
Margin="0,0,-15,0" /> | |||
<bpa:PipeLineV | |||
Width="8" | |||
Height="20" | |||
Margin="0,-4,-15,0" | |||
Direction="0" /> | |||
<bpa:Tanks | |||
Width="60" | |||
Height="60" | |||
Margin="0,-5,-15,0" /> | |||
</StackPanel> | |||
<StackPanel | |||
@@ -132,7 +280,11 @@ | |||
Canvas.Top="175" | |||
Width="65" | |||
Height="150"> | |||
<bpa:MotorTwo Width="40" Height="30" Margin="0 0 0 -1" RenderTransformOrigin="0.5,0.5"> | |||
<bpa:MotorTwo | |||
Width="40" | |||
Height="30" | |||
Margin="0,0,0,-1" | |||
RenderTransformOrigin="0.5,0.5"> | |||
<bpa:MotorTwo.RenderTransform> | |||
<TransformGroup> | |||
<ScaleTransform /> | |||
@@ -142,7 +294,10 @@ | |||
</TransformGroup> | |||
</bpa:MotorTwo.RenderTransform> | |||
</bpa:MotorTwo> | |||
<bpa:Joint Width="40" Height="30" Margin="0 0 0 -3"/> | |||
<bpa:Joint | |||
Width="40" | |||
Height="30" | |||
Margin="0,0,0,-3" /> | |||
<bpa:JAR Width="65" Height="65" /> | |||
<bpa:HandValve | |||
Width="45" | |||
@@ -165,11 +320,11 @@ | |||
<bpa:PipeLineV Margin="418,58,362,194" Direction="0" /> | |||
<bpa:PipeLineH Width="65" Margin="333,276,402,154" /> | |||
<bpa:PipeLineH Width="65" Margin="458,19,277,411" /> | |||
<bpa:PipeLineV Margin="543,310,237,104" Direction="0" /> | |||
<bpa:PipeLineV Margin="543,160,237,255" Direction="0" /> | |||
<bpa:PipeLineV Margin="543,251,237,164" Direction="0" /> | |||
<bpa:MotorTwo Margin="253,222,465,184" RenderTransformOrigin="0.5,0.5"> | |||
<bpa:MotorTwo.RenderTransform> | |||
@@ -1,4 +1,11 @@ | |||
using System; | |||
using BPASmartClient.Academy.Model; | |||
using LiveCharts; | |||
using LiveCharts.Wpf; | |||
using Newtonsoft.Json.Linq; | |||
using OxyPlot; | |||
using OxyPlot.Axes; | |||
using OxyPlot.Series; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
@@ -24,5 +31,246 @@ namespace BPASmartClient.Academy.View | |||
{ | |||
InitializeComponent(); | |||
} | |||
private void Start_Click(object sender, RoutedEventArgs e) | |||
{ | |||
if (recipeName.Text!="") | |||
{ | |||
switch (start_check.Content.ToString()) | |||
{ | |||
case "系统启动": | |||
start_check.IsChecked = true; | |||
DataFeedback dataFeedback = new DataFeedback(); | |||
dataFeedback.Name = recipeName.Text; | |||
Simens_PLC.GetInstance.id = dataFeedback.Id; | |||
Simens_PLC.GetInstance.dataFeedback = dataFeedback; | |||
Sqlite.GetInstance.saveDatas.Clear(); | |||
start_check.Content = "系统停止"; | |||
break; | |||
case "系统停止": | |||
start_check.IsChecked = false; | |||
Simens_PLC.GetInstance.id = ""; | |||
start_check.Content = "系统启动"; | |||
break; | |||
default: | |||
break; | |||
} | |||
} | |||
else | |||
{ | |||
MessageNotify.GetInstance.ShowDialog("请输入名称后,再开始测试!!", DialogType.Information); | |||
start_check.IsChecked = false; | |||
} | |||
} | |||
private void auto_click(object sender, RoutedEventArgs e) | |||
{ | |||
RadioButton radioButton = (RadioButton)sender; | |||
switch (radioButton.Content.ToString()) | |||
{ | |||
case "自动升温": | |||
blf_view.Visibility = Visibility.Collapsed; | |||
break; | |||
case "手动升温": | |||
blf_view.Visibility = Visibility.Visible; | |||
break; | |||
default: | |||
break; | |||
} | |||
} | |||
private void Open_Click(object sender, RoutedEventArgs e) | |||
{ | |||
RadioButton radioButton = sender as RadioButton; | |||
int bit = Convert.ToInt32(radioButton.Tag.ToString()); | |||
if (bit<8) | |||
{ | |||
Simens_PLC.GetInstance.siemens.Write<bool>($"V2000.{bit}", true); | |||
} | |||
else | |||
{ | |||
Simens_PLC.GetInstance.siemens.Write<bool>($"V2001.{bit-8}", true); | |||
} | |||
} | |||
private void Close_Click(object sender, RoutedEventArgs e) | |||
{ | |||
RadioButton radioButton = sender as RadioButton; | |||
int bit = Convert.ToInt32(radioButton.Tag.ToString()); | |||
if (bit < 8) | |||
{ | |||
Simens_PLC.GetInstance.siemens.Write<bool>($"V2000.{bit}", false); | |||
} | |||
else | |||
{ | |||
Simens_PLC.GetInstance.siemens.Write<bool>($"V2001.{bit - 8}", false); | |||
} | |||
} | |||
public PlotModel plotModel { get; set; } = new PlotModel(); | |||
private void DataView_CLick(object sender, MouseButtonEventArgs e) | |||
{ | |||
CartesianChart liveCharts = sender as CartesianChart; | |||
OxyPlot.Series.LineSeries line = new OxyPlot.Series.LineSeries() { Title = "反应釜温度", MarkerType = MarkerType.Circle, MarkerFill = OxyColor.FromRgb(110, 79, 79), MarkerSize = 2, InterpolationAlgorithm = InterpolationAlgorithms.CanonicalSpline }; | |||
OxyPlot.Series.LineSeries line_1 = new OxyPlot.Series.LineSeries() { Title = "反应釜排气温度", MarkerType = MarkerType.Circle, MarkerFill = OxyColor.FromRgb(110, 79, 79), MarkerSize = 2, InterpolationAlgorithm = InterpolationAlgorithms.CanonicalSpline }; | |||
OxyPlot.Series.LineSeries line_2 = new OxyPlot.Series.LineSeries() { Title = "配料罐温度", MarkerType = MarkerType.Circle, MarkerFill = OxyColor.FromRgb(110, 79, 79), MarkerSize = 2, InterpolationAlgorithm = InterpolationAlgorithms.CanonicalSpline }; | |||
switch (liveCharts.ToolTip) | |||
{ | |||
case "温度曲线": | |||
plotModel.Series.Clear(); | |||
plotModel = new PlotModel() { Title = "温度曲线"}; | |||
chartGrid.Visibility = Visibility.Visible; | |||
List<DataPoint> twValues = new List<DataPoint>(); | |||
List<DataPoint> tvValues = new List<DataPoint>(); | |||
List<DataPoint> tmValues = new List<DataPoint>(); | |||
Sqlite.GetInstance.saveDatas.ForEach(t => | |||
{ | |||
twValues.Add(new DataPoint(DateTimeAxis.ToDouble(t.Date),t.TempWok)); | |||
tvValues.Add(new DataPoint(DateTimeAxis.ToDouble(t.Date), t.TempVent)); | |||
tmValues.Add(new DataPoint(DateTimeAxis.ToDouble(t.Date), t.TempMaterial)); | |||
}); | |||
line.Points.AddRange(twValues); | |||
line_1.Points.AddRange(tvValues); | |||
line_2.Points.AddRange(tmValues); | |||
if (!(plotModel.Axes.Count>0)) | |||
{ | |||
plotModel.Axes.Add(new DateTimeAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "时间",StringFormat="hh:mm:ss" }); | |||
plotModel.Axes.Add(new LinearAxis() { Key = "y1", Title = "温度/℃", Position = OxyPlot.Axes.AxisPosition.Left, LabelFormatter = value => value.ToString("f2"), }); | |||
} | |||
plotModel.Series.Add(line); | |||
plotModel.Series.Add(line_1); | |||
plotModel.Series.Add(line_2); | |||
plotModel.InvalidatePlot(true);//重新加载曲线 | |||
chartView.Model = plotModel; | |||
break; | |||
case "转速曲线": | |||
plotModel.Series.Clear(); | |||
plotModel = new PlotModel() { Title = "转速曲线"}; | |||
chartGrid.Visibility = Visibility.Visible; | |||
List<DataPoint> m101 = new List<DataPoint>(); | |||
List<DataPoint> m102 = new List<DataPoint>(); | |||
List<DataPoint> m103 = new List<DataPoint>(); | |||
Sqlite.GetInstance.saveDatas.ForEach(t => | |||
{ | |||
m101.Add(new DataPoint(DateTimeAxis.ToDouble(t.Date), t.M101_Speed)); | |||
m102.Add(new DataPoint(DateTimeAxis.ToDouble(t.Date), t.M102_Speed)); | |||
m103.Add(new DataPoint(DateTimeAxis.ToDouble(t.Date), t.M103_Speed)); | |||
}); | |||
line.Points.AddRange(m101); | |||
line_1.Points.AddRange(m102); | |||
line_2.Points.AddRange(m103); | |||
if (!(plotModel.Axes.Count > 0)) | |||
{ | |||
plotModel.Axes.Add(new DateTimeAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "时间/s", StringFormat = "hh:mm:ss" }); | |||
plotModel.Axes.Add(new LinearAxis() { Key = "y1", Title = "转速/rpm", Position = OxyPlot.Axes.AxisPosition.Left, LabelFormatter = value => value.ToString("f2"), }); | |||
} | |||
plotModel.Series.Add(line); | |||
plotModel.Series.Add(line_1); | |||
plotModel.Series.Add(line_2); | |||
plotModel.InvalidatePlot(true);//重新加载曲线 | |||
chartView.Model = plotModel; | |||
break; | |||
case "比例阀开度曲线": | |||
plotModel.Series.Clear(); | |||
plotModel = new PlotModel() { Title = "比例阀开度曲线" }; | |||
chartGrid.Visibility = Visibility.Visible; | |||
List<DataPoint> open = new List<DataPoint>(); | |||
Sqlite.GetInstance.saveDatas.ForEach(t => | |||
{ | |||
open.Add(new DataPoint(DateTimeAxis.ToDouble(t.Date), t.OpenValve)); | |||
}); | |||
line.Points.AddRange(open); | |||
if (!(plotModel.Axes.Count > 0)) | |||
{ | |||
plotModel.Axes.Add(new DateTimeAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "时间/s", StringFormat = "hh:mm:ss" }); | |||
plotModel.Axes.Add(new LinearAxis() { Key = "y1", Title = "比例阀开度/挡", Position = OxyPlot.Axes.AxisPosition.Left, LabelFormatter = value => value.ToString("f2"), }); | |||
} | |||
plotModel.Series.Add(line); | |||
plotModel.InvalidatePlot(true);//重新加载曲线 | |||
chartView.Model = plotModel; | |||
break; | |||
case "压力曲线": | |||
plotModel.Series.Clear(); | |||
plotModel = new PlotModel() { Title = "反应釜压力曲线" }; | |||
chartGrid.Visibility = Visibility.Visible; | |||
List<DataPoint> pressure = new List<DataPoint>(); | |||
Sqlite.GetInstance.saveDatas.ForEach(t => | |||
{ | |||
pressure.Add(new DataPoint(DateTimeAxis.ToDouble(t.Date), t.PressureWok)); | |||
}); | |||
line.Points.AddRange(pressure); | |||
if (!(plotModel.Axes.Count > 0)) | |||
{ | |||
plotModel.Axes.Add(new DateTimeAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "时间/s", StringFormat = "hh:mm:ss" }); | |||
plotModel.Axes.Add(new LinearAxis() { Key = "y1", Title = "反应釜压力/Mpa", Position = OxyPlot.Axes.AxisPosition.Left, LabelFormatter = value => value.ToString("f2"), }); | |||
} | |||
plotModel.Series.Add(line); | |||
plotModel.InvalidatePlot(true);//重新加载曲线 | |||
chartView.Model = plotModel; | |||
break; | |||
case "重量曲线": | |||
plotModel.Series.Clear(); | |||
plotModel = new PlotModel() { Title = "反应釜重量曲线" }; | |||
chartGrid.Visibility = Visibility.Visible; | |||
List<DataPoint> ww = new List<DataPoint>(); | |||
Sqlite.GetInstance.saveDatas.ForEach(t => | |||
{ | |||
ww.Add(new DataPoint(DateTimeAxis.ToDouble(t.Date), t.WeightWok)); | |||
}); | |||
line.Points.AddRange(ww); | |||
if (!(plotModel.Axes.Count > 0)) | |||
{ | |||
plotModel.Axes.Add(new DateTimeAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "时间/s", StringFormat = "hh:mm:ss" }); | |||
plotModel.Axes.Add(new LinearAxis() { Key = "y1", Title = "反应釜重量/kg", Position = OxyPlot.Axes.AxisPosition.Left, LabelFormatter = value => value.ToString("f2"), }); | |||
} | |||
plotModel.Series.Add(line); | |||
plotModel.InvalidatePlot(true);//重新加载曲线 | |||
chartView.Model = plotModel; | |||
break; | |||
default: | |||
break; | |||
} | |||
} | |||
//private void xxx_MouseMove(object sender, MouseEventArgs e) | |||
//{ | |||
// CartesianChart liveCharts = sender as CartesianChart; | |||
// var possition = e.GetPosition(liveCharts); | |||
//} | |||
//Double old; | |||
//private void xxx_MouseDown(object sender, MouseButtonEventArgs e) | |||
//{ | |||
// CartesianChart liveCharts = sender as CartesianChart; | |||
// var point = e.GetPosition(liveCharts); | |||
// old = liveCharts.AxisX[0].(point.X); | |||
//} | |||
//private void Zoom_MouseWheel(object sender, MouseWheelEventArgs e) | |||
//{ | |||
// double MinValue = xxx.AxisX[0].MinValue; | |||
// double MaxValue = xxx.AxisX[0].MaxValue; | |||
// ChartValues<DataValue> twValues = new ChartValues<DataValue>(); | |||
// ChartValues<DataValue> tvValues = new ChartValues<DataValue>(); | |||
// ChartValues<DataValue> tmValues = new ChartValues<DataValue>(); | |||
// Sqlite.GetInstance.saveDatas.ForEach(t => | |||
// { | |||
// if (t.Date.Ticks >= MinValue && t.Date.Ticks <= MaxValue) | |||
// { | |||
// twValues.Add(new DataValue() { DateTime = t.Date, Value = t.TempWok }); | |||
// tvValues.Add(new DataValue() { DateTime = t.Date, Value = t.TempVent }); | |||
// tmValues.Add(new DataValue() { DateTime = t.Date, Value = t.TempMaterial }); | |||
// } | |||
// }); | |||
// xxx.Series[0].Values = twValues; | |||
// xxx.Series[1].Values = tvValues; | |||
// xxx.Series[2].Values = tmValues; | |||
//} | |||
} | |||
} |
@@ -1,16 +1,94 @@ | |||
using System; | |||
using LiveCharts.Configurations; | |||
using LiveCharts; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using System.Windows; | |||
namespace BPASmartClient.Academy.ViewModel | |||
{ | |||
public class DeviceMotionViewModel : NotifyBase | |||
{ | |||
public DeviceMotionViewModel() | |||
{ | |||
var mapper = Mappers.Xy<DataValue>() | |||
.X(model => model.DateTime.Ticks) | |||
.Y(model => model.Value); | |||
Charting.For<DataValue>(mapper); | |||
DateTimeFormatter = value => new DateTime((long)value).ToString("mm:ss"); | |||
doubleFormatter = value=> value.ToString("F2"); | |||
AxisStep = TimeSpan.FromSeconds(2).Ticks; | |||
AxisUnit = TimeSpan.TicksPerSecond; | |||
ThreadManage.GetInstance.StartLong(() => { SetAxisLimits(DateTime.Now); }, "时间显示"); | |||
} | |||
private DataFeedback dataFeedback = Simens_PLC.GetInstance.dataFeedback; | |||
public DataFeedback DataFeedback { get { return dataFeedback; } set { dataFeedback = value;OnPropertyChanged(); } } | |||
public Func<double, string> DateTimeFormatter { get; set; } | |||
public Func<double, string> doubleFormatter { get; set; } | |||
public double AxisStep { get; set; } | |||
public double AxisUnit { get; set; } | |||
private double _axisMax; | |||
public double AxisMax | |||
{ | |||
get { return _axisMax; } | |||
set | |||
{ | |||
_axisMax = value; | |||
OnPropertyChanged("AxisMax"); | |||
} | |||
} | |||
private double _axisMin = DateTime.Now.Ticks; | |||
public double AxisMin | |||
{ | |||
get { return _axisMin; } | |||
set | |||
{ | |||
_axisMin = value; | |||
OnPropertyChanged("AxisMin"); | |||
} | |||
} | |||
private void SetAxisLimits(DateTime now) | |||
{ | |||
if (Simens_PLC.GetInstance.id != "") | |||
{ | |||
if (DataFeedback.TempWok.Count > 0) | |||
{ | |||
AxisMax = now.Ticks + TimeSpan.FromSeconds(3).Ticks; | |||
AxisMin = now.Ticks - TimeSpan.FromSeconds(8).Ticks; | |||
} | |||
} | |||
else | |||
{ | |||
AxisMax = now.Ticks + TimeSpan.FromSeconds(3).Ticks; | |||
AxisMin = now.Ticks - TimeSpan.FromSeconds(8).Ticks; | |||
} | |||
Thread.Sleep(1000); | |||
} | |||
private DeviceCtrl _deviceStatus = Simens_PLC.GetInstance.deviceCtrl; | |||
public DeviceCtrl DeviceStatus | |||
{ | |||
get { return _deviceStatus = Simens_PLC.GetInstance.deviceCtrl; } | |||
set { _deviceStatus = Simens_PLC.GetInstance.deviceCtrl = value;OnPropertyChanged(); } | |||
} | |||
} | |||
public class DataValue:NotifyBase | |||
{ | |||
private DateTime _dateTime; | |||
public DateTime DateTime {get { return _dateTime; }set { _dateTime = value; OnPropertyChanged(); } } | |||
private double _value; | |||
public double Value { get { return _value; } set { _value = value; OnPropertyChanged(); } } | |||
} | |||
} |
@@ -60,7 +60,7 @@ | |||
<pry:BeveledButton | |||
x:Name="bb" | |||
FillColor="#4B8EC4" | |||
FillColor="#F14129" | |||
IsParallelogram="False" | |||
StrokeThickness="1" /> | |||
@@ -78,7 +78,7 @@ | |||
</Grid> | |||
<ControlTemplate.Triggers> | |||
<Trigger Property="IsChecked" Value="False"> | |||
<Setter TargetName="bb" Property="FillColor" Value="#4B8EC4" /> | |||
<Setter TargetName="bb" Property="FillColor" Value="#F14129" /> | |||
</Trigger> | |||
<Trigger Property="IsChecked" Value="True"> | |||
<Setter TargetName="bb" Property="FillColor" Value="#50EB53" /> | |||
@@ -137,7 +137,7 @@ | |||
<Setter Property="Width" Value="100" /> | |||
<Setter Property="IsChecked" Value="False" /> | |||
<Setter Property="FontSize" Value="16" /> | |||
<Setter Property="Foreground" Value="#ff2AB2E7" /> | |||
<Setter Property="Foreground" Value="White" /> | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
<ControlTemplate TargetType="{x:Type RadioButton}"> | |||
@@ -146,9 +146,9 @@ | |||
<Border | |||
x:Name="bb" | |||
BorderBrush="#4B8EC4" | |||
BorderThickness="0,0,0,2" /> | |||
BorderThickness="2,2,2,0" /> | |||
<ContentPresenter | |||
<ContentControl | |||
x:Name="contentPresenter" | |||
Margin="10" | |||
HorizontalAlignment="Center" | |||
@@ -156,17 +156,17 @@ | |||
Content="{TemplateBinding Content}" | |||
ContentStringFormat="{TemplateBinding ContentStringFormat}" | |||
ContentTemplate="{TemplateBinding ContentTemplate}" | |||
Focusable="False" | |||
RecognizesAccessKey="True" | |||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" /> | |||
Foreground="{TemplateBinding Foreground}"/> | |||
</Grid> | |||
<ControlTemplate.Triggers> | |||
<Trigger Property="IsChecked" Value="True"> | |||
<!--<Setter TargetName="bb" Property="Background" Value="#4B8EC4" />--> | |||
<Setter TargetName="bb" Property="Visibility" Value="Visible" /> | |||
<Setter TargetName="contentPresenter" Property="Foreground" Value="#ff2AB2E7" /> | |||
</Trigger> | |||
<Trigger Property="IsChecked" Value="False"> | |||
<Setter TargetName="bb" Property="Visibility" Value="Hidden" /> | |||
<Setter TargetName="contentPresenter" Property="Foreground" Value="white" /> | |||
<!--<Setter TargetName="bb" Property="Background" Value="Transparent" />--> | |||
</Trigger> | |||
</ControlTemplate.Triggers> | |||
@@ -21,7 +21,7 @@ namespace BPASmartClient.S7Net | |||
public void Connect(CpuType cpuType, string ip, int port = 102, short rack = 0, short solt = 0) | |||
{ | |||
myPlc = new Plc(cpuType, ip, port, rack, solt); | |||
myPlc.Open(); | |||
myPlc.Open(); | |||
} | |||
/// <summary> | |||