Commit 1d242aa2 authored by 潘栩锋's avatar 潘栩锋 🚴

1.修复 IO口 需要显示 X0~X15

2.添加 电容测厚仪模拟器地址设置,机架参数设置
parent 59a400e8
......@@ -211,12 +211,8 @@ namespace FLY.Thick.Blowing.Server
flyAd.Connect();
flyAdService.Init(flyAd, Ad2Thk);
Misc.BindingOperations.SetBinding(flyAd, nameof(flyAd.HardwareVersion), () =>
{
FlyADIODefine.SetInstance(new FlyADIODefine());
FlyADIODefine.Instance.SerVersion(flyAd.HardwareVersion);
});
FlyADIODefine.SetInstance(new FlyADIODefine());
FlyADIODefine.Instance.SetFlyAD(flyAd);
Misc.BindingOperations.SetBinding(flyAd, nameof(flyAd.IStatus), DynArea, nameof(DynArea.IStatus));
Misc.BindingOperations.SetBinding(flyAd, nameof(flyAd.OStatus), DynArea, nameof(DynArea.OStatus));
......
......@@ -315,10 +315,8 @@ namespace FLY.Thick.BlowingScan.Server
flyAd.Connect();
flyAdService.Init(flyAd, Ad2Thk);
Misc.BindingOperations.SetBinding(flyAd, nameof(flyAd.HardwareVersion), () => {
FlyADIODefine.SetInstance(new FlyADIODefine());
FlyADIODefine.Instance.SerVersion(flyAd.HardwareVersion);
});
FlyADIODefine.SetInstance(new FlyADIODefine());
FlyADIODefine.Instance.SetFlyAD(flyAd);
Misc.BindingOperations.SetBinding(initParam, nameof(initParam.PosLength), flyAd, nameof(flyAd.PosLen));
......
......@@ -129,7 +129,7 @@
</StackPanel>
</StackPanel>
</Grid>
<UniformGrid Columns="9" Margin="2,0" VerticalAlignment="Top" HorizontalAlignment="Left">
<UniformGrid Columns="20" Margin="2,0" VerticalAlignment="Top" HorizontalAlignment="Left">
<UniformGrid.Resources>
<Style TargetType="TextBlock" BasedOn="{StaticResource Styles.Text.IO}"/>
</UniformGrid.Resources>
......@@ -138,26 +138,52 @@
<TextBlock Text="1" />
<TextBlock Text="2" />
<TextBlock Text="3" />
<Grid/>
<TextBlock Text="4" />
<TextBlock Text="5" />
<TextBlock Text="6" />
<TextBlock Text="7" />
<Grid/>
<TextBlock Text="8" />
<TextBlock Text="9" />
<TextBlock Text="10" />
<TextBlock Text="11" />
<Grid/>
<TextBlock Text="12" />
<TextBlock Text="13" />
<TextBlock Text="14" />
<TextBlock Text="15" />
<TextBlock FontWeight="Bold" Text="X" />
<Border Tag="{Binding IStatus, ConverterParameter=0, Converter={StaticResource io2bconv}}" Style="{StaticResource Styles.Border.IO}" />
<Border Tag="{Binding IStatus, ConverterParameter=1, Converter={StaticResource io2bconv}}" Style="{StaticResource Styles.Border.IO}" />
<Border Tag="{Binding IStatus, ConverterParameter=2, Converter={StaticResource io2bconv}}" Style="{StaticResource Styles.Border.IO}" />
<Border Tag="{Binding IStatus, ConverterParameter=3, Converter={StaticResource io2bconv}}" Style="{StaticResource Styles.Border.IO}" />
<Grid/>
<Border Tag="{Binding IStatus, ConverterParameter=4, Converter={StaticResource io2bconv}}" Style="{StaticResource Styles.Border.IO}" />
<Border Tag="{Binding IStatus, ConverterParameter=5, Converter={StaticResource io2bconv}}" Style="{StaticResource Styles.Border.IO}" />
<Border Tag="{Binding IStatus, ConverterParameter=6, Converter={StaticResource io2bconv}}" Style="{StaticResource Styles.Border.IO}" />
<Border Tag="{Binding IStatus, ConverterParameter=7, Converter={StaticResource io2bconv}}" Style="{StaticResource Styles.Border.IO}" />
<Grid/>
<Border Tag="{Binding IStatus, ConverterParameter=8, Converter={StaticResource io2bconv}}" Style="{StaticResource Styles.Border.IO}" />
<Border Tag="{Binding IStatus, ConverterParameter=9, Converter={StaticResource io2bconv}}" Style="{StaticResource Styles.Border.IO}" />
<Border Tag="{Binding IStatus, ConverterParameter=10, Converter={StaticResource io2bconv}}" Style="{StaticResource Styles.Border.IO}" />
<Border Tag="{Binding IStatus, ConverterParameter=11, Converter={StaticResource io2bconv}}" Style="{StaticResource Styles.Border.IO}" />
<Grid/>
<Border Tag="{Binding IStatus, ConverterParameter=12, Converter={StaticResource io2bconv}}" Style="{StaticResource Styles.Border.IO}" />
<Border Tag="{Binding IStatus, ConverterParameter=13, Converter={StaticResource io2bconv}}" Style="{StaticResource Styles.Border.IO}" />
<Border Tag="{Binding IStatus, ConverterParameter=14, Converter={StaticResource io2bconv}}" Style="{StaticResource Styles.Border.IO}" />
<Border Tag="{Binding IStatus, ConverterParameter=15, Converter={StaticResource io2bconv}}" Style="{StaticResource Styles.Border.IO}" />
<TextBlock FontWeight="Bold" Text="Y" />
<Border Tag="{Binding OStatus, ConverterParameter=0, Converter={StaticResource io2bconv}}" Style="{StaticResource Styles.Border.IO}" />
<Border Tag="{Binding OStatus, ConverterParameter=1, Converter={StaticResource io2bconv}}" Style="{StaticResource Styles.Border.IO}" />
<Border Tag="{Binding OStatus, ConverterParameter=2, Converter={StaticResource io2bconv}}" Style="{StaticResource Styles.Border.IO}" />
<Border Tag="{Binding OStatus, ConverterParameter=3, Converter={StaticResource io2bconv}}" Style="{StaticResource Styles.Border.IO}" />
<Grid/>
<Border Tag="{Binding OStatus, ConverterParameter=4, Converter={StaticResource io2bconv}}" Style="{StaticResource Styles.Border.IO}" />
<Border Tag="{Binding OStatus, ConverterParameter=5, Converter={StaticResource io2bconv}}" Style="{StaticResource Styles.Border.IO}" />
<Border Tag="{Binding OStatus, ConverterParameter=6, Converter={StaticResource io2bconv}}" Style="{StaticResource Styles.Border.IO}" />
<Border Tag="{Binding OStatus, ConverterParameter=7, Converter={StaticResource io2bconv}}" Style="{StaticResource Styles.Border.IO}" />
</UniformGrid>
</StackPanel>
......
......@@ -7,7 +7,7 @@
<Setter Property="Background" Value="{StaticResource Brush.LenOff}"/>
<Setter Property="Height" Value="12"/>
<Setter Property="Width" Value="10"/>
<Setter Property="Margin" Value="3,1"/>
<Setter Property="Margin" Value="1,1"/>
<Style.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Tag}" Value="True">
<Setter Property="Background" Value="{StaticResource Brush.LedOn}"/>
......@@ -16,5 +16,6 @@
</Style>
<Style TargetType="TextBlock" x:Key="Styles.Text.IO">
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="FontSize" Value="10"/>
</Style>
</ResourceDictionary>
\ No newline at end of file
......@@ -23,12 +23,6 @@ namespace FLY.Thick.Cap.Common
public int OutNo_PushDown { get; protected set; } = 1;
/// <summary>
/// 新版本只需要下压,没前推
/// </summary>
[Description("前推")]
public int OutNo_PushForward { get; private set; } = 2;
public FlyADIODefine()
{
OutNo_Sync = 0;
......@@ -60,8 +54,7 @@ namespace FLY.Thick.Cap.Common
{
return new List<string> {
nameof(OutNo_Sync),
nameof(OutNo_PushDown),
nameof(OutNo_PushForward)
nameof(OutNo_PushDown)
};
}
......
......@@ -315,11 +315,8 @@ namespace FLY.Thick.Cap.Server
flyAd.Connect();
flyAdService.Init(flyAd, flyAd7WithCapSensor, Ad2Thk);
Misc.BindingOperations.SetBinding(flyAd, nameof(flyAd.HardwareVersion), () =>
{
FlyADIODefine.SetInstance(new FlyADIODefine());
FlyADIODefine.Instance.SerVersion(flyAd.HardwareVersion);
});
FlyADIODefine.SetInstance(new FlyADIODefine());
FlyADIODefine.Instance.SetFlyAD(flyAd);
Misc.BindingOperations.SetBinding(initParam, nameof(initParam.PosLength), flyAd, nameof(flyAd.PosLen));
......
using System;
using Newtonsoft.Json;
using System;
using System.Diagnostics;
using System.IO;
using System.Threading.Tasks;
using System.Windows;
......@@ -32,6 +34,10 @@ namespace CapSimulator
/// </summary>
FLY.Simulation.CapSensor.CapSensor2 capSensor;
/// <summary>
/// app 的参数
/// </summary>
AppConfig appConfig;
public App()
{
appjustone = new FLY.AppHelper.AppJustOne(this);
......@@ -55,7 +61,7 @@ namespace CapSimulator
var ver = new Misc.Ver();
ver.SrcType = this.GetType();
main.Title = ver.ToString();
main.Init(gageAd, flyad7, capSensor, plcLink, blowing);
main.Init(gageAd, flyad7, capSensor, plcLink, blowing, appConfig);
this.MainWindow = main;
......@@ -67,17 +73,24 @@ namespace CapSimulator
void Init()
{
appConfig = new AppConfig();
if (!appConfig.Load())
appConfig.Save();
blowing = new FLY.Simulation.Blowing.Blowing();
plcLink = new FLY.Simulation.Blowing.KeXinPlc();
plcLink.PlcAddr = appConfig.PlcAddr;
plcLink.Init(blowing, blowing.mAirRing2);
gageAd = new FLY.Simulation.Blowing.GageAD();
gageAd.Init(blowing);
flyad7 = new FLY.Simulation.Flyad7.FLYAD7();
flyad7.Addr = appConfig.FlyAd7Addr;
capSensor = new FLY.Simulation.CapSensor.CapSensor2();
capSensor.Addr = appConfig.CapSensorAddr;
flyad7.Init(gageAd);
......@@ -115,4 +128,47 @@ namespace CapSimulator
});
}
}
public class AppConfig
{
[JsonIgnore]
public string filePath = "appConfig.json";
public bool Save()
{
try
{
File.WriteAllText(filePath, JsonConvert.SerializeObject(this, Formatting.Indented));
}
catch
{
//异常,没有json 编码失败
return false;
}
return true;
}
public bool Load()
{
try
{
if (File.Exists(filePath))
{
string json = File.ReadAllText(filePath);
JsonConvert.PopulateObject(json, this);
return true;
}
}
catch
{
//异常,没有json 解码失败
return false;
}
return false;
}
public string CapSensorAddr { get; set; } = "0.0.0.0:20021";
public string FlyAd7Addr { get; set; } = "0.0.0.0:20006";
public string PlcAddr { get; set; } = "0.0.0.0:502";
}
}
......@@ -67,9 +67,8 @@
<Compile Include="Converters\IO2BinConverter.cs" />
<Compile Include="Converters\IO2BitBoolConverter.cs" />
<Compile Include="Converters\VisibilityConverter.cs" />
<Compile Include="WdBlowingVm.cs">
<DependentUpon>WindowBlowing.xaml</DependentUpon>
<SubType>Code</SubType>
<Compile Include="WdAddr.xaml.cs">
<DependentUpon>WdAddr.xaml</DependentUpon>
</Compile>
<Compile Include="WindowBlowing.xaml.cs">
<DependentUpon>WindowBlowing.xaml</DependentUpon>
......@@ -99,6 +98,10 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="WdAddr.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="WindowBlowing.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
......@@ -161,6 +164,9 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="CommunityToolkit.Mvvm">
<Version>8.0.0</Version>
</PackageReference>
<PackageReference Include="Costura.Fody">
<Version>5.7.0</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
......
......@@ -18,6 +18,7 @@ using System.Threading.Tasks;
using System.Windows.Threading;
using FLY.Simulation.Blowing;
using FLY.Simulation.CapSensor;
using CommunityToolkit.Mvvm.Input;
namespace CapSimulator
{
......@@ -30,50 +31,23 @@ namespace CapSimulator
FLY.Simulation.Flyad7.FLYAD7 flyad7;
FLY.Simulation.Blowing.Blowing blowing;
KeXinPlc plc;
AppConfig appConfig;
public MainWindow()
{
InitializeComponent();
}
public void Init(GageAD gageAd, FLYAD7 flyad7, CapSensor2 capSensor, KeXinPlc plc, Blowing blowing)
public void Init(GageAD gageAd, FLYAD7 flyad7, CapSensor2 capSensor, KeXinPlc plc, Blowing blowing, AppConfig appConfig)
{
this.flyad7 = flyad7;
this.blowing = blowing;
this.plc = plc;
this.appConfig = appConfig;
viewModel = new MainVm();
viewModel.Init(gageAd, flyad7, capSensor, plc);
viewModel.Init(gageAd, flyad7, capSensor, plc, blowing, appConfig);
this.DataContext = viewModel;
}
private void button1_Click(object sender, RoutedEventArgs e)
{
WindowBlowing wb = new WindowBlowing();
wb.Init(blowing, plc);
wb.ShowDialog();
}
private void btnPressScramClick(object sender, RoutedEventArgs e)
{
flyad7.ManualStop();
}
private void btnReleaseScramClick(object sender, RoutedEventArgs e)
{
flyad7.ManualRelease();
}
private void btnManualForwordClick(object sender, RoutedEventArgs e)
{
flyad7.ManualForw();
}
private void btnManualBackwordClick(object sender, RoutedEventArgs e)
{
flyad7.ManualBackw();
}
}
......@@ -107,31 +81,82 @@ namespace CapSimulator
public int Surplus { get; set; } = 8000;
private DispatcherTimer timer;
private FLYAD7 flyad;
private KeXinPlc plc;
private CapSensor2 capSensor;
GageAD gageAd;
public RelayCommand OpenBlowingSetupCmd { get; private set; }
public RelayCommand OpenAppConfigCmd { get; private set; }
public RelayCommand PressScramCmd { get; private set; }
public RelayCommand ReleaseScramCmd { get; private set; }
public RelayCommand ManualForwordCmd { get; private set; }
public RelayCommand ManualBackwordCmd { get; private set; }
public FLY.Simulation.Flyad7.FLYAD7 FlyAd => flyad;
public KeXinPlc Plc => plc;
public GageAD GageAD => gageAd;
public CapSensor2 CapSensor => capSensor;
private DispatcherTimer timer;
FLYAD7 flyad;
KeXinPlc plc;
CapSensor2 capSensor;
GageAD gageAd;
Blowing blowing;
AppConfig appConfig;
public MainVm()
{
OpenBlowingSetupCmd = new RelayCommand(OpenBlowingSetup);
OpenAppConfigCmd = new RelayCommand(OpenAppConfig);
PressScramCmd = new RelayCommand(PressScram);
ReleaseScramCmd = new RelayCommand(ReleaseScram);
ManualForwordCmd = new RelayCommand(ManualForword);
ManualBackwordCmd = new RelayCommand(ManualBackword);
}
public void Init(GageAD gageAd, FLYAD7 flyad, CapSensor2 capSensor, KeXinPlc plc)
public void Init(GageAD gageAd, FLYAD7 flyad, CapSensor2 capSensor, KeXinPlc plc, Blowing blowing, AppConfig appConfig)
{
this.gageAd = gageAd;
this.flyad = flyad;
this.plc = plc;
this.capSensor = capSensor;
this.blowing = blowing;
this.appConfig = appConfig;
timer = new DispatcherTimer();
timer.Interval = TimeSpan.FromSeconds(0.1);
timer.Tick += new EventHandler(timer_Tick);
timer.Start();
}
private void OpenBlowingSetup()
{
WindowBlowing wb = new WindowBlowing();
wb.Init(blowing, plc, gageAd);
wb.ShowDialog();
}
private void OpenAppConfig()
{
WdAddr w = new WdAddr();
w.Init(appConfig);
w.ShowDialog();
}
private void PressScram()
{
flyad.ManualStop();
}
private void ReleaseScram()
{
flyad.ManualRelease();
}
private void ManualForword()
{
flyad.ManualForw();
}
private void ManualBackword()
{
flyad.ManualBackw();
}
void timer_Tick(object sender, EventArgs e)
{
......
<Window x:Class="CapSimulator.WdAddr"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:CapSimulator"
mc:Ignorable="d"
Title="WdAddr" Height="250" Width="350" >
<Grid>
<StackPanel Margin="{StaticResource ControlMargin}" Grid.Column="1" >
<StackPanel.Resources>
<Style TargetType="TextBlock" x:Key="Styles.Text.FieldHeader.Editable" BasedOn="{StaticResource Styles.Text.FieldHeader.Editable}">
<Setter Property="Width" Value="130"/>
</Style>
</StackPanel.Resources>
<StackPanel Orientation="Horizontal" Margin="2">
<TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="电容传感器地址"/>
<TextBox Style="{StaticResource Styles.Text.FieldContent.Input}" Text="{Binding CapSensorAddr}"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="2">
<TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="AD盒地址"/>
<TextBox Style="{StaticResource Styles.Text.FieldContent.Input}" Text="{Binding FlyAd7Addr}"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="2">
<TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="PLC地址"/>
<TextBox Style="{StaticResource Styles.Text.FieldContent.Input}" Text="{Binding PlcAddr}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<Button Style="{StaticResource Styles.Button.Square.Accent2}" Content="应用" Command="{Binding SaveCmd}"/>
</StackPanel>
</StackPanel>
</Grid>
</Window>
using CommunityToolkit.Mvvm.Input;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace CapSimulator
{
/// <summary>
/// WdAddr.xaml 的交互逻辑
/// </summary>
public partial class WdAddr : Window
{
WdAddrVm viewModel;
public WdAddr()
{
InitializeComponent();
}
public void Init(AppConfig appConfig)
{
viewModel = new WdAddrVm();
viewModel.Init(appConfig);
this.DataContext = viewModel;
}
}
public class WdAddrVm : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public string CapSensorAddr { get; set; }
public string FlyAd7Addr { get; set; }
public string PlcAddr { get; set; }
public RelayCommand SaveCmd { get; set; }
AppConfig appConfig;
public WdAddrVm()
{
SaveCmd = new RelayCommand(Save);
}
public void Init(AppConfig appConfig)
{
this.appConfig = appConfig;
CapSensorAddr = appConfig.CapSensorAddr;
FlyAd7Addr = appConfig.FlyAd7Addr;
PlcAddr = appConfig.PlcAddr;
}
private void Save()
{
if (MessageBox.Show("需要重启,才能生效", "提示", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
{
appConfig.CapSensorAddr = CapSensorAddr;
appConfig.FlyAd7Addr = FlyAd7Addr;
appConfig.PlcAddr = PlcAddr;
appConfig.Save();
FLY.AppHelper.AppJustOne.Restart();
}
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CapSimulator
{
public class WdBlowingVm : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
}
}
......@@ -7,22 +7,24 @@ using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Forms.DataVisualization.Charting;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Threading;
using CommunityToolkit.Mvvm.Input;
using FLY.Simulation.Blowing;
namespace CapSimulator
{
/// <summary>
/// WindowBlowing.xaml 的交互逻辑
/// </summary>
public partial class WindowBlowing : Window
{
Blowing mBlowing;
KeXinPlc plcLink;
WdBlowingVm viewModel;
public WindowBlowing()
{
InitializeComponent();
......@@ -146,50 +148,84 @@ namespace CapSimulator
this.chart2.BackColor = System.Drawing.Color.Transparent;
}
public void Init(Blowing blowing, KeXinPlc plcLink)
public void Init(Blowing blowing, KeXinPlc plc, GageAD gageAD)
{
this.mBlowing = blowing;
this.plcLink = plcLink;
this.DataContext = mBlowing;
spPlc.DataContext = plcLink;
mBlowing.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(mBlowing_PropertyChanged);
DataBindAll();
chart1.ChartAreas["Default"].CursorX.Position = mBlowing.TestPos;
viewModel = new WdBlowingVm();
viewModel.Init(blowing, plc, gageAD, chart1, chart2, Dispatcher);
this.DataContext = viewModel;
DataBindAll_chart2();
}
}
public class WdBlowingVm : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public RelayCommand TestCmd { get; private set; }
public RelayCommand SaveCmd { get; private set; }
public Blowing Blowing => blowing;
public KeXinPlc Plc => plc;
public GageAD GageAD => gageAD;
Blowing blowing;
KeXinPlc plc;
GageAD gageAD;
Chart chart1;
Chart chart2;
Dispatcher dispatcher;
public WdBlowingVm()
{
TestCmd = new RelayCommand(Test);
SaveCmd = new RelayCommand(Save);
}
private void Window_Loaded(object sender, RoutedEventArgs e)
public void Init(Blowing blowing, KeXinPlc plc, GageAD gageAD, Chart chart1, Chart chart2, Dispatcher dispatcher)
{
this.blowing = blowing;
this.plc = plc;
this.gageAD = gageAD;
this.chart1 = chart1;
this.chart2 = chart2;
this.dispatcher = dispatcher;
this.blowing.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(mBlowing_PropertyChanged);
DataBindAll();
chart1.ChartAreas["Default"].CursorX.Position = blowing.TestPos;
DataBindAll_chart2();
}
void mBlowing_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(mBlowing.TestPos))
if (e.PropertyName == nameof(blowing.TestPos))
{
chart1.ChartAreas["Default"].CursorX.Position = mBlowing.TestPos;
chart1.ChartAreas["Default"].CursorX.Position = blowing.TestPos;
}
else if (e.PropertyName == nameof(mBlowing.AfterDatas))
else if (e.PropertyName == nameof(blowing.AfterDatas))
{
this.Dispatcher.Invoke(new Action(DataBindAll2_chart2));
this.Dispatcher.Invoke(new Action(DataBindAll2));
dispatcher.Invoke(new Action(DataBindAll2_chart2));
dispatcher.Invoke(new Action(DataBindAll2));
}
}
public void DataBindAll()
{
chart1.Series["Series 1"].Points.Clear();
for (int i = 0; i < mBlowing.AfterDatas.Count(); i++)
for (int i = 0; i < blowing.AfterDatas.Count(); i++)
{
chart1.Series["Series 1"].Points.AddXY(i, mBlowing.AfterDatas[i]);
chart1.Series["Series 1"].Points.AddXY(i, blowing.AfterDatas[i]);
}
int max = mBlowing.AfterDatas.Max();
int min = mBlowing.AfterDatas.Min();
int avg = (int)mBlowing.AfterDatas.Average();
int max = blowing.AfterDatas.Max();
int min = blowing.AfterDatas.Min();
int avg = (int)blowing.AfterDatas.Average();
if (max == min)
{
max = (int)(avg * 1.1);
......@@ -199,16 +235,16 @@ namespace CapSimulator
chart1.ChartAreas["Default"].AxisY.Minimum = min - (max - min);
chart1.ChartAreas["Default"].AxisX.Maximum = mBlowing.AfterDatas.Count();
chart1.ChartAreas["Default"].AxisX.Maximum = blowing.AfterDatas.Count();
chart1.ChartAreas["Default"].AxisX.Minimum = 0;
chart1.Invalidate();
}
public void DataBindAll2()
{
for (int i = 0; i < mBlowing.AfterDatas.Count(); i++)
for (int i = 0; i < blowing.AfterDatas.Count(); i++)
{
chart1.Series["Series 1"].Points[i].SetValueY(mBlowing.AfterDatas[i]);
chart1.Series["Series 1"].Points[i].SetValueY(blowing.AfterDatas[i]);
}
chart1.Invalidate();
}
......@@ -216,49 +252,43 @@ namespace CapSimulator
public void DataBindAll_chart2()
{
chart2.Series["Series 1"].Points.Clear();
for (int i = 0; i < mBlowing.mAirRing2.Heats.Count(); i++)
for (int i = 0; i < blowing.mAirRing2.Heats.Count(); i++)
{
chart2.Series["Series 1"].Points.AddXY(i, mBlowing.mAirRing2.Heats[i]);
chart2.Series["Series 1"].Points.AddXY(i, blowing.mAirRing2.Heats[i]);
}
chart2.ChartAreas["Default"].AxisY.Maximum = 100;
chart2.ChartAreas["Default"].AxisY.Minimum = 0;
chart2.ChartAreas["Default"].AxisX.Maximum = mBlowing.mAirRing2.Heats.Count();
chart2.ChartAreas["Default"].AxisX.Maximum = blowing.mAirRing2.Heats.Count();
chart2.ChartAreas["Default"].AxisX.Minimum = 0;
chart2.Invalidate();
}
public void DataBindAll2_chart2()
{
for (int i = 0; i < mBlowing.mAirRing2.Heats.Count(); i++)
for (int i = 0; i < blowing.mAirRing2.Heats.Count(); i++)
{
chart2.Series["Series 1"].Points[i].SetValueY(mBlowing.mAirRing2.Heats[i]);
chart2.Series["Series 1"].Points[i].SetValueY(blowing.mAirRing2.Heats[i]);
}
chart2.Invalidate();
}
private void button1_Click(object sender, RoutedEventArgs e)
{
mBlowing.Test();
}
private void btnSaveClick(object sender, RoutedEventArgs e)
private void Save()
{
if (MessageBox.Show("需要重启,才能生效", "提示", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
{
mBlowing.Save();
if (MessageBox.Show("需要重启,才能生效", "提示", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
{
blowing.Save();
gageAD.Save();
FLY.AppHelper.AppJustOne.Restart();
}
}
private void CheckBox_Checked(object sender, RoutedEventArgs e)
{
}
private void CheckBox_Unchecked(object sender, RoutedEventArgs e)
private void Test()
{
blowing.Test();
}
}
......
using System;
using AutoMapper;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
namespace FLY.Simulation.Blowing
......@@ -82,6 +85,9 @@ namespace FLY.Simulation.Blowing
public GageAD()
{
curve = new CurveCollection();
if (!Load())
Save();
}
public void Init(Blowing blowing)
{
......@@ -250,7 +256,7 @@ namespace FLY.Simulation.Blowing
/// <returns></returns>
public UInt16 GetInput()
{
UInt16 istatus = 0x0fff;
UInt16 istatus = 0xffff;
if (!mBlowing.IsShieldI9)
{
......@@ -309,6 +315,73 @@ namespace FLY.Simulation.Blowing
{
this.position = position;
}
private string param_path = "simulation_gage.json";
public bool Save()
{
return GageADJsonDb.Save(this, param_path);
}
bool Load()
{
return GageADJsonDb.Load(this, param_path);
}
}
public class GageADJsonDb
{
static Mapper Mapper { get; } = new AutoMapper.Mapper(new MapperConfiguration(c => {
c.CreateMap<GageAD, GageADJsonDb>().ReverseMap();
}));
public static bool Save(GageAD src, string filePath)
{
try
{
var jsondb = Mapper.Map<GageADJsonDb>(src);
string json = Newtonsoft.Json.JsonConvert.SerializeObject(jsondb, Formatting.Indented);
File.WriteAllText(filePath, json);
return true;
}
catch
{
return false;
}
}
public static bool Load(GageAD src, string filePath)
{
if (!File.Exists(filePath))
return false;
try
{
string json = File.ReadAllText(filePath);
var jsondb = Newtonsoft.Json.JsonConvert.DeserializeObject<GageADJsonDb>(json);
Mapper.Map(jsondb, src);
return true;
}
catch
{
return false;
}
}
/// <summary>
/// 1脉冲 = ? mm
/// </summary>
public double Mmpp { get; set; } = 0.075;
/// <summary>
/// 机架总长 mm
/// </summary>
public int TotalLengthMm { get; set; } = 845;
/// <summary>
/// 原点信号位置
/// </summary>
public int OrgSignMm { get; set; } = 30;
}
}
......
......@@ -708,7 +708,7 @@ namespace FLY.Simulation.Flyad7
public UInt16 IStatus { get; set; }
public UInt16 OStatus { get; set; } = 0xf;
public UInt16 OStatus { get; set; } = 0xff;
public void SetOutput(ushort mask, ushort enable)
......
......@@ -5,6 +5,7 @@ using System.Text;
namespace FLY.Simulation
{
//大AD盒
public class IODefinition
{
/// <summary>
......@@ -12,18 +13,7 @@ namespace FLY.Simulation
/// </summary>
public const int IN_Sync = 0;
/// <summary>
/// X1 归0
/// </summary>
public const int IN_Origin = 1;
/// <summary>
/// X2 反向限位
/// </summary>
public const int IN_Minimum = 2;
/// <summary>
/// X3 正向限位
/// </summary>
public const int IN_Maximum = 3;
/// <summary>
/// X4 下压按钮
......@@ -54,10 +44,26 @@ namespace FLY.Simulation
/// </summary>
public const int IN_TurnSign1 = 9;
/// <summary>
/// X12 归0
/// </summary>
public const int IN_Origin = 12;
/// <summary>
/// X13 反向限位
/// </summary>
public const int IN_Minimum = 13;
/// <summary>
/// X14 线速度
/// </summary>
public const int IN_Roll = 14;
/// <summary>
/// X10 线速度
/// X15 正向限位
/// </summary>
public const int IN_Roll = 10;
public const int IN_Maximum = 15;
/// <summary>
/// Y0 同步信号
......
Subproject commit 70d4619c783bcc73f24a486c8521dea8dc4ff257
Subproject commit 0b3ae5b97be51891534edde1b8a1152d7da7d7ae
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment