Commit e0a9f888 authored by 潘栩锋's avatar 潘栩锋 🚴

2019.03.21 顺之航

parent b3c377da
......@@ -77,10 +77,11 @@
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Background="{TemplateBinding Background}"
Height="{TemplateBinding Height}"
Width="{TemplateBinding Width}"
>
<ContentPresenter RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Border>
......@@ -97,6 +98,7 @@
</Setter.Value>
</Setter>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="Transparent"/>
</Style>
<Style TargetType="Button" x:Key="ButtonStyle2">
<Setter Property="Margin" Value="6"/>
......
......@@ -219,12 +219,13 @@ namespace FObjBase
Poll_Config(POLL_CONFIG.ADD, pollfunc, new TimeSpan(), false, true, owner, markno, true);
}
static DateTime dt_last = DateTime.Now;
System.Windows.Threading.DispatcherTimer timer;
public System.Windows.Threading.DispatcherTimer timer;
/// <summary>
/// 不需要自己创建实例,因为已经创建了静态的对象
/// </summary>
public PollModule()
{
timer = new System.Windows.Threading.DispatcherTimer();
timer.Interval = TimeSpan.FromMilliseconds(1);
timer.Tick += (s, e) =>
......
......@@ -5,45 +5,61 @@ using System.Text;
namespace Misc
{
/// <summary>
/// 扩展 Enumerable 计算
/// </summary>
public static class Enumerable
{
//
// 摘要:
// 计算 System.Double 值序列的Sigma,该值可通过调用输入序列的每个元素的转换函数获取。
//
// 参数:
// source:
// 要计算其平均值的值序列。
//
// selector:
// 应用于每个元素的转换函数。
//
// 类型参数:
// TSource:
// source 中的元素的类型。
//
// 返回结果:
// 值序列的Sigma。
//
// 异常:
// T:System.ArgumentNullException:
// source 或 selector 为 null。
//
// T:System.InvalidOperationException:
// source 中不包含任何元素。
/// <summary>
/// 获取 σ
/// </summary>
/// <typeparam name="TSource"></typeparam>
/// <param name="source"></param>
/// <param name="selector"></param>
/// <returns></returns>
public static double Sigma<TSource>(this IEnumerable<TSource> source, Func<TSource, double> selector)
{
if (source.Count() == 0)
return -1;
return double.NaN;
double avg = source.Average(selector);
double sum_pow = source.Sum((s) => Math.Pow((selector(s) - avg), 2));
return Math.Sqrt(sum_pow / (source.Count() - 1));
}
/// <summary>
/// 获取 σ
/// </summary>
/// <param name="source"></param>
/// <returns></returns>
public static double Sigma(this IEnumerable<int> source)
{
return source.Sigma(d => (int)d);
}
/// <summary>
/// 获取 σ
/// </summary>
/// <param name="source"></param>
/// <returns></returns>
public static double Sigma(this IEnumerable<double> source)
{
return source.Sigma(d => d);
var list = source.Where((d) =>
{
if (double.IsNaN(d))
return false;
else
return true;
});
return list.Sigma(d => d);
}
/// <summary>
/// 获取CPK
/// </summary>
/// <typeparam name="TSource"></typeparam>
/// <param name="source"></param>
/// <param name="selector"></param>
/// <param name="usl"></param>
/// <param name="lsl"></param>
/// <returns></returns>
public static double CPK<TSource>(this IEnumerable<TSource> source, Func<TSource, double> selector, double usl, double lsl)
{
if (source.Count() == 0)
......@@ -67,10 +83,32 @@ namespace Misc
return CPK;
}
/// <summary>
/// 获取CPK
/// </summary>
/// <param name="source"></param>
/// <param name="usl"></param>
/// <param name="lsl"></param>
/// <returns></returns>
public static double CPK(this IEnumerable<double> source, double usl, double lsl)
{
return source.CPK(d => d, usl, lsl);
var list = source.Where((d) =>
{
if (double.IsNaN(d))
return false;
else
return true;
});
return list.CPK(d => d, usl, lsl);
}
/// <summary>
/// 获取直方图,统计数据
/// </summary>
/// <typeparam name="TSource"></typeparam>
/// <param name="source"></param>
/// <param name="selector"></param>
/// <param name="step"></param>
/// <returns></returns>
public static List<XY> GetHistogram<TSource>(this IEnumerable<TSource> source, Func<TSource, double> selector, double step)
{
List<XY> list = new List<XY>();
......@@ -90,16 +128,72 @@ namespace Misc
}
}
//没有数据也能排序的,不会错
list.Sort();
return list;
}
/// <summary>
/// 获取直方图,统计数据
/// </summary>
/// <param name="source"></param>
/// <param name="step"></param>
/// <returns></returns>
public static List<XY> GetHistogram(this IEnumerable<double> source, double step)
{
return source.GetHistogram(d => d, step);
var list = source.Where((d) =>
{
if (double.IsNaN(d))
return false;
else
return true;
});
return list.GetHistogram(d => d, step);
}
/// <summary>
/// 当有 NaN 数据,不统计它。
/// </summary>
/// <param name="source"></param>
/// <returns></returns>
public static double AverageNoNull(this IEnumerable<double> source)
{
return source.AverageNoNull(d => d);
}
/// <summary>
/// 当有 NaN 数据,不统计它。
/// </summary>
/// <typeparam name="TSource"></typeparam>
/// <param name="source"></param>
/// <param name="selector"></param>
/// <returns></returns>
public static double AverageNoNull<TSource>(this IEnumerable<TSource> source, Func<TSource, double> selector)
{
if (source.Count() == 0)
return double.NaN;
var list = source.Select(selector);
var list2 = list.Where((d) =>
{
if (double.IsNaN(d))
return false;
else
return true;
});
if (list2.Count() == 0)
return double.NaN;
return list2.Average();
}
}
/// <summary>
/// X Y 组合
/// </summary>
public class XY : IComparable, ICloneable, ICopiable
{
public double X { get; set; }
......@@ -127,7 +221,10 @@ namespace Misc
xy.Copy(this);
return xy;
}
public override string ToString()
{
return $"{X}.{Y}";
}
public void Copy(object src)
{
Misc.PropertiesManager.CopyTo(src, this);
......
......@@ -102,6 +102,23 @@ namespace Misc
}
}
/// <summary>
/// 检测 dest是否 实现了ICopiable,如果是,调用dest.Copy ;否 调用CopyTo(src,dest)
/// </summary>
/// <param name="src"></param>
/// <param name="dest"></param>
public static void AutoCopyTo(object src, object dest)
{
if (dest is ICopiable)
{
((ICopiable)dest).Copy(src);
}
else
{
CopyTo(src, dest);
}
}
}
/// <summary>
......
......@@ -14,10 +14,10 @@
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" />
</startup>
<system.data>
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SQLite.EF6" />
<add name="SQLite Data Provider (Entity Framework 6)" invariant="System.Data.SQLite.EF6" description=".NET Framework Data Provider for SQLite (Entity Framework 6)" type="System.Data.SQLite.EF6.SQLiteProviderFactory, System.Data.SQLite.EF6" />
<remove invariant="System.Data.SQLite" /><add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" /></DbProviderFactories>
</system.data>
</configuration>
\ No newline at end of file
</system.data></configuration>
\ No newline at end of file
......@@ -9,7 +9,7 @@ using System.Threading.Tasks;
namespace FLY.OBJComponents.Common
{
public class FlyData_WarningHistory : IFlyData, IPack2
public class FlyData_WarningHistory : IFlyData
{
/// <summary>
/// 时间
......@@ -79,62 +79,6 @@ namespace FLY.OBJComponents.Common
str += "," + Description.ToString();
return str;
}
public byte[] ToBytes()
{
List<byte> buf = new List<byte>();
buf.AddRange(BitConverter.GetBytes(Time.Ticks));
buf.Add(ErrCode);
buf.AddRange(BitConverter.GetBytes((int)State));
byte[] bs = Misc.Converter.StringToBytes(Description);
int len;
if (bs == null)
len = 0;
else
len = bs.Length;
buf.AddRange(BitConverter.GetBytes(len));
if (len > 0)
buf.AddRange(bs);
return buf.ToArray();
}
public bool TryParse(byte[] value, int index, out int cnt)// ref int idx)
{
cnt = 8 + 1 + 4 + 4;
if (value.Length - index < cnt)
return false;
int idx = index;
Time = new DateTime(BitConverter.ToInt64(value, idx));
idx += 8;
ErrCode = value[idx];
idx++;
State = (ERR_STATE)BitConverter.ToInt32(value, idx);
idx += 4;
int len = BitConverter.ToInt32(value, idx);
idx += 4;
cnt += len;
if (value.Length - index < cnt)
return false;
if (len == 0)
Description = "";
else
{
Description = Misc.Converter.BytesToString(value, idx, len);
}
idx += len;
return true;
}
public bool TryParse(byte[] value)
{
int cnt;
return TryParse(value, 0, out cnt);
}
}
/// <summary>
......@@ -149,11 +93,7 @@ namespace FLY.OBJComponents.Common
/// <summary>
/// 关闭
/// </summary>
OFF,
/// <summary>
/// 只发生了一次
/// </summary>
ONCE
OFF
}
/// <summary>
......
......@@ -52,14 +52,14 @@
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" />
<Reference Include="System.Data.SQLite, Version=1.0.109.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
<HintPath>..\..\..\Project.FLY.Thick.Normal\packages\System.Data.SQLite.Core.1.0.109.2\lib\net46\System.Data.SQLite.dll</HintPath>
<Reference Include="System.Data.SQLite, Version=1.0.110.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
<HintPath>..\..\..\Project.FLY.Thick.Normal\packages\System.Data.SQLite.Core.1.0.110.0\lib\net46\System.Data.SQLite.dll</HintPath>
</Reference>
<Reference Include="System.Data.SQLite.EF6, Version=1.0.109.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
<HintPath>..\..\..\Project.FLY.Thick.Normal\packages\System.Data.SQLite.EF6.1.0.109.0\lib\net46\System.Data.SQLite.EF6.dll</HintPath>
<Reference Include="System.Data.SQLite.EF6, Version=1.0.110.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
<HintPath>..\..\..\Project.FLY.Thick.Normal\packages\System.Data.SQLite.EF6.1.0.110.0\lib\net46\System.Data.SQLite.EF6.dll</HintPath>
</Reference>
<Reference Include="System.Data.SQLite.Linq, Version=1.0.109.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
<HintPath>..\..\..\Project.FLY.Thick.Normal\packages\System.Data.SQLite.Linq.1.0.109.0\lib\net46\System.Data.SQLite.Linq.dll</HintPath>
<Reference Include="System.Data.SQLite.Linq, Version=1.0.110.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
<HintPath>..\..\..\Project.FLY.Thick.Normal\packages\System.Data.SQLite.Linq.1.0.110.0\lib\net46\System.Data.SQLite.Linq.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
......@@ -129,10 +129,10 @@
<PropertyGroup>
<ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\..\..\Project.FLY.Thick.Normal\packages\System.Data.SQLite.Core.1.0.109.2\build\net46\System.Data.SQLite.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\Project.FLY.Thick.Normal\packages\System.Data.SQLite.Core.1.0.109.2\build\net46\System.Data.SQLite.Core.targets'))" />
<Error Condition="!Exists('..\..\..\Project.FLY.Thick.Normal\packages\Fody.3.3.2\build\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\Project.FLY.Thick.Normal\packages\Fody.3.3.2\build\Fody.targets'))" />
<Error Condition="!Exists('..\..\..\Project.FLY.Thick.Normal\packages\PropertyChanged.Fody.2.6.0\build\PropertyChanged.Fody.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\Project.FLY.Thick.Normal\packages\PropertyChanged.Fody.2.6.0\build\PropertyChanged.Fody.props'))" />
<Error Condition="!Exists('..\..\..\Project.FLY.Thick.Normal\packages\System.Data.SQLite.Core.1.0.110.0\build\net46\System.Data.SQLite.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\Project.FLY.Thick.Normal\packages\System.Data.SQLite.Core.1.0.110.0\build\net46\System.Data.SQLite.Core.targets'))" />
</Target>
<Import Project="..\..\..\Project.FLY.Thick.Normal\packages\System.Data.SQLite.Core.1.0.109.2\build\net46\System.Data.SQLite.Core.targets" Condition="Exists('..\..\..\Project.FLY.Thick.Normal\packages\System.Data.SQLite.Core.1.0.109.2\build\net46\System.Data.SQLite.Core.targets')" />
<Import Project="..\..\..\Project.FLY.Thick.Normal\packages\Fody.3.3.2\build\Fody.targets" Condition="Exists('..\..\..\Project.FLY.Thick.Normal\packages\Fody.3.3.2\build\Fody.targets')" />
<Import Project="..\..\..\Project.FLY.Thick.Normal\packages\System.Data.SQLite.Core.1.0.110.0\build\net46\System.Data.SQLite.Core.targets" Condition="Exists('..\..\..\Project.FLY.Thick.Normal\packages\System.Data.SQLite.Core.1.0.110.0\build\net46\System.Data.SQLite.Core.targets')" />
</Project>
\ No newline at end of file
......@@ -41,7 +41,9 @@ namespace FLY.OBJComponents.Server
ReasonList = new Buffer<FlyData_WarningHistory>();
NewestList = new BufferStorage<FlyData_WarningHistory>("warning_newest.csv");
}
/// <summary>
/// 报警复位!!!!
/// </summary>
public Action ResetEvent;
public void Reset()
{
......@@ -49,7 +51,7 @@ namespace FLY.OBJComponents.Server
ResetEvent?.Invoke();
}
/// <summary>
/// 正在报警
/// 正在报警!!!
/// </summary>
public Action RingEvent;
......
......@@ -4,8 +4,8 @@
<package id="Fody" version="3.3.2" targetFramework="net462" developmentDependency="true" />
<package id="Newtonsoft.Json" version="12.0.1" targetFramework="net462" />
<package id="PropertyChanged.Fody" version="2.6.0" targetFramework="net462" />
<package id="System.Data.SQLite" version="1.0.109.2" targetFramework="net462" />
<package id="System.Data.SQLite.Core" version="1.0.109.2" targetFramework="net462" />
<package id="System.Data.SQLite.EF6" version="1.0.109.0" targetFramework="net462" />
<package id="System.Data.SQLite.Linq" version="1.0.109.0" targetFramework="net462" />
<package id="System.Data.SQLite" version="1.0.110.0" targetFramework="net462" />
<package id="System.Data.SQLite.Core" version="1.0.110.0" targetFramework="net462" />
<package id="System.Data.SQLite.EF6" version="1.0.110.0" targetFramework="net462" />
<package id="System.Data.SQLite.Linq" version="1.0.110.0" targetFramework="net462" />
</packages>
\ No newline at end of file
......@@ -137,9 +137,6 @@
<Compile Include="Page_DynAreaWarning.xaml.cs">
<DependentUpon>Page_DynAreaWarning.xaml</DependentUpon>
</Compile>
<Compile Include="Page_FixAnalyse.xaml.cs">
<DependentUpon>Page_FixAnalyse.xaml</DependentUpon>
</Compile>
<Compile Include="Page_FlyAD.xaml.cs">
<DependentUpon>Page_FlyAD.xaml</DependentUpon>
</Compile>
......@@ -306,10 +303,6 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Page_FixAnalyse.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Page_FlyAD.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
......
......@@ -45,6 +45,16 @@ namespace ThickTcpUiInWindow
lmodule.UIModules.Add(kv.Key, kv.Value);
}
//把不支持的模块删除
mLayout.DynAreaItems.RemoveAll(c => !lmodule.UIModules.ContainsKey(c.Module));
foreach (var tabitem in mLayout.Items)
{
tabitem.Graphs.RemoveAll(c => !lmodule.UIModules.ContainsKey(c.Module));
}
InitializeComponent_bulkgraph();
InitializeComponent_dynarea();
InitializeComponent_menu();
......@@ -81,8 +91,10 @@ namespace ThickTcpUiInWindow
public void Init(TabControl tabControl, StackPanel stackpanel_dynarea, StackPanel stackpanel_menu,
UIModule.FLYLayout layout)
{
this.mLayout = layout;
this.tabControl = tabControl;
this.stackpanel_dynarea = stackpanel_dynarea;
this.stackpanel_menu = stackpanel_menu;
......@@ -200,9 +212,7 @@ namespace ThickTcpUiInWindow
components.AddRange(item.Graphs);
components.AddRange(mLayout.DynAreaItems);
//components.AddRange(mLayout.MenuItems);
Dictionary<string, List<int>> modules = new Dictionary<string, List<int>>();
foreach (UIModule.FLYComponent c in components)
{
......@@ -214,8 +224,10 @@ namespace ThickTcpUiInWindow
foreach (var m in modules)
{
FLY.UI.Module.IUIModule pm = lmodule.UIModules[m.Key].UIModule;
pm.MatchParam(m.Value.ToArray());
}
}
}
......
<Page x:Class="ThickTcpUiInWindow.Page_FixAnalyse"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:ThickTcpUiInWindow"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300"
Title="Page_FixAnalyse">
<Grid>
</Grid>
</Page>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
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.Navigation;
using System.Windows.Shapes;
namespace ThickTcpUiInWindow
{
/// <summary>
/// Page_FixAnalyse.xaml 的交互逻辑
/// </summary>
public partial class Page_FixAnalyse : Page
{
public Page_FixAnalyse()
{
InitializeComponent();
}
}
}
......@@ -30,7 +30,7 @@ namespace ThickTcpUiInWindow
/// <summary>
/// 报警管理
/// </summary>
public WarningServiceSimple mWarningService;
//public WarningServiceSimple mWarningService;
/// <summary>
/// 扫描报警
......
......@@ -13,7 +13,7 @@ namespace ThickTcpUiInWindow.UIModule
/// </summary>
public int ID { get; set; }
protected void NotifyPropertyChanged(string propertyName)
protected void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
......
......@@ -192,7 +192,7 @@ namespace ThickTcpUiInWindow.UIModule
if (len != value)
{
len = value;
NotifyPropertyChanged("Len");
OnPropertyChanged("Len");
}
}
}
......@@ -213,7 +213,7 @@ namespace ThickTcpUiInWindow.UIModule
if (beginno != value)
{
beginno = value;
NotifyPropertyChanged("BeginNo");
OnPropertyChanged("BeginNo");
}
}
}
......@@ -229,7 +229,7 @@ namespace ThickTcpUiInWindow.UIModule
if (endno != value)
{
endno = value;
NotifyPropertyChanged("EndNo");
OnPropertyChanged("EndNo");
}
}
}
......@@ -245,7 +245,7 @@ namespace ThickTcpUiInWindow.UIModule
if (isall != value)
{
isall = value;
NotifyPropertyChanged("IsAll");
OnPropertyChanged("IsAll");
}
}
}
......@@ -262,7 +262,7 @@ namespace ThickTcpUiInWindow.UIModule
if (type != value)
{
type = value;
NotifyPropertyChanged("Type");
OnPropertyChanged("Type");
}
}
}
......@@ -279,7 +279,7 @@ namespace ThickTcpUiInWindow.UIModule
if (xtype != value)
{
xtype = value;
NotifyPropertyChanged("XType");
OnPropertyChanged("XType");
}
}
}
......@@ -299,7 +299,7 @@ namespace ThickTcpUiInWindow.UIModule
if (bm != value)
{
bm = value;
NotifyPropertyChanged("BM");
OnPropertyChanged("BM");
}
}
}
......@@ -317,7 +317,7 @@ namespace ThickTcpUiInWindow.UIModule
set
{
_yrangepercent = value;
NotifyPropertyChanged("YRangePercent");
OnPropertyChanged("YRangePercent");
}
}
......@@ -333,7 +333,7 @@ namespace ThickTcpUiInWindow.UIModule
if (title != value)
{
title = value;
NotifyPropertyChanged("Title");
OnPropertyChanged("Title");
}
}
}
......@@ -353,7 +353,7 @@ namespace ThickTcpUiInWindow.UIModule
if (mix != value)
{
mix = value;
NotifyPropertyChanged("Mix");
OnPropertyChanged("Mix");
}
}
}
......@@ -374,7 +374,7 @@ namespace ThickTcpUiInWindow.UIModule
if (isautotarget != value)
{
isautotarget = value;
NotifyPropertyChanged("IsAutoTarget");
OnPropertyChanged("IsAutoTarget");
}
}
}
......@@ -394,7 +394,7 @@ namespace ThickTcpUiInWindow.UIModule
if (ispercent != value)
{
ispercent = value;
NotifyPropertyChanged("IsPercent");
OnPropertyChanged("IsPercent");
}
}
}
......
......@@ -8,11 +8,13 @@
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Themes/Dictionary_MyStyle.xaml"/>
</ResourceDictionary.MergedDictionaries>
<local:WindowABHelperViewModel x:Key="viewmodel"/>
</ResourceDictionary>
</Window.Resources>
<Grid TextBlock.FontSize="24" TextBlock.FontStyle="Normal" >
<Grid TextBlock.FontSize="24" TextBlock.FontStyle="Normal" d:DataContext="{StaticResource viewmodel}">
<StackPanel Orientation="Vertical" Margin="5,20">
<StackPanel Orientation="Horizontal" Margin="0,5">
<Border Width="150" Background="{StaticResource Color_theme_activity}" Margin="0,5,5,5" >
......
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Windows;
......@@ -19,41 +20,40 @@ namespace ThickTcpUiInWindow
/// </summary>
public partial class Window_ABHelper : FLY.ControlLibrary.WindowBigClose
{
private ABHelper mABHelper;
public double A;
public double B;
WindowABHelperViewModel viewModel;
public double A { get { return viewModel.A; } }
public double B { get { return viewModel.B; } }
//外部值
private double a;
private double b;
public Window_ABHelper()
{
InitializeComponent();
mABHelper = new ABHelper();
this.DataContext = mABHelper;
viewModel = new WindowABHelperViewModel();
this.DataContext = viewModel;
}
public void Init(double Comp,double Shift)
public void Init(double a,double b)
{
a = Comp;
b = Shift;
mABHelper.A = a;
mABHelper.B = b;
this.a = a;
this.b = b;
A = mABHelper.A;
B = mABHelper.B;
viewModel.A = a;
viewModel.B = b;
}
private void button_cal_Click(object sender, RoutedEventArgs e)
{
if ((mABHelper.X2 == mABHelper.X1) && (mABHelper.Y2 != mABHelper.Y1))
if ((viewModel.X2 == viewModel.X1) && (viewModel.Y2 != viewModel.Y1))
{
FLY.ControlLibrary.Window_WarningTip.Show("异常!!!!",
"X2 == X1 但 Y2 != Y1",
TimeSpan.FromSeconds(2));
return;
}
if ((mABHelper.X2 != mABHelper.X1) && (mABHelper.Y2 == mABHelper.Y1))
if ((viewModel.X2 != viewModel.X1) && (viewModel.Y2 == viewModel.Y1))
{
FLY.ControlLibrary.Window_WarningTip.Show("异常!!!!",
"X2 != X1 但 Y2 == Y1",
......@@ -68,18 +68,18 @@ namespace ThickTcpUiInWindow
return;
}
if ((mABHelper.X2 == mABHelper.X1) && (mABHelper.Y2 == mABHelper.Y1))
if ((viewModel.X2 == viewModel.X1) && (viewModel.Y2 == viewModel.Y1))
{
mABHelper.A = a;
mABHelper.B = mABHelper.Y2 - mABHelper.X2 + b;
viewModel.A = a;
viewModel.B = viewModel.Y2 - viewModel.X2 + b;
}
else
{
double x2 = (mABHelper.X2 - b) / a;
double x1 = (mABHelper.X1 - b) / a;
double x2 = (viewModel.X2 - b) / a;
double x1 = (viewModel.X1 - b) / a;
mABHelper.A = (mABHelper.Y2 - mABHelper.Y1) / (x2 - x1);
mABHelper.B = mABHelper.Y2 - mABHelper.A * x2;
viewModel.A = (viewModel.Y2 - viewModel.Y1) / (x2 - x1);
viewModel.B = viewModel.Y2 - viewModel.A * x2;
}
FLY.ControlLibrary.Window_Tip.Show("成功",
......@@ -92,4 +92,20 @@ namespace ThickTcpUiInWindow
}
}
public class WindowABHelperViewModel : INotifyPropertyChanged
{
public double X1 { get; set; }
public double Y1 { get; set; }
public double X2 { get; set; }
public double Y2 { get; set; }
public double A { get; set; }
public double B { get; set; }
public event PropertyChangedEventHandler PropertyChanged;
}
}
......@@ -20,29 +20,28 @@ namespace ThickTcpUiInWindow
/// </summary>
public partial class Window_AHelper : FLY.ControlLibrary.WindowBigClose
{
private ABHelper mABHelper;
public double A;
private WindowAHelperViewModel viewModel;
public double A { get { return viewModel.A; } }
private double a;
public Window_AHelper()
{
InitializeComponent();
mABHelper = new ABHelper();
this.DataContext = mABHelper;
viewModel = new WindowAHelperViewModel();
this.DataContext = viewModel;
}
public void Init(double Comp)
public void Init(double a)
{
a = Comp;
mABHelper.A = a;
A = mABHelper.A;
this.a = a;
viewModel.A = a;
}
private void button_cal_Click(object sender, RoutedEventArgs e)
{
if (mABHelper.X1 == 0 || mABHelper.Y1 == 0)
if (viewModel.X == 0 || viewModel.Y == 0)
{
FLY.ControlLibrary.Window_WarningTip.Show("异常!!!!",
"X1=0 或 Y1=0",
"X=0 或 Y=0",
TimeSpan.FromSeconds(2));
return;
}
......@@ -53,10 +52,9 @@ namespace ThickTcpUiInWindow
TimeSpan.FromSeconds(2));
return;
}
double x1 = (mABHelper.X1) / a;
double x = (viewModel.X) / a;
mABHelper.A = mABHelper.Y1 / x1;
A = mABHelper.A;
viewModel.A = viewModel.Y / x;
}
private void button_apply_Click(object sender, RoutedEventArgs e)
{
......@@ -65,93 +63,14 @@ namespace ThickTcpUiInWindow
}
public class ABHelper : INotifyPropertyChanged
public class WindowAHelperViewModel : INotifyPropertyChanged
{
private double x1;
public double X1
{
get { return x1; }
set
{
if (x1 != value)
{
x1 = value;
NotifyPropertyChanged("X1");
}
}
}
private double y1;
public double Y1
{
get { return y1; }
set
{
if (y1 != value)
{
y1 = value;
NotifyPropertyChanged("Y1");
}
}
}
private double x2;
public double X2
{
get { return x2; }
set
{
if (x2 != value)
{
x2 = value;
NotifyPropertyChanged("X2");
}
}
}
private double y2;
public double Y2
{
get { return y2; }
set
{
if (y2 != value)
{
y2 = value;
NotifyPropertyChanged("Y2");
}
}
}
private double a;
public double A
{
get { return a; }
set
{
if (a != value)
{
a = value;
NotifyPropertyChanged("A");
}
}
}
private double b;
public double B
{
get { return b; }
set
{
if (b != value)
{
b = value;
NotifyPropertyChanged("B");
}
}
}
public double X { get; set; }
public double Y { get; set; }
public double A { get; set; }
void NotifyPropertyChanged(string propertyname)
{
if (PropertyChanged != null)
PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyname));
}
public event PropertyChangedEventHandler PropertyChanged;
}
}
......@@ -28,9 +28,9 @@ namespace FLY.Thick.Base.Client
/// 注册timegrid 事件
/// </summary>
/// <param name="handler"></param>
public void RegistTimeGridEvent(TimeGridEventHandler handler)
public void RegistTimeGridEvent(FixEventHandler handler)
{
TimeGridEvent += handler;
FixEvent += handler;
CurrObjSys.SenseConfigEx(
mConn, mServerID, ID,
Misc.MyBase.BIT(FIX_OBJ_INTERFACE.PUSH_TIMEGRID),
......@@ -40,10 +40,10 @@ namespace FLY.Thick.Base.Client
/// 关闭注册timegrid 事件
/// </summary>
/// <param name="handler"></param>
public void UnRegistTimeGridEvent(TimeGridEventHandler handler)
public void UnRegistTimeGridEvent(FixEventHandler handler)
{
TimeGridEvent -= handler;
if (TimeGridEvent == null)
FixEvent -= handler;
if (FixEvent == null)
{
CurrObjSys.SenseConfigEx(
mConn, mServerID, ID,
......@@ -52,7 +52,7 @@ namespace FLY.Thick.Base.Client
}
}
event TimeGridEventHandler TimeGridEvent;
event FixEventHandler FixEvent;
#endregion
......@@ -69,7 +69,7 @@ namespace FLY.Thick.Base.Client
{
//设置推送
if (TimeGridEvent != null)
if (FixEvent != null)
{
UInt32 sense_mask = Misc.MyBase.BIT(FIX_OBJ_INTERFACE.PUSH_TIMEGRID);
......@@ -87,11 +87,10 @@ namespace FLY.Thick.Base.Client
{
case FIX_OBJ_INTERFACE.PUSH_TIMEGRID:
{
TimeGridEventArgs p = new TimeGridEventArgs();
if (!p.TryParse(infodata))
return;
if (TimeGridEvent != null)
TimeGridEvent(this, p);
string json = Misc.Converter.BytesToString(infodata);
var p = Newtonsoft.Json.JsonConvert.DeserializeObject<FixEventArgs>(json);
FixEvent?.Invoke(this, p);
} break;
}
......
......@@ -5,17 +5,42 @@ using System.Text;
namespace FLY.Thick.Base.IService
{
/// <summary>
/// 定点测量服务
/// </summary>
public interface IFixService
{
/// <summary>
/// 注册timegrid 事件
/// </summary>
/// <param name="handler"></param>
void RegistTimeGridEvent(TimeGridEventHandler handler);
void RegistTimeGridEvent(FixEventHandler handler);
/// <summary>
/// 关闭注册timegrid 事件
/// </summary>
/// <param name="handler"></param>
void UnRegistTimeGridEvent(TimeGridEventHandler handler);
void UnRegistTimeGridEvent(FixEventHandler handler);
}
public delegate void FixEventHandler(object sender, FixEventArgs e);
public class FixEventArgs : EventArgs
{
/// <summary>
/// 数据, AD数据!!!!!
/// </summary>
public int[] ADs;
/// <summary>
/// 数据, 厚度数据!!!!!
/// </summary>
public double[] thicks;
/// <summary>
/// 单数据时间间隔
/// </summary>
public TimeSpan ts;
/// <summary>
/// 开始时间点
/// </summary>
public DateTime time;
}
}
......@@ -23,13 +23,14 @@ namespace FLY.Thick.Base.Server.OBJProxy
{
ID = id;
mFix = fix;
mFix.RegistTimeGridEvent(new TimeGridEventHandler(GM_Fix_TimeGridEvent));
mFix.RegistTimeGridEvent(new FixEventHandler(GM_Fix_TimeGridEvent));
}
void GM_Fix_TimeGridEvent(object sender, TimeGridEventArgs e)
void GM_Fix_TimeGridEvent(object sender, FixEventArgs e)
{
CurrObjSys.PushObjInfoEx(
string json = Newtonsoft.Json.JsonConvert.SerializeObject(e);
CurrObjSys.PushObjInfoEx(
this, FIX_OBJ_INTERFACE.PUSH_TIMEGRID,
e.ToBytes());
Misc.Converter.StringToBytes(json));
}
#region FObj 重载
......
......@@ -8,7 +8,7 @@ using FLY.Thick.BulkDataModule;
using FLY.Thick.Base.Common;
using FLY.Thick.Base.IService;
using Misc;
namespace FLY.Thick.Base.Server
{
......@@ -19,18 +19,9 @@ namespace FLY.Thick.Base.Server
{
get { return CTRL_STATE.FIX; }
}
private bool isrunning = false;
public bool IsRunning
{
get { return isrunning; }
protected set {
if (isrunning != value)
{
isrunning = value;
NotifyPropertyChanged("IsRunning");
}
}
}
public bool IsRunning { get; protected set; }
#endregion
protected FlyADBase.FlyAD7 mFlyAD;
protected DynArea mDynArea;
......@@ -49,35 +40,67 @@ namespace FLY.Thick.Base.Server
AD2Thick = func_ad2thick;
}
/// <summary>
/// 1s 的AD值
/// 1s 的AD值,就只是用来显示到主界面左上面角而已 DynArea.AD
/// </summary>
List<int> Data1s = new List<int>();
void flyad_TimeGridEvent(object sender, FlyADBase.TimeGridEventArgs e)
{
if (!IsRunning)
return;
DateTime dt = e.Time;
TimeSpan ts = e.Ts;
int[] data2 = e.Data;
int[] data = (int[])data2.Clone();
List<int> data = new List<int>(e.Data);
//1秒数据
Data1s.AddRange(data);
if ((Data1s.Count * ts.Ticks) / TimeSpan.TicksPerSecond >= 1)
if (TimeSpan.FromTicks(Data1s.Count * ts.Ticks) >= TimeSpan.FromSeconds(1))
{
int ad = Misc.MyMath.Avg(Data1s.ToArray());
int ad = (int)Data1s.Average();
Data1s.Clear();
mDynArea.AD = ad;
mDynArea.Thick = AD2Thick(ad);
}
//转换为thick
for (int i = 0; i < data.Length; i++)
data[i] = AD2Thick(data[i]);
if (TimeGridEvent != null)
TimeGridEvent(this, new TimeGridEventArgs() { time = e.Time, ts = e.Ts, data = data });
List<double> thicks = new List<double>();
foreach(int ad in data)
{
double thick;
int t = AD2Thick(ad);
if (Misc.MyBase.ISVALIDATA(t))
thick = t / 100.0;
else
thick = double.NaN;
thicks.Add(thick);
}
//需要限制大小,push 不能太大
//分拆为多个包
int size = 200;
while (data.Count()>0)
{
int cnt = (data.Count() > size) ? size : data.Count();
var ADs2 = data.Take(cnt);
var thicks2 = thicks.Take(cnt);
data.RemoveRange(0, cnt);
thicks.RemoveRange(0, cnt);
FixEvent?.Invoke(this,
new FixEventArgs()
{
time = dt,
ts = ts,
ADs = ADs2.ToArray(),
thicks = thicks2.ToArray()
});
dt += TimeSpan.FromTicks(cnt * ts.Ticks);
}
}
#region IGageMode
......@@ -95,26 +118,26 @@ namespace FLY.Thick.Base.Server
#endregion
protected void NotifyPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
event TimeGridEventHandler TimeGridEvent;
public void RegistTimeGridEvent(TimeGridEventHandler handler)
event FixEventHandler FixEvent;
/// <summary>
/// 注册定点数据事件 FixEvent += handler;
/// </summary>
/// <param name="handler"></param>
public void RegistTimeGridEvent(FixEventHandler handler)
{
TimeGridEvent += handler;
FixEvent += handler;
}
public void UnRegistTimeGridEvent(TimeGridEventHandler handler)
/// <summary>
/// 取消注册定点数据事件 FixEvent -= handler;
/// </summary>
/// <param name="handler"></param>
public void UnRegistTimeGridEvent(FixEventHandler handler)
{
TimeGridEvent -= handler;
FixEvent -= handler;
}
}
}
......@@ -47,22 +47,8 @@ namespace FLY.Thick.Base.Server
/// </summary>
public class GageModeManager:INotifyPropertyChanged
{
CTRL_STATE state = CTRL_STATE.FIX;
public CTRL_STATE State
{
get
{
return state;
}
set
{
if (state != value)
{
state = value;
NotifyPropertyChanged("State");
}
}
}
public CTRL_STATE State { get; set; } = CTRL_STATE.FIX;
/// <summary>
/// 第1个GM,就是默认值
......@@ -118,13 +104,6 @@ namespace FLY.Thick.Base.Server
}
}
protected void NotifyPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
public event PropertyChangedEventHandler PropertyChanged;
}
}
......@@ -123,12 +123,18 @@ namespace FLY.UI.Module
if (type == null)
continue;
string module_name = mp.assembly_name + "." + mp.class_name;
var uimodule = Activator.CreateInstance(type) as IUIModule;
if (uimodule == null)
{
//加载失败
continue;
}
UIModules.Add(
module_name,
new UIModuleInfo()
{
Param = mp,
UIModule = Activator.CreateInstance(type) as IUIModule
UIModule = uimodule
});
group.ModuleNames.Add(module_name);
......
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