Commit aaddf320 authored by 潘栩锋's avatar 潘栩锋 :bicyclist:

Merge remote-tracking branch 'remotes/origin/dev7.0-battery' into dev7.0-blowing

parents 23b74050 ab6975e7
......@@ -51,10 +51,16 @@ namespace Install.Core
/// </summary>
public bool HasNewestInstallZip { get; private set; }
/// <summary>
/// 从网络检测信息中
/// </summary>
public bool IsCheckingNetwork { get; private set; }
/// <summary>
/// 最新的安装包版本
/// </summary>
public string NewestInstallZipVersion { get; private set; }
/// <summary>
/// 当前的安装包版本
/// </summary>
......@@ -115,6 +121,7 @@ namespace Install.Core
/// </summary>
void DownloadNewestInstallZipInfo()
{
IsCheckingNetwork = true;
//新建线程
Task.Factory.StartNew(() =>
{
......@@ -130,7 +137,9 @@ namespace Install.Core
NewestInstallZipVersion = NewestInstallZipVersionInfo.InstallZipVersion;
int ret = VerExt.VersionCompare(InstallPacks.InstallZipVersion, NewestInstallZipVersionInfo.InstallZipVersion);
IsCheckingNetwork = false;
HasNewestInstallZip = (ret < 0);
});
}
......
......@@ -12,7 +12,7 @@ using System.Windows;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("佛山市枫莱尔自动化有限公司")]
[assembly: AssemblyProduct("FLY系列软件安装向导")]
[assembly: AssemblyCopyright("Copyright © 2021 flyautomation")]
[assembly: AssemblyCopyright("Copyright © 2022 flyautomation")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
......@@ -51,6 +51,6 @@ using System.Windows;
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("4.0.1")]
[assembly: AssemblyFileVersion("4.0.1")]
[assembly: AssemblyVersion("4.0.2")]
[assembly: AssemblyFileVersion("4.0.2")]
[assembly: Guid("AB127AC6-16C6-411F-8892-D90413A863C8")]
......@@ -22,6 +22,10 @@
</Grid.ColumnDefinitions>
<TextBlock Text="已安装项目" Style="{StaticResource h1}"/>
<StackPanel Orientation="Horizontal" Grid.Column="1">
<TextBlock
Visibility="{Binding InstallWizard.IsCheckingNetwork,Converter={StaticResource visbilityconv}}"
Foreground="Green" FontSize="20"
Text="正在联网检测版本更新" />
<Button Margin="5" Command="{Binding DownloadCmd}" Visibility="{Binding InstallWizard.HasNewestInstallZip,Converter={StaticResource visbilityconv}}">
<TextBlock Margin="10,2">
点击下载 最新版本 v<Run Foreground="Red" FontSize="20" Text="{Binding InstallWizard.NewestInstallZipVersion,Mode=OneWay}"/>
......
......@@ -45,6 +45,10 @@ namespace Update.Core
/// </summary>
public bool HasNewestInstallZip { get; private set; }
/// <summary>
/// 从网络检测信息中
/// </summary>
public bool IsCheckingNetwork { get; private set; }
/// <summary>
/// 最新的安装包版本
/// </summary>
......@@ -94,7 +98,7 @@ namespace Update.Core
UpdateHasInstalled();
UpdateIcons();
DownloadNewestInstallZipInfo();
return true;
}
......@@ -104,6 +108,7 @@ namespace Update.Core
/// </summary>
void DownloadNewestInstallZipInfo()
{
IsCheckingNetwork = true;
//新建线程
Task.Factory.StartNew(() =>
{
......@@ -119,7 +124,9 @@ namespace Update.Core
NewestInstallZipVersion = NewestInstallZipVersionInfo.InstallZipVersion;
int ret = VerExt.VersionCompare(InstallPacks.InstallZipVersion, NewestInstallZipVersionInfo.InstallZipVersion);
IsCheckingNetwork = false;
HasNewestInstallZip = (ret < 0);
});
}
......
......@@ -12,7 +12,7 @@ using System.Windows;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("佛山市枫莱尔自动化技术有限公司")]
[assembly: AssemblyProduct("FLY系列软件升级检测")]
[assembly: AssemblyCopyright("Copyright © 2021 flyautomation")]
[assembly: AssemblyCopyright("Copyright © 2022 flyautomation")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
......@@ -51,5 +51,5 @@ using System.Windows;
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.1.0")]
[assembly: AssemblyFileVersion("1.0.1.0")]
......@@ -24,11 +24,17 @@
<TextBlock Style="{StaticResource h1}">
当前版本号: v<Run Text="{Binding InstallWizard.CurrentInstallZipVersion,Mode=OneWay}"/>
</TextBlock>
<TextBlock Margin="10,2"
VerticalAlignment="Center"
Visibility="{Binding InstallWizard.HasNewestInstallZip,Converter={StaticResource visbilityconv},ConverterParameter=HiddenWhenTrue}"
Foreground="Red" FontSize="20"
Text="(已经为最新版本)" />
<Grid Margin="10,2" VerticalAlignment="Center">
<Grid Visibility="{Binding InstallWizard.IsCheckingNetwork,Converter={StaticResource visbilityconv},ConverterParameter=HiddenWhenTrue}">
<TextBlock Visibility="{Binding InstallWizard.HasNewestInstallZip,Converter={StaticResource visbilityconv},ConverterParameter=HiddenWhenTrue}"
Foreground="Red" FontSize="20"
Text="(已经为最新版本)" />
</Grid>
<TextBlock
Visibility="{Binding InstallWizard.IsCheckingNetwork,Converter={StaticResource visbilityconv}}"
Foreground="Green" FontSize="20"
Text="正在联网检测版本更新" />
</Grid>
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Column="1">
<Button Margin="5" Command="{Binding DownloadCmd}" Visibility="{Binding InstallWizard.HasNewestInstallZip,Converter={StaticResource visbilityconv}}">
......
......@@ -24,4 +24,5 @@
<conv:RatioConverter_TimeSpan x:Key="ratioconv_ts" />
<conv:Item2IndexConverter x:Key="i2iConv"/>
<conv:Item2NoConverter x:Key="i2noConv"/>
</ResourceDictionary>
\ No newline at end of file
......@@ -39,4 +39,37 @@ namespace FLY.ControlLibrary.Converter
throw new NotImplementedException();
}
}
/// <summary>
/// 列表转Number 从1开始
/// </summary>
[ValueConversion(typeof(object), typeof(int))]
public class Item2NoConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
int result = -1;
if (value != null)
{
var collectionViewSource = parameter as CollectionViewSource;
if (collectionViewSource != null)
{
var cv = (CollectionView)collectionViewSource.View;
//在 设计模式中, View为null, 所以下面必须判断
if (cv != null)
{
result = cv.IndexOf(value);
}
}
}
return result >= 0 ? result + 1 : System.Windows.DependencyProperty.UnsetValue;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
......@@ -57,7 +57,10 @@ namespace FLY.Simulation.Coating
public List<DataInfo> Datas_Horizontal = new List<DataInfo>();//横向数据
double datas_horizontal_avg = 0;
int datas_vertical_position=0;
/// <summary>
/// 由于泵损坏带来的纵向波动
/// </summary>
double datas_vertical_pumpDamaged = 0;
//30m 后的数据
public List<DataInfo> Datas_Vertical_30m = new List<DataInfo>();//纵向数据
......@@ -65,6 +68,7 @@ namespace FLY.Simulation.Coating
int datas_vertical_30m_position=0;
/// <summary>
/// 膜宽
/// </summary>
......@@ -123,9 +127,24 @@ namespace FLY.Simulation.Coating
/// </summary>
public bool HSignal2;
/// <summary>
/// 设备状态
/// </summary>
public bool DeviceState { get; set; }
/// <summary>
/// 泵的转子坏了, 会看到有周期的波动,周期为 泵速
/// </summary>
public bool IsPumpDamaged { get; set; }
/// <summary>
/// 由于 泵的转子坏了 导致 面密度 周期的波动 的变化公差,单位g/m²
/// </summary>
public double ToleranceOfPumpBeDamaged { get; set; } = 1;
/// <summary>
/// 均值
/// </summary>
public double Avg { get; set; }
void Load_Vertical()
......@@ -143,7 +162,7 @@ namespace FLY.Simulation.Coating
int pos_mm = int.Parse(ss[0]);
bool isLight = bool.Parse(ss[1]);
bool isLight2 = bool.Parse(ss[2]);
double thick = double.Parse(ss[3]);
double thick = double.Parse(ss[3]);//单位 g/m²
Datas_Vertical.Add(new DataInfo() { IsLight = isLight, IsLight2 = isLight2, Thick = thick });
Datas_Vertical_30m.Add(new DataInfo() { IsLight = isLight, IsLight2 = isLight2, Thick = thick });
......@@ -216,8 +235,12 @@ namespace FLY.Simulation.Coating
return 0;
if (mm >= FilmWidth)
return 0;
return Datas_Vertical_30m[datas_vertical_position].Thick * Datas_Horizontal_30m[mm].Thick / datas_horizontal_avg;
double d = Datas_Vertical_30m[datas_vertical_position].Thick * Datas_Horizontal_30m[mm].Thick / datas_horizontal_avg;
if (IsPumpDamaged)
{
d += datas_vertical_pumpDamaged;
}
return d;
}
public double GetData(int mm)
{
......@@ -226,7 +249,13 @@ namespace FLY.Simulation.Coating
if (mm >= FilmWidth)
return 0;
return Datas_Vertical[datas_vertical_position].Thick * Datas_Horizontal[mm].Thick / datas_horizontal_avg;
double d = Datas_Vertical[datas_vertical_position].Thick * Datas_Horizontal[mm].Thick / datas_horizontal_avg;
if (IsPumpDamaged)
{
d += datas_vertical_pumpDamaged;
}
return d;
}
/// <summary>
/// 上一个时间点
......@@ -249,18 +278,33 @@ namespace FLY.Simulation.Coating
double filmMove = ts.TotalMinutes * FilmVelocity;
FilmLength += filmMove;//膜位置
int p1 = (int)(FilmLength * 1000 % Datas_Vertical.Count());
if (p1 != datas_vertical_position)
{
datas_vertical_position = p1;
Avg = Datas_Vertical[datas_vertical_position].Thick / 100.0;
if (AvgChanged != null)
double avg = Datas_Vertical[datas_vertical_position].Thick;
if (hmi_cc.NowCtrl.Pump > 0 && IsPumpDamaged)
{
AvgChanged(FilmLength, (int)(Avg*100));
// 泵损坏 周期 m
double intervalOfPumpDamage = FilmVelocity / hmi_cc.NowCtrl.Pump;
double index = FilmLength % intervalOfPumpDamage;
double percent = index / intervalOfPumpDamage;
double v = ToleranceOfPumpBeDamaged * Math.Sin(Math.PI * 2 * percent);
datas_vertical_pumpDamaged = v;
avg += datas_vertical_pumpDamaged;
}
Avg = avg;
AvgChanged?.Invoke(this, new AvgChangedEventArgs() { filmLength = FilmLength, avg = Avg });
}
datas_vertical_30m_position = (int)((FilmLength - OvenLength) * 1000 % Datas_Vertical.Count());
if (datas_vertical_30m_position < 0)
datas_vertical_30m_position += Datas_Vertical.Count();
......@@ -288,7 +332,12 @@ namespace FLY.Simulation.Coating
/// <summary>
/// 每1mm更新一次
/// </summary>
public event Action<double, int> AvgChanged;
public event AvgChangedEventHandler AvgChanged;
public delegate void AvgChangedEventHandler(object sender, AvgChangedEventArgs args);
public class AvgChangedEventArgs : EventArgs {
public double filmLength;
public double avg;
}
public event Action DatasChanged;
public event Action Datas30mChanged;
public void NotifyDatasChanged()
......@@ -317,12 +366,13 @@ namespace FLY.Simulation.Coating
public string[] GetSavePropertyNames()
{
return new string[] {
"Port",
"CoatingMode"
nameof(Port),
nameof(CoatingMode)
};
}
}
/// <summary>
/// 涂布控制量
/// </summary>
......
......@@ -330,8 +330,8 @@ namespace FLY.Simulation.Flyad7
}
else
{
Now += FlyADBase.TimeGridAdvHelperExt.ad_ts;
systick += FlyADBase.TimeGridAdvHelperExt.ad_ts_ms;
Now += TimeSpan.FromTicks((long)(1.28 * TimeSpan.TicksPerMillisecond));
systick += 1.28;
}
UpdateAD();
......@@ -385,7 +385,7 @@ namespace FLY.Simulation.Flyad7
TimeGridEvent.Invoke(this,
new TimeGridEventArgs(
Now,
FlyADBase.TimeGridAdvHelperExt.ad_ts,
TimeSpan.FromTicks((long)(1.28 * TimeSpan.TicksPerMillisecond)),
TimeGrid.ToArray()));
}
TimeGrid.Clear();
......
......@@ -97,8 +97,13 @@
</Grid>
<StackPanel>
<CheckBox Content="设置位" FontSize="18" FontWeight="Bold" Height="23" Margin="3" VerticalAlignment="Center" FlowDirection="RightToLeft" IsChecked="{Binding OK}" DataContext="{Binding DataContext,ElementName=hmi}"/>
<CheckBox Content="涂布状态" FontSize="18" FontWeight="Bold" Height="23" Margin="3" VerticalAlignment="Center" FlowDirection="RightToLeft" IsChecked="{Binding DeviceState}" IsEnabled="False"/>
<CheckBox Content="设置位" FontSize="18" FontWeight="Bold" Height="23" Margin="3" IsChecked="{Binding OK}" DataContext="{Binding DataContext,ElementName=hmi}"/>
<CheckBox Content="涂布状态" FontSize="18" FontWeight="Bold" Height="23" Margin="3" IsChecked="{Binding DeviceState}" IsEnabled="False"/>
<CheckBox Content="泵损坏" FontSize="18" FontWeight="Bold" Height="23" Margin="3" IsChecked="{Binding IsPumpDamaged}" />
<StackPanel Orientation="Horizontal">
<TextBlock Text="泵公差" FontSize="18" FontWeight="Bold" Height="23" Margin="3" />
<TextBox Text="{Binding ToleranceOfPumpBeDamaged }" FontSize="18" MinWidth="50"/>
</StackPanel>
</StackPanel>
</StackPanel>
......@@ -122,7 +127,7 @@
</ComboBox>
<TextBlock FontSize="18" FontWeight="Bold" Height="23" Margin="3" VerticalAlignment="Center" >
<Run Text="当前平均值:" />
<Run Text="{Binding Avg}" />
<Run Text="{Binding Avg,StringFormat={}{0:F2}}" />
</TextBlock>
</StackPanel>
<Grid Margin="12,3" Grid.Row="2">
......
......@@ -44,12 +44,13 @@ namespace FLYAD7_Simulation_Wpf
DataBindAll();
mCoating.DatasChanged += new Action(mCoating_DatasChanged);
mCoating.AvgChanged += new Action<double, int>(mCoating_AvgChanged);
mCoating.AvgChanged += MCoating_AvgChanged;
}
void mCoating_AvgChanged(double arg1, int arg2)
private void MCoating_AvgChanged(object sender, Coating.AvgChangedEventArgs args)
{
int filmlength_cm = (int)(arg1*100);
int filmlength_cm = (int)(args.filmLength * 100);
if(FilmLength_cm == filmlength_cm)
{
......@@ -73,7 +74,7 @@ namespace FLYAD7_Simulation_Wpf
}
datas.Clear();
}
datas.Add(arg2);
datas.Add(args.avg);
}
void mCoating_DatasChanged()
......
......@@ -2,6 +2,7 @@
using FObjBase;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
......@@ -476,6 +477,8 @@ namespace FlyADBase
}
}, TimeSpan.FromSeconds(1));
Misc.BindingOperations.SetBinding(isReadyContext, nameof(isReadyContext.IsReady), this, nameof(IsReady));
}
......@@ -1032,9 +1035,34 @@ namespace FlyADBase
Now = dt;
}
data = pack.data;
//放入的数据应该是1ms一个,不对就扩展
TimeSpan curr_ad_ts = TimeSpan.FromTicks((long)(1.28 * TimeSpan.TicksPerMillisecond));
List<int> data_1ms = new List<int>();
DateTime idealTime = dt;
DateTime actTime = dt;
for (int j = 0; j < data.Count(); j++)
{
int idx2 = data.Count() - 1 - j;
int ad = data[idx2];
actTime -= curr_ad_ts;
while (idealTime > actTime)
{
data_1ms.Add(ad);//导出数据
idealTime -= TimeSpan.FromMilliseconds(1);//导出数据时间累加
}
}
data_1ms.Reverse();
data = data_1ms.ToArray();
advPushTimeGrid(dt, data);
TimeSpan ts = TimeSpan.FromTicks((long)(1.28 * TimeSpan.TicksPerMillisecond));
TimeSpan ts = TimeSpan.FromMilliseconds(1);
if (lastTimeGridTime != DateTime.MinValue)
ts = TimeSpan.FromTicks((dt - lastTimeGridTime).Ticks / data.Length);
lastTimeGridTime = dt;
......
......@@ -367,6 +367,7 @@ namespace FlyADBase
{
#region 高级 timegrid
//TODO
mTimeGridAdvHelper.AddAD(end_dt - TimeSpan.FromMilliseconds(ADLag), datas);
if (IsTimeToPushTimeGridAdv) {
......
......@@ -37,10 +37,10 @@ namespace FlyADBase
{
NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
#region 一分钟数据缓存池, 目标每个AD数据(1.28ms 都有对应的其它数据
#region 一分钟数据缓存池, 目标每个AD数据(1ms 都有对应的其它数据
/// <summary>
/// AD数据池时间间隔为TimeGridAdvHelperExt.ad_ts_ms, 肯定最少有一个数据
/// 每个数据包(200个数据)理论间隔是200*ad_ts_ms, 但实际上不是。
/// AD数据池时间间隔为1ms, 肯定最少有一个数据
/// 每个数据包(200个数据)理论间隔是200ms, 但实际上不是。
/// 数据输出时,输出的每个数据必须是1ms, 需要通过数据包的systick线性填充数据
/// </summary>
public List<DateTimeUnit3> ADPool = new List<DateTimeUnit3>();
......@@ -79,7 +79,7 @@ namespace FlyADBase
/// <summary>
/// 添加ad数据,且判断数据量是否够触发事件, 时间间隔为 TimeGridAdvHelperExt.ad_ts_ms
/// 添加ad数据,且判断数据量是否够触发事件, 时间间隔为 1ms
/// </summary>
/// <param name="end_dt"></param>
/// <param name="adArray"></param>
......@@ -564,19 +564,10 @@ namespace FlyADBase
public static class TimeGridAdvHelperExt
{
/// <summary>
/// 缓存区每个ad数据的时间间隔 AD盒1.2.3版本都是 1.28ms, AD盒2021 为1ms
/// </summary>
public static double ad_ts_ms = 1.28;
/// <summary>
/// ad_ts_ms 的 TimeSpan
/// </summary>
public static TimeSpan ad_ts => TimeSpan.FromTicks((long)(ad_ts_ms * TimeSpan.TicksPerMillisecond));
/// <summary>
/// 导出的数据间隔是1ms 一个, 导出的数据量肯定比要求给的更多
/// </summary>
/// <param name="adPool">AD缓存区(每个数据间隔ad_ts_ms)</param>
/// <param name="adPool">AD缓存区(每个数据间隔1ms)</param>
/// <param name="begin">开始时间点</param>
/// <param name="end">结束时间点</param>
/// <param name="reponse_endTime">实际导出的数据结束时间点</param>
......@@ -596,9 +587,9 @@ namespace FlyADBase
}
/// <summary>
/// 导出的数据间隔是1ms 一个,原始数据间隔是ad_ts_ms(可能是1ms,或者1.28ms)
/// 导出的数据间隔是1ms 一个
/// </summary>
/// <param name="adPool">AD缓存区(每个数据间隔ad_ts_ms)</param>
/// <param name="adPool">AD缓存区(每个数据间隔1ms)</param>
/// <returns></returns>
public static List<int> GetAD(List<DateTimeUnit3> adPool)
{
......@@ -606,7 +597,7 @@ namespace FlyADBase
}
/// <summary>
/// 导出的数据间隔是1ms 一个,原始数据间隔是ad_ts_ms(可能是1ms,或者1.28ms)
/// 导出的数据间隔是1ms 一个
/// </summary>
/// <param name="adPool">AD缓存区</param>
/// <param name="begin">开始时间点</param>
......@@ -619,48 +610,21 @@ namespace FlyADBase
DateTime idealTime = adPool.Last().dt;
//每个ad包的每个数据不是准确的1.28ms,肯定比1.28ms大,每次需要准
//每个ad包的每个数据不是准确的1ms,肯定比1.28ms大,每次需要准
for (int i = 0; i < adPool.Count(); i++)
{
int idx = adPool.Count() - 1 - i;
//当前缓存区包,每个数据的时间间隔
TimeSpan curr_ad_ts;
//TimeSpan curr_ad_ts;
//计算这个包每个数据的时间间隔
DateTime end_dt = adPool[idx].dt;
if (idx > 0)
{
//上一个数据包的结束时间,就是这个数据包的开始时间
var begin_dt = adPool[idx - 1].dt;
//数据包总时间
double total_ms = (end_dt - begin_dt).Ticks / TimeSpan.TicksPerMillisecond;
//当前缓存区包,实际每个数据的时间间隔
var curr_ad_ts_ms = total_ms / adPool[idx].datas.Count();
curr_ad_ts = TimeSpan.FromTicks((long)(curr_ad_ts_ms * TimeSpan.TicksPerMillisecond));
}
else if (adPool.Count() > 1)
{
//缓存区的第0号序号包, 只能通过下一个数据包 推测时间
var begin_dt = adPool[idx].dt - (adPool[idx + 1].dt - adPool[idx].dt);
double total_ms = (end_dt - begin_dt).Ticks / TimeSpan.TicksPerMillisecond;
var curr_ad_ts_ms = total_ms / adPool[idx].datas.Count();
curr_ad_ts = TimeSpan.FromTicks((long)(curr_ad_ts_ms * TimeSpan.TicksPerMillisecond));
}
else
{
//整个缓存就一个数据包,使用默认的时间间隔
curr_ad_ts = ad_ts;
}
DateTime actTime = adPool[idx].dt;//从缓存区获取数据的时间
for (int j = 0; j < adPool[idx].datas.Count(); j++)
{
int idx2 = adPool[idx].datas.Count() - 1 - j;
int ad = adPool[idx].datas[idx2];
actTime -= curr_ad_ts;
actTime -= TimeSpan.FromMilliseconds(1);//导出数据时间累加
while (idealTime > actTime)
{
......
#!/bin/bash
#第1次编译后, 执行
#还原 bin/Debug 的 配置文件
echo 初始化 FLYAD7_Simulation_Wpf.资料
src_dir="FLYAD7_Simulation_Wpf.资料/*"
dest_dir="../FLYAD7_Simulation_Wpf/bin/Debug"
cp -Rf ${src_dir} ${dest_dir}
if [ "$?" -ne "0" ]; then
echo 初始化 FLYAD7_Simulation_Wpf.资料 出错
exit -1
fi
echo 初始化 FLYAD7.Simulation.Battery.RayLaser.资料
src_dir="FLYAD7.Simulation.Battery.RayLaser.资料/*"
dest_dir="../FLYAD7.Simulation.Battery.RayLaser/bin/Debug"
cp -Rf ${src_dir} ${dest_dir}
if [ "$?" -ne "0" ]; then
echo 初始化 FLYAD7.Simulation.Battery.RayLaser.资料 出错
exit -1
fi
echo 完成
\ No newline at end of file
......@@ -5,6 +5,6 @@
"PosOfGrid": 5,
"Ratio01": 4,
"Ratio02": 1,
"JogVelocity": 1234,
"JogVelocity": 3000,
"PosOffset": 150
}
\ No newline at end of file
......@@ -150,14 +150,32 @@ namespace Misc
};
if (r.End < r.Begin)
{
return new RangeStruct();
return InvalidValue;
}
else
{
return r;
}
}
/// <summary>
/// 范围 减
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <returns></returns>
public static RangeStruct operator -(RangeStruct a, RangeStruct b)
{
if (a.Begin < b.Begin)
{
return new RangeStruct(a.Begin, b.Begin - 1);
}
else {
if (a.End > b.End)
return new RangeStruct(b.End + 1, a.End);
else
return InvalidValue;
}
}
/// <summary>
/// 范围 a小于b
/// </summary>
......
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
......@@ -74,4 +75,23 @@ namespace Misc
}
}
}
public class MainWindowTitle
{
public string Title;
public bool Load()
{
try
{
string json = File.ReadAllText("title.json");
Newtonsoft.Json.JsonConvert.PopulateObject(json, this);
return true;
}
catch
{
return false;
}
}
}
}
......@@ -34,6 +34,13 @@ namespace FLY.OBJComponents.Common
/// 附加信息, json格式
/// </summary>
public string Accessory { get; set; }
/// <summary>
/// 可以被复位
/// </summary>
public bool CanReset { get; set; } = true;
public FlyData_WarningHistory Clone()
{
return new FlyData_WarningHistory()
......
......@@ -107,7 +107,7 @@ namespace FLY.OBJComponents.Server
}
//--------------------------------------------------------------------------------
//连接断开事件, 3秒查一次,不能有复位的机会
//连接断开事件, 3秒后再查一次,不能有复位的机会
FObjBase.PollModule.Current.Poll_Config(PollModule.POLL_CONFIG.ADD,
() =>
{
......@@ -131,11 +131,11 @@ namespace FLY.OBJComponents.Server
//FObjBase.PollModule.Current.Poll_Config(PollModule.POLL_CONFIG.ADD,
// () =>
// {
// foreach(var objError in obj_error)
// foreach (var objError in obj_error)
// {
// object sender = objError.Key;
// ErrorAction errorAction = objError.Value;
// foreach (var ei in errorAction.error_property)
// foreach (var ei in errorAction.error_property)
// {
// //获取描述
// var type = sender.GetType();
......@@ -153,7 +153,7 @@ namespace FLY.OBJComponents.Server
// mWarning.Add(errcode, description, state);
// }
// }
// }, TimeSpan.FromSeconds(1));
// }, TimeSpan.FromSeconds(3));
}
string GetPlcName(int index)
{
......@@ -168,7 +168,7 @@ namespace FLY.OBJComponents.Server
//没有定义全部名字
return $"{plcNames[0]} No.{index + 1}";
}
return plcNames[index];
}
public void ResetError(INotifyPropertyChanged sender)
......@@ -199,16 +199,19 @@ namespace FLY.OBJComponents.Server
var type = sender.GetType();
var property = type.GetProperty(ei.property);
bool b = (bool)property.GetValue(sender, null);
string desp = ei.msg;
ERR_STATE state = b ? ERR_STATE.ON : ERR_STATE.OFF;
string description = ei.msg;
byte errcode = ei.code;//每个报警必须不一样!!
string description = desp;
errorAction.action?.Invoke(ref description, errorAction.state);
mWarning.Add(errcode, description, state);
if (b)
{
//修改报警文字内容
errorAction.action?.Invoke(ref description, errorAction.state);
//报警, 不能被复位的!!!
mWarning.Add(errcode, description, canReset: false);
}
else {
mWarning.Remove(errcode);
}
}
}
#endregion
......
......@@ -62,8 +62,9 @@ namespace FLY.OBJComponents.Server
public void Reset()
{
errors.Clear();
updateReasonList();
if (errors.RemoveAll(e => e.CanReset == true) > 0) {
updateReasonList();
}
}
public void Silence()
......@@ -72,29 +73,15 @@ namespace FLY.OBJComponents.Server
}
#region IWarningServiceSimple
public void Add(int errcode, string description)
{
Add(errcode, description, ERR_STATE.ON);
}
public void Add(int errcode, string description, string accessory)
{
Add(errcode, description, ERR_STATE.ON, accessory, false);
}
public void Add(int errcode, string description, ERR_STATE state)
{
Add(errcode, description, state, "", false );
}
public void Update(int errcode, string description)
{
Update(errcode, description, "");
}
public void Update(int errcode, string description, string accessory)
public void Update(int errcode, string description, string accessory="", bool canReset=true)
{
Add(errcode, description, ERR_STATE.ON, accessory, true);
Add(errcode, description,
accessory:accessory,
isUpdate:true,
canReset:canReset);
}
......@@ -106,7 +93,8 @@ namespace FLY.OBJComponents.Server
/// <param name="state">状态,ON or OFF</param>
/// <param name="accessory">附加信息</param>
/// <param name="isUpdate">就算已经存在,也有刷新</param>
public void Add(int errcode, string description, ERR_STATE state, string accessory, bool isUpdate)
/// <param name="canReset">可以被Reset()清除</param>
public void Add(int errcode, string description, ERR_STATE state = ERR_STATE.ON, string accessory = "", bool isUpdate=false, bool canReset=true)
{
if (!Enable)
return;
......@@ -144,7 +132,8 @@ namespace FLY.OBJComponents.Server
ErrCode = errcode,
Description = description,
State = state,
Accessory = accessory
Accessory = accessory,
CanReset = canReset
};
errors.Add(error);
updateReasonList();
......
......@@ -19,6 +19,7 @@ namespace FLY.Thick.Base.UI
this.paramDictionary = paramDictionary;
//绑定 this.PortName 与 this.paramDictionary.LCUS1_PortName
this.paramDictionary.SetBinding(this, nameof(PortName), ParamDistItemKeys.LCUS1_PortName, "COM1");
this.paramDictionary.SetBinding(this, nameof(Enable), ParamDistItemKeys.LCUS1_Enable, false);
}
}
}
......@@ -5,6 +5,7 @@ using System.IO.Ports;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Threading;
namespace FLY.Thick.Base.UI
{
......@@ -14,48 +15,61 @@ namespace FLY.Thick.Base.UI
public string ErrMsg { get; set; }
public event PropertyChangedEventHandler PropertyChanged;
DispatcherTimer timer;
public void On()
public bool IsOn { get; set; }
private bool enable;
public bool Enable
{
Task.Factory.StartNew(() =>
{
try
{
SerialPort serial = new SerialPort();
serial.PortName = PortName;
serial.BaudRate = 9600;
serial.Open();
byte[] buf = new byte[] { 0xa0, 0x01, 0x01, 0xa2 };
serial.Write(buf, 0, buf.Length);
serial.Close();
ErrMsg = $"{DateTime.Now} ON";
get {
return enable;
}
set {
if (enable != value) {
enable = value;
timer.IsEnabled = enable;
}
catch (Exception e)
{
ErrMsg = e.Message;
}
});
}
}
public void Off()
public LCUS1() {
timer = new DispatcherTimer();
timer.Interval = TimeSpan.FromSeconds(1);
timer.Tick += Timer_Tick;
}
private void Timer_Tick(object sender, EventArgs e)
{
Task.Factory.StartNew(() =>
//每1秒都写状态。 避免通讯不上
try
{
try
{
SerialPort serial = new SerialPort();
serial.PortName = PortName;
serial.BaudRate = 9600;
serial.Open();
byte[] buf = new byte[] { 0xa0, 0x01, 0x00, 0xa1 };
serial.Write(buf, 0, buf.Length);
serial.Close();
ErrMsg = $"{DateTime.Now} OFF";
}
catch (Exception e)
{
ErrMsg = e.Message;
}
});
SerialPort serial = new SerialPort();
serial.PortName = PortName;
serial.BaudRate = 9600;
serial.Open();
byte[] buf;
if (IsOn)
buf = new byte[] { 0xa0, 0x01, 0x01, 0xa2 };
else
buf = new byte[] { 0xa0, 0x01, 0x00, 0xa1 };
serial.Write(buf, 0, buf.Length);
serial.Close();
string msg = IsOn ? "On" : "Off";
ErrMsg = $"{DateTime.Now} {msg}";
}
catch (Exception _e)
{
ErrMsg = _e.Message;
}
}
public void On()
{
IsOn = true;
}
public void Off()
{
IsOn = false;
}
}
}
......@@ -37,7 +37,7 @@ namespace FLY.Thick.Base.UI.OnInit
{
if (e.PropertyName == nameof(warningSystemManager.IsRinging))
{
if (this.paramDictionary.GetValue(ParamDistItemKeys.LCUS1_Enable, false))
if (lcus1.Enable)
{
if (warningSystemManager.IsRinging)
lcus1.On();
......
......@@ -37,7 +37,7 @@ namespace FLY.Thick.Base.UI.OnInit
{
if (e.PropertyName == nameof(warningService.IsRinging))
{
if (this.paramDictionary.GetValue(ParamDistItemKeys.LCUS1_Enable, false))
if (lcus1.Enable)
{
if (warningService.IsRinging)
lcus1.On();
......
......@@ -20,9 +20,9 @@
<RowDefinition Height="auto" />
<RowDefinition Height="496*" />
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" Background="{StaticResource Brush_theme_bar}" >
<StackPanel Orientation="Horizontal" Background="{StaticResource Brushes.TitleBar.Background}" >
<Button Style="{StaticResource Styles.TitleBar.BackButton2}" Command="BrowseBack"/>
<TextBlock Style="{StaticResource TextBlockStyle_Title}" Text="服务器地址"/>
<TextBlock Style="{StaticResource Styles.TitleBar.Text}" Text="服务器地址"/>
</StackPanel>
<DataGrid AlternationCount ="2" AlternatingRowBackground="LightGray" AutoGenerateColumns="False" CanUserAddRows="False" Margin="{StaticResource ControlMargin}"
Grid.Row="1" ItemsSource="{Binding ConnAddrs}" >
......@@ -52,7 +52,7 @@
</DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
<Button Style="{StaticResource ButtonStyle_apply}" VerticalAlignment="Bottom" Margin="0,0,20,-45"
<Button Style="{StaticResource Styles.Button.Apply}" VerticalAlignment="Bottom" Margin="0,0,20,-45"
Command="{Binding ApplyCmd}"/>
</Grid>
</Page>
......@@ -43,7 +43,7 @@ namespace FLY.Thick.Base.UI
public List<ConnAddr> ConnAddrs { get; }
public RelayCommand ApplyCmd { get; }
public RelayCommand ApplyCmd { get; }
FObjServiceClientManager serviceClientManager;
......@@ -70,40 +70,53 @@ namespace FLY.Thick.Base.UI
if (!WdPassword.Authorize("Address"))
return;
Regex regex = new Regex(@"(\d+)\.(\d+)\.(\d+)\.(\d+)\:(\d+)");
Regex regex_hostname = new Regex(@"(\S+)\:(\d+)");
Regex regex_ip = new Regex(@"(\d+)\.(\d+)\.(\d+)\.(\d+)\:(\d+)");
//检测地址格式
foreach(var ca in ConnAddrs)
foreach (var ca in ConnAddrs)
{
Match m = regex.Match(ca.Address);
if (!m.Success)
//把地址的 : 替换为 :
ca.Address = ca.Address.Replace(":", ":");
Match m_hostname = regex_hostname.Match(ca.Address);
Match m_ip = regex_ip.Match(ca.Address);
if (!m_hostname.Success)
{
//格式错误
FLY.ControlLibrary.Window_WarningTip.Show(
"格式错误",
$"{ca.ConnName} 地址格式错误! 正确为 IP地址:端口号, 请检查");
$"{ca.ConnName} 地址格式错误! 正确为 IP地址:端口号 或 域名:端口号 , 请检查");
return;
}
for (int i = 0; i < 4; i++)
if (m_ip.Success)
{
if (!int.TryParse(m.Groups[1 + i].Value, out int num))
//这个IP
for (int i = 0; i < 4; i++)
{
//格式错误
FLY.ControlLibrary.Window_WarningTip.Show(
"格式错误",
$"{ca.ConnName} 地址格式错误! 第{i+1} 位IP段 出错");
return;
}
if (num < 0 || num > 255)
{
//格式错误
FLY.ControlLibrary.Window_WarningTip.Show(
"格式错误",
$"{ca.ConnName} 地址格式错误! 第{i + 1}位IP段应该在 0~255 之间");
return;
if (!int.TryParse(m_ip.Groups[1 + i].Value, out int num))
{
//格式错误
FLY.ControlLibrary.Window_WarningTip.Show(
"格式错误",
$"{ca.ConnName} 地址格式错误! 第{i + 1} 位IP段 出错");
return;
}
if (num < 0 || num > 255)
{
//格式错误
FLY.ControlLibrary.Window_WarningTip.Show(
"格式错误",
$"{ca.ConnName} 地址格式错误! 第{i + 1}位IP段应该在 0~255 之间");
return;
}
}
}
{
if (!int.TryParse(m.Groups[5].Value, out int port))
if (!int.TryParse(m_hostname.Groups[2].Value, out int port))
{
//格式错误
FLY.ControlLibrary.Window_WarningTip.Show(
......@@ -120,6 +133,15 @@ namespace FLY.Thick.Base.UI
return;
}
}
var ep = Misc.StringConverter.ToIPEndPoint(ca.Address);
if (ep == null) {
//不能转为ep
FLY.ControlLibrary.Window_WarningTip.Show(
"地址出错",
$"{ca.ConnName} 不能有效转换IPv4");
return;
}
}
int modifyCnt = 0;
......
......@@ -88,7 +88,7 @@
</StackPanel>
</StackPanel>
<StackPanel Orientation="Horizontal">
<StackPanel Margin="{StaticResource ControlMargin}">
<TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="差异比例" />
......@@ -98,14 +98,6 @@
<TextBlock Style="{StaticResource Styles.Text.FieldHeader.Comment}" Text="样品1AD/样品0AD&#13;与上一次比较" />
</StackPanel>
</StackPanel>
<StackPanel Margin="{StaticResource ControlMargin}">
<TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="差异时间范围" />
<StackPanel Orientation="Horizontal">
<TextBox Style="{StaticResource Styles.Text.FieldContent.Input.Card}" Text="{Binding ErrIntervalMin}" />
<TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}" Text="min"/>
<TextBlock Style="{StaticResource Styles.Text.FieldHeader.Comment}" Text="两次时间点比较,&#13;时间点的间隔最大时长。 大于它无效,不能比较" />
</StackPanel>
</StackPanel>
</StackPanel>
</StackPanel>
</Border>
......@@ -277,38 +269,6 @@
</StackPanel>
</Border>
<Border Style="{StaticResource Styles.Card.Border}">
<StackPanel>
<TextBlock Style="{StaticResource Styles.Card.Title}"
Text="采集记录"/>
<StackPanel Orientation="Horizontal">
<Button Style="{StaticResource Styles.Button.Square2}" Content="获取" Command="{Binding GetTempDataCmd}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<ItemsControl ItemsSource="{Binding TempData}" >
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<DataGrid ItemsSource="{Binding .}" IsReadOnly="True" Margin="{StaticResource ControlMargin}" AutoGenerateColumns="False" Width="400" TextBlock.FontSize="12" TextBlock.FontWeight="Normal"
>
<DataGrid.Columns>
<DataGridTextColumn Header="复位" Binding="{Binding IsReset}" Width="100"/>
<DataGridTextColumn Header="时间" Binding="{Binding Time,StringFormat={}{0:HH:mm:ss}}" FontSize="10" Width="100"/>
<DataGridTextColumn Header="AD" Binding="{Binding Ad}" Width="100"/>
<DataGridTextColumn Header="滤波AD" Binding="{Binding FilterAd}" Width="100"/>
</DataGrid.Columns>
</DataGrid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
</StackPanel>
</Border>
</StackPanel>
</ScrollViewer>
<Button Style="{StaticResource Styles.Button.Apply}" VerticalAlignment="Bottom" Margin="0,0,20,20"
......
......@@ -85,12 +85,6 @@ namespace FLY.Thick.Base.UI
/// </summary>
public double CrossErrPercent { get; set; }
/// <summary>
/// 异常比较 时间间隔范围;
/// 两次时间点比较, 时间点的间隔最大时长。 大于它无效,不能比较
/// </summary>
public int ErrIntervalMin { get; set; }
/// <summary>
/// 参数:样品点参数
/// </summary>
......@@ -108,12 +102,11 @@ namespace FLY.Thick.Base.UI
#region Command
public RelayCommand ApplyCmd { get; private set; }
public RelayCommand GetTempDataCmd { get; private set; }
#endregion
public event PropertyChangedEventHandler PropertyChanged;
public List<List<TempFilterData>> TempData { get; private set; }
public string InfoName { get; set; }
IGetSampleService getSampleService;
......@@ -121,7 +114,6 @@ namespace FLY.Thick.Base.UI
public PgGetSampleVm()
{
ApplyCmd = new RelayCommand(Apply);
GetTempDataCmd = new RelayCommand(GetTempData);
}
......@@ -139,7 +131,6 @@ namespace FLY.Thick.Base.UI
Misc.BindingOperations.SetBinding(this.getSampleService, nameof(this.getSampleService.ErrPercent), this, nameof(ErrPercent));
Misc.BindingOperations.SetBinding(this.getSampleService, nameof(this.getSampleService.ErrValue), this, nameof(ErrValue));
Misc.BindingOperations.SetBinding(this.getSampleService, nameof(this.getSampleService.CrossErrPercent), this, nameof(CrossErrPercent));
Misc.BindingOperations.SetBinding(this.getSampleService, nameof(this.getSampleService.ErrIntervalMin), this, nameof(ErrIntervalMin));
Misc.BindingOperations.SetBinding(this.getSampleService, nameof(this.getSampleService.SearchRange), this, nameof(SearchRange));
......@@ -257,7 +248,7 @@ namespace FLY.Thick.Base.UI
this.getSampleService.ErrPercent = this.ErrPercent;
this.getSampleService.ErrValue = this.ErrValue;
this.getSampleService.CrossErrPercent = this.CrossErrPercent;
this.getSampleService.ErrIntervalMin = this.ErrIntervalMin;
for (int i = 0; i < Samples.Count(); i++)
{
......@@ -287,17 +278,7 @@ namespace FLY.Thick.Base.UI
TimeSpan.FromSeconds(2));
}
private void GetTempData()
{
getSampleService.GetTempFilterDatas((asyncContext, retData) =>
{
var ll = retData as List<List<TempFilterData>>;
TempData = ll;
FLY.ControlLibrary.Window_Tip.Show("加载完成",
$"共加载{ll.Count()}列数据",
TimeSpan.FromSeconds(2));
}, null);
}
}
public class PgGetSampleVmUt : PgGetSampleVm
{
......
......@@ -115,7 +115,8 @@
</Border>
</Grid>
</Button>
<Button x:Name="grid_error" Style="{StaticResource DynAreaErrorStyle}" d:DataContext="{StaticResource errorVm}"/>
<Button x:Name="grid_error" Style="{StaticResource DynAreaErrorStyle}" d:DataContext="{StaticResource errorVm}"
Command="{Binding OpenWarningCmd}"/>
</Grid>
</UserControl>
......@@ -61,13 +61,6 @@ namespace FLY.Thick.Base.IService
/// </summary>
double CrossErrPercent { get; set; }
/// <summary>
/// 异常比较 时间间隔范围;
/// 两次时间点比较, 时间点的间隔最大时长。 大于它无效,不能比较
/// </summary>
int ErrIntervalMin { get; set; }
/// <summary>
/// 参数:样品点参数
/// </summary>
......@@ -191,10 +184,6 @@ namespace FLY.Thick.Base.IService
/// </summary>
public double SampleValue { get; set; }
/// <summary>
/// 采集失败了
/// </summary>
public bool IsFailure { get; set; }
#region INotifyPropertyChanged 成员
public event PropertyChangedEventHandler PropertyChanged;
......
......@@ -553,7 +553,7 @@ namespace FLY.Thick.Base.Server
break;
if (!Misc.MyBase.ISVALIDATA(breakdats[i]))
break;
if (breakdats[i] < breakdats[i + num])
if (breakdats[i] <= breakdats[i + num])
{
//在减少
bg = i;
......@@ -582,7 +582,7 @@ namespace FLY.Thick.Base.Server
if (!Misc.MyBase.ISVALIDATA(filterdats[i]))
break;
if (breakdats[i] < breakdats[i - num])
if (breakdats[i] <= breakdats[i - num])
{
//在减少
eg = i;
......
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