Commit 181ce960 authored by 潘栩锋's avatar 潘栩锋 🚴

添加 用于 IBC的3个测量头记录 的程序,更新频率是 0.2s

parent c9512ad6
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>
\ No newline at end of file
<Application x:Class="IbcDebugApp.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:IbcDebugApp"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace IbcDebugApp
{
/// <summary>
/// App.xaml 的交互逻辑
/// </summary>
public partial class App : Application
{
FLY.AppHelper.AppJustOne appjustone;
NLog.Logger log = NLog.LogManager.GetCurrentClassLogger();
public App()
{
appjustone = new FLY.AppHelper.AppJustOne(this);
AppDomain.CurrentDomain.UnhandledException += (s, e) =>
{
log.Error((Exception)e.ExceptionObject, "AppDomain.CurrentDomain.UnhandledException");
string err = e.ExceptionObject.ToString();
MessageBox.Show("程序出现异常,请把下面信息拍照发给厂家" + Environment.NewLine + err,
"异常,联系厂家",
MessageBoxButton.OK, MessageBoxImage.Error);
};
}
}
}
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<PropertyChanged />
<Costura />
</Weavers>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. -->
<xs:element name="Weavers">
<xs:complexType>
<xs:all>
<xs:element name="PropertyChanged" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:attribute name="InjectOnPropertyNameChanged" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if the On_PropertyName_Changed feature is enabled.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="TriggerDependentProperties" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if the Dependent properties feature is enabled.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="EnableIsChangedProperty" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if the IsChanged property feature is enabled.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="EventInvokerNames" type="xs:string">
<xs:annotation>
<xs:documentation>Used to change the name of the method that fires the notify event. This is a string that accepts multiple values in a comma separated form.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="CheckForEquality" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if equality checks should be inserted. If false, equality checking will be disabled for the project.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="CheckForEqualityUsingBaseEquals" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if equality checks should use the Equals method resolved from the base class.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="UseStaticEqualsFromBase" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if equality checks should use the static Equals method resolved from the base class.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="SuppressWarnings" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to turn off build warnings from this weaver.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="SuppressOnPropertyNameChangedWarning" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to turn off build warnings about mismatched On_PropertyName_Changed methods.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="Costura" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:all>
<xs:element minOccurs="0" maxOccurs="1" name="ExcludeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="IncludeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="Unmanaged32Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged 32 bit assembly names to include, delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="Unmanaged64Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged 64 bit assembly names to include, delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="PreloadOrder" type="xs:string">
<xs:annotation>
<xs:documentation>The order of preloaded assemblies, delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
</xs:all>
<xs:attribute name="CreateTemporaryAssemblies" type="xs:boolean">
<xs:annotation>
<xs:documentation>This will copy embedded files to disk before loading them into memory. This is helpful for some scenarios that expected an assembly to be loaded from a physical file.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="IncludeDebugSymbols" type="xs:boolean">
<xs:annotation>
<xs:documentation>Controls if .pdbs for reference assemblies are also embedded.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="DisableCompression" type="xs:boolean">
<xs:annotation>
<xs:documentation>Embedded assemblies are compressed by default, and uncompressed when they are loaded. You can turn compression off with this option.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="DisableCleanup" type="xs:boolean">
<xs:annotation>
<xs:documentation>As part of Costura, embedded assemblies are no longer included as part of the build. This cleanup can be turned off.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="LoadAtModuleInit" type="xs:boolean">
<xs:annotation>
<xs:documentation>Costura by default will load as part of the module initialization. This flag disables that behavior. Make sure you call CosturaUtility.Initialize() somewhere in your code.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="IgnoreSatelliteAssemblies" type="xs:boolean">
<xs:annotation>
<xs:documentation>Costura will by default use assemblies with a name like 'resources.dll' as a satellite resource and prepend the output path. This flag disables that behavior.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="ExcludeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with |</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="IncludeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of assembly names to include from the default action of "embed all Copy Local references", delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="Unmanaged32Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged 32 bit assembly names to include, delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="Unmanaged64Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged 64 bit assembly names to include, delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="PreloadOrder" type="xs:string">
<xs:annotation>
<xs:documentation>The order of preloaded assemblies, delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:all>
<xs:attribute name="VerifyAssembly" type="xs:boolean">
<xs:annotation>
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="VerifyIgnoreCodes" type="xs:string">
<xs:annotation>
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="GenerateXsd" type="xs:boolean">
<xs:annotation>
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{C254A1B9-4CB4-4482-ADF2-D4C08BEEBC18}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>IbcDebugApp</RootNamespace>
<AssemblyName>IbcDebugApp</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>图片2.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
</Compile>
<Compile Include="PgLoading.xaml.cs">
<DependentUpon>PgLoading.xaml</DependentUpon>
</Compile>
<Compile Include="PgMain.xaml.cs">
<DependentUpon>PgMain.xaml</DependentUpon>
</Compile>
<Compile Include="WdDRList.xaml.cs">
<DependentUpon>WdDRList.xaml</DependentUpon>
</Compile>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="SaveDataSystem.cs" />
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="PgLoading.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="PgMain.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="WdDRList.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Costura.Fody">
<Version>4.1.0</Version>
</PackageReference>
<PackageReference Include="Newtonsoft.Json">
<Version>12.0.3</Version>
</PackageReference>
<PackageReference Include="NLog">
<Version>4.6.8</Version>
</PackageReference>
<PackageReference Include="PropertyChanged.Fody">
<Version>3.3.1</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\thick_public\Project.FLY.AppHelper\FLY.AppHelper\FLY.AppHelper.csproj">
<Project>{9c46d98f-6500-490b-9e56-c89dfffa05f8}</Project>
<Name>FLY.AppHelper</Name>
</ProjectReference>
<ProjectReference Include="..\thick_public\Project.FLY.FObjSys\FObjSys\FObjBase.csproj">
<Project>{abfe87d4-b692-4ae9-a8c0-1f470b8acbb8}</Project>
<Name>FObjBase</Name>
</ProjectReference>
<ProjectReference Include="..\thick_public\Project.FLY.Misc\MISC\Misc.csproj">
<Project>{5ee61ac6-5269-4f0f-b8fa-4334fe4a678f}</Project>
<Name>Misc</Name>
</ProjectReference>
<ProjectReference Include="..\thick_public\Project.FLY.ModbusMapper\FLY.ModbusMapper\FLY.ModbusMapper.csproj">
<Project>{6d4b9bda-2a66-4583-b244-758bc4213d9f}</Project>
<Name>FLY.ModbusMapper</Name>
</ProjectReference>
<ProjectReference Include="..\thick_public\Project.FLY.OBJComponents\OBJComponents\FLY.OBJComponents.csproj">
<Project>{A539505D-9AC0-426B-A9A0-197DF50598B0}</Project>
<Name>FLY.OBJComponents</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Resource Include="图片2.ico" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
<NavigationWindow x:Class="IbcDebugApp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
ResizeMode="CanMinimize"
Title="MainWindow" SizeToContent="WidthAndHeight" MinWidth="400" MinHeight="200"
ShowsNavigationUI="False"
Loaded="NavigationWindow_Loaded">
</NavigationWindow>
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Navigation;
namespace IbcDebugApp
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : NavigationWindow
{
FLY.AppHelper.WindowNotifyIconHelper notifyiconhelper;
SaveDataSystem iBCSystem;
public MainWindow()
{
InitializeComponent();
PgLoading p = new PgLoading();
this.Navigate(p);
this.Title = (new Misc.Ver() { SrcType = typeof(MainWindow) }).ToString();
notifyiconhelper = new FLY.AppHelper.WindowNotifyIconHelper(this, this.Title);
}
private async void NavigationWindow_Loaded(object sender, RoutedEventArgs _e)
{
iBCSystem = new SaveDataSystem();
await Task.Delay(1000);
iBCSystem.Init();
FObjBase.PollModule.Current.Start();
this.Hide();
PgMain p = new PgMain();
p.Init(iBCSystem, iBCSystem.plcos);
this.Navigate(p);
this.NavigationService.RemoveBackEntry();
}
}
}
<Page x:Class="IbcDebugApp.PgLoading"
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"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
Title="PgLoading" >
<Grid>
<TextBlock x:Name="message" VerticalAlignment="Center" HorizontalAlignment="Center" Text="初始化中......" FontSize="24"/>
</Grid>
</Page>
\ No newline at end of file
using System;
using System.Windows.Controls;
using System.Windows.Threading;
namespace IbcDebugApp
{
/// <summary>
/// PgLoading.xaml 的交互逻辑
/// </summary>
public partial class PgLoading : Page
{
DispatcherTimer timer;
public PgLoading()
{
InitializeComponent();
timer = new DispatcherTimer();
timer.Interval = TimeSpan.FromSeconds(1);
timer.Tick += Timer_Tick;
timer.Start();
Timer_Tick(null, null);
}
int cnt = 0;
private void Timer_Tick(object sender, EventArgs e)
{
string str = "";
for (int i = 0; i < cnt; i++)
{
str += ".";
}
message.Text = "初始化中" + str;
cnt++;
if (cnt > 6)
cnt = 0;
}
}
}
<Page x:Class="IbcDebugApp.PgMain"
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:IbcDebugApp"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
Title="PgMain">
<Page.Resources>
<local:TimeSpan2msConverter x:Key="timespan2msConv"/>
<local:PgMainVmUt x:Key="viewModel"/>
</Page.Resources>
<Grid d:DataContext="{StaticResource viewModel}">
<StackPanel>
<StackPanel Orientation="Horizontal" Margin="5" x:Name="spDataSystem">
<TextBlock Margin="5" >
当前缓冲数据量:<Run Text="{Binding DataCnt,Mode=OneWay}"/>
</TextBlock>
<Button Margin="5" Padding="20,5" Content="立刻导出" Click="btnOutputClick"/>
</StackPanel>
<ItemsControl x:Name="itemcontrol" ItemsSource="{Binding PLCs}" Margin="5">
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel>
<StackPanel Orientation="Horizontal" >
<StackPanel Margin="4" >
<TextBlock Text="更新速度" />
<TextBlock FontSize="20">
<Run Text="{Binding ActUpdateInterval,Converter={StaticResource timespan2msConv}, Mode=OneWay}" />
<Run Text="ms" FontSize="15"/>
</TextBlock>
</StackPanel>
<StackPanel Margin="4" >
<TextBlock Text="{Binding Client.RemoteAddr,Mode=OneWay}" />
<TextBlock >
连接状态[<Run Text="{Binding Client.IsConnected,Mode=OneWay}" FontSize="20"/>]
</TextBlock>
</StackPanel>
<StackPanel Margin="4" >
<TextBlock Text="异常次数" />
<TextBlock Text="{Binding ErrorCnt}" FontSize="20"/>
</StackPanel>
<StackPanel Margin="4" >
<TextBlock Text="寄存器更新数" />
<StackPanel Orientation="Horizontal">
<TextBlock FontSize="20">
<Run Text="{Binding DRNeedUpdateCnt,Mode=OneWay}"/>/<Run Text="{Binding DRCnt,Mode=OneWay}"/>
</TextBlock>
</StackPanel>
</StackPanel>
<Button Margin="4" Content="..." Height="40" Width="40" Tag="{Binding .}" Click="btnMoreClick"/>
</StackPanel>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
</Grid>
</Page>
using FLY.OBJComponents.Server;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
namespace IbcDebugApp
{
/// <summary>
/// PgMain.xaml 的交互逻辑
/// </summary>
public partial class PgMain : Page
{
SaveDataSystem saveDataSystem;
public PgMain()
{
InitializeComponent();
}
public void Init(SaveDataSystem saveDataSystem, PLCProxySystem plcos)
{
this.saveDataSystem = saveDataSystem;
this.spDataSystem.DataContext = saveDataSystem;
this.itemcontrol.ItemsSource = plcos.PLCs;
}
private void btnMoreClick(object sender, RoutedEventArgs e)
{
Button button = sender as Button;
var plc = button.Tag as FLY.Modbus.WithThread.ModbusMapper_Client;
WdDRList w = new WdDRList();
w.Init(plc);
w.ShowDialog();
}
private void btnOutputClick(object sender, RoutedEventArgs e)
{
saveDataSystem.Output();
MessageBox.Show("已经导出");
}
}
public class PgMainVmUt : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public List<ModbusMapperClientView> PLCs { get; set; }
public PgMainVmUt()
{
PLCs = new List<ModbusMapperClientView>() {
new ModbusMapperClientView(){
ActUpdateInterval = TimeSpan.FromMilliseconds( 623),
Client = new TcpClientView(){
IsConnected = true,
RemoteAddr = "127.168.50.1:502"
},
DRCnt = 130,
DRNeedUpdateCnt = 30,
ErrorCnt = 2
},
new ModbusMapperClientView(){
ActUpdateInterval = TimeSpan.FromMilliseconds(2623),
Client = new TcpClientView(){
IsConnected = false,
RemoteAddr = "127.168.50.2:502"
},
DRCnt = 45,
DRNeedUpdateCnt = 40,
ErrorCnt = 2
},
new ModbusMapperClientView(){
ActUpdateInterval = TimeSpan.FromMilliseconds(123),
Client = new TcpClientView(){
IsConnected = true,
RemoteAddr = "127.168.50.3:502"
},
DRCnt = 10,
DRNeedUpdateCnt = 3,
ErrorCnt = 0
}
};
}
}
public class ModbusMapperClientView : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
/// <summary>
/// 实际更新间隔
/// </summary>
public TimeSpan ActUpdateInterval { get; set; }
public int ErrorCnt { get; set; }
public int DRNeedUpdateCnt { get; set; }
public int DRCnt { get; set; }
public TcpClientView Client { get; set; }
}
public class TcpClientView : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public string RemoteAddr { get; set; }
public bool IsConnected { get; set; }
}
public class TimeSpan2msConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (!(value is TimeSpan))
return null;
return (int)(((TimeSpan)value).TotalMilliseconds);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("ModbusTCP数据记录器")]
[assembly: AssemblyDescription("ModbusTCP数据记录器")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ModbusTCP数据记录器")]
[assembly: AssemblyCopyright("Copyright © 2023 flyautomation")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
//若要开始生成可本地化的应用程序,请设置
//.csproj 文件中的 <UICulture>CultureYouAreCodingWith</UICulture>
//例如,如果您在源文件中使用的是美国英语,
//使用的是美国英语,请将 <UICulture> 设置为 en-US。 然后取消
//对以下 NeutralResourceLanguage 特性的注释。 更新
//以下行中的“en-US”以匹配项目文件中的 UICulture 设置。
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //主题特定资源词典所处位置
//(未在页面中找到资源时使用,
//或应用程序资源字典中找到时使用)
ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置
//(未在页面中找到资源时使用,
//、应用程序或任何主题专用资源字典中找到时使用)
)]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本: 4.0.30319.42000
//
// 对此文件的更改可能导致不正确的行为,如果
// 重新生成代码,则所做更改将丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace IbcDebugApp.Properties
{
/// <summary>
/// 强类型资源类,用于查找本地化字符串等。
/// </summary>
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或删除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// 返回此类使用的缓存 ResourceManager 实例。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("IbcDebugApp.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// 重写当前线程的 CurrentUICulture 属性,对
/// 使用此强类型资源类的所有资源查找执行重写。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace IbcDebugApp.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>
\ No newline at end of file
using FLY.Modbus;
using FLY.OBJComponents.IService;
using FLY.OBJComponents.Server;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
namespace IbcDebugApp
{
public class SaveDataSystem:INotifyPropertyChanged
{
public PLCProxySystem plcos = new PLCProxySystem();
PLCGroup plcgroup;
/// <summary>
/// 数据保存周期 单位ms
/// </summary>
public int SaveInterval { get; set; } = 200;
public int DataCnt { get; private set; }
/// <summary>
/// 每1min写入一次文件
/// </summary>
List<Lc_SaveData> lc_SaveDatas = new List<Lc_SaveData>();
public SaveDataSystem()
{
if (!Load()) {
Save();
}
//--------------------------------------------------------------------------------
//step 1 加载PLC寄存器 文件
AddConfigFile();
}
public void Init()
{
//--------------------------------------------------------------------------------
//last step PLC 更新计划服务初始化
plcos.Init();
plcos.SetPlanAll(0);
FObjBase.PollModule.Current.Poll_Config(FObjBase.PollModule.POLL_CONFIG.ADD,
OnPoll_save, TimeSpan.FromMilliseconds(SaveInterval));
FObjBase.PollModule.Current.Poll_Config(FObjBase.PollModule.POLL_CONFIG.ADD,
OnPoll_output, TimeSpan.FromSeconds(60));
}
void OnPoll_save()
{
if (!plcos.IsConnectedWithPLC)
return;
Lc_SaveData saveData = new Lc_SaveData();
saveData.time = DateTime.Now;
for (int i = 0; i < plcos.DRMap.Count(); i++)
{
var dr = plcos.DRMap[i];
saveData.dataCells.Add(dr.value);
}
lc_SaveDatas.Add(saveData);
DataCnt++;
}
void OnPoll_output()
{
//写入文件
if (lc_SaveDatas.Count() == 0)
return;
//数据保存到根目录的 data 下
if (!Directory.Exists("data"))
{
Directory.CreateDirectory("data");
}
string fileName = $"{DateTime.Now.Year:0000}-{DateTime.Now.Month:00}-{DateTime.Now.Day:00}.csv";
string filePath = "data/" + fileName;
//追加
try
{
if (!File.Exists(filePath))
{
//需要写标题
using (StreamWriter streamWriter = new StreamWriter(filePath, false))
{
output(streamWriter, true);
}
}
else
{
using (StreamWriter streamWriter = new StreamWriter(filePath, true))
{
output(streamWriter, false);
}
}
lc_SaveDatas.Clear();
DataCnt = 0;
}
catch
{
//打开出错,下次吧
return;
}
}
void output(StreamWriter streamWriter, bool hasHeader)
{
if (hasHeader) {
streamWriter.WriteLine(getHeader());
}
for (int i = 0; i < lc_SaveDatas.Count(); i++)
{
string line = "";
var data = lc_SaveDatas[i];
line = data.time.ToString("yyyy/MM/dd HH:mm:ss.ff");
for (int j = 0; j < data.dataCells.Count(); j++)
{
var value = data.dataCells[j];
if (line != "")
{
line += ",";
}
line += $"{value}";
}
streamWriter.WriteLine(line);
}
streamWriter.Flush();
}
string getHeader()
{
string header = "Time";
for (int i = 0; i < plcos.DRMap.Count(); i++)
{
var dr = plcos.DRMap[i];
if (header != "") {
header += ",";
}
header += $"{dr.ownerName}.{dr.propertyName}";
}
return header;
}
void AddConfigFile()
{
plcos.AddConfigFile("plcgroup.json", (plcgroup) =>
{
this.plcgroup = plcgroup;
return new Dictionary<string, INotifyPropertyChanged>();
});
}
public void Output()
{
OnPoll_output();
}
private string filePath = "saveDataSystem.json";
public event PropertyChangedEventHandler PropertyChanged;
public bool Save()
{
return SaveDataSystemJsonDb.Save(this, filePath);
}
public bool Load()
{
return SaveDataSystemJsonDb.Load(this, filePath);
}
}
public class Lc_SaveData
{
public DateTime time;
public List<object> dataCells = new List<object>();
}
public class SaveDataSystemJsonDb
{
public static bool Load(SaveDataSystem src, string filePath)
{
try
{
if (!File.Exists(filePath))
return false;
string json = File.ReadAllText(filePath);
var jsonDb = Newtonsoft.Json.JsonConvert.DeserializeObject<SaveDataSystemJsonDb>(json);
src.SaveInterval = jsonDb.SaveInterval;
return true;
}
catch
{
return false;
}
}
public static bool Save(SaveDataSystem src, string filePath)
{
try
{
var jsonDb = new SaveDataSystemJsonDb()
{
SaveInterval = src.SaveInterval
};
string json = Newtonsoft.Json.JsonConvert.SerializeObject(jsonDb);
File.WriteAllText(filePath, json);
return true;
}
catch {
return false;
}
}
/// <summary>
/// 数据保存周期 单位ms
/// </summary>
public int SaveInterval { get; set; } = 200;
}
}
<Window x:Class="IbcDebugApp.WdDRList"
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:IbcDebugApp"
mc:Ignorable="d"
Title="DRList" Height="450" Width="800">
<Window.Resources>
<Style TargetType="DataGridCell" x:Key="gridCellStyle">
<!--文字居中-->
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridCell}">
<Grid Background="{TemplateBinding Background}">
<ContentPresenter HorizontalAlignment="Center" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
<!--被选中时,背景色改变-->
<Style.Triggers>
<Trigger Property="DataGridCell.IsSelected" Value="True">
<Setter Property="Background" Value="Gray" />
</Trigger>
</Style.Triggers>
</Style>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal">
<TextBox Text="{Binding SearchText}" MinWidth="200" Margin="2"/>
<Button Content="向下搜索" Padding="20,5" Margin="2" Click="btnSearchDownClick"/>
<Button Content="向上搜索" Padding="20,5" Margin="2" Click="btnSearchUpClick"/>
<TextBlock>
当前查找结果序号=<Run Text="{Binding SearchIndex,Mode=OneWay}"/>
</TextBlock>
</StackPanel>
<DataGrid Grid.Row="1" x:Name="dataGrid" AutoGenerateColumns="True" IsReadOnly="True"
AlternationCount ="5" AlternatingRowBackground="LightGray"
CellStyle="{StaticResource gridCellStyle}" CanUserSortColumns="False"/>
</Grid>
</Window>
using FLY.Modbus;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
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 IbcDebugApp
{
/// <summary>
/// DRList.xaml 的交互逻辑
/// </summary>
public partial class WdDRList : Window, INotifyPropertyChanged
{
ObservableCollection<DataToRegsView> dataToRegsViews = new ObservableCollection<DataToRegsView>();
FLY.Modbus.WithThread.ModbusMapper_Client plc;
public event PropertyChangedEventHandler PropertyChanged;
public WdDRList()
{
InitializeComponent();
}
public void Init(FLY.Modbus.WithThread.ModbusMapper_Client plc)
{
this.plc = plc;
for (int i = 0; i < plc.DRmap.Count(); i++)
{
var dr = plc.DRmap[i];
//获取描述
string description = "";
if (dr.owner != null)
{
var type = dr.owner.GetType();
var propertyInfo = type.GetProperty(dr.propertyName);
var attributes = propertyInfo.GetCustomAttributes(typeof(DescriptionAttribute), false);
if (attributes.Length > 0)
{
description = (attributes.First() as DescriptionAttribute).Description;
}
}
dataToRegsViews.Add(new DataToRegsView()
{
Index = i,
dr = dr,
Addr = dr.addr,
RegAddr = dr.regAddr,
DataArea = dr.dataArea,
OwnerName = dr.ownerName,
IsNeedUpdate = dr.isNeedUpdate,
PropertyName = dr.propertyName,
Description = description,
Value = dr.value
}); ;
}
plc.PropertyChanged += Plc_PropertyChanged;
plc.NameDataChanged += Plc_NameDataChanged;
dataGrid.ItemsSource = dataToRegsViews;
this.DataContext = this;
}
private void Plc_NameDataChanged(object sender, DataToRegs dr)
{
var drViews = from _drView in dataToRegsViews
where _drView.dr == dr
select _drView;
if (drViews.Count() == 0)
return;
var drView = drViews.First();
drView.Value = dr.value;
}
private void Plc_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(plc.PlanUpdateTime))
{
for (int i = 0; i < plc.DRmap.Count(); i++)
{
var dr = plc.DRmap[i];
dataToRegsViews[i].IsNeedUpdate = dr.isNeedUpdate;
}
}
}
public int SearchIndex { get; private set; } = -1;
public string SearchText { get; set; }
private void btnSearchDownClick(object sender, RoutedEventArgs e)
{
if (string.IsNullOrEmpty(SearchText))
{
MessageBox.Show("输入为空", "异常", MessageBoxButton.OK, MessageBoxImage.Hand);
return;
}
int newSearchIndex = -1;
for (int i = SearchIndex + 1; i < dataToRegsViews.Count(); i++)
{
if (dataToRegsViews[i].OwnerName.Contains(SearchText))
{
//找到了
newSearchIndex = i;
break;
}
if (dataToRegsViews[i].PropertyName.Contains(SearchText))
{
//找到了
newSearchIndex = i;
break;
}
if (dataToRegsViews[i].Description.Contains(SearchText))
{
//找到了
newSearchIndex = i;
break;
}
if (dataToRegsViews[i].RegAddr.Contains(SearchText))
{
//找到了
newSearchIndex = i;
break;
}
}
if (newSearchIndex != -1)
{
SearchIndex = newSearchIndex;
dataGrid.SelectedItem = dataToRegsViews[newSearchIndex];
dataGrid.ScrollIntoView(dataGrid.SelectedItem);
return;
}
else
{
SearchIndex = -1;
MessageBox.Show("不能找到更多", "异常", MessageBoxButton.OK, MessageBoxImage.Hand);
return;
}
}
private void btnSearchUpClick(object sender, RoutedEventArgs e)
{
if (string.IsNullOrEmpty(SearchText))
{
MessageBox.Show("输入为空", "异常", MessageBoxButton.OK, MessageBoxImage.Hand);
return;
}
int newSearchIndex = -1;
for (int i = SearchIndex - 1; i >= 0 && i < dataToRegsViews.Count(); i--)
{
if (dataToRegsViews[i].OwnerName.Contains(SearchText))
{
//找到了
newSearchIndex = i;
break;
}
if (dataToRegsViews[i].PropertyName.Contains(SearchText))
{
//找到了
newSearchIndex = i;
break;
}
if (dataToRegsViews[i].Description.Contains(SearchText))
{
//找到了
newSearchIndex = i;
break;
}
if (dataToRegsViews[i].RegAddr.Contains(SearchText))
{
//找到了
newSearchIndex = i;
break;
}
}
if (newSearchIndex != -1)
{
SearchIndex = newSearchIndex;
dataGrid.SelectedItem = dataToRegsViews[newSearchIndex];
return;
}
else
{
SearchIndex = -1;
MessageBox.Show("不能找到更多", "异常", MessageBoxButton.OK, MessageBoxImage.Hand);
return;
}
}
}
/// <summary>
/// 数据映射的类;
/// Data: PC 属性
/// Regs: PLC 对象(寄存器、线圈)
/// </summary>
public class DataToRegsView : INotifyPropertyChanged
{
public int Index { get; set; }
public DataToRegs dr;
/// <summary>
/// 对应 PLC寄存器区 coil or register
/// </summary>
public PLCAddressArea DataArea { get; set; }
/// <summary>
/// PLC寄存器 首地址
/// </summary>
public int Addr { get; set; }
/// <summary>
/// 寄存器 原始地址字符串
/// </summary>
public string RegAddr { get; set; }
public string OwnerName { get; set; }
/// <summary>
/// object 的 property 名称, 只能是 数字类型都是double, 剩下就是 bool
/// </summary>
public string PropertyName { get; set; }
/// <summary>
/// property 描述
/// </summary>
public string Description { get; set; }
/// <summary>
/// property 的值, 没有缩小. 只有 double 与 bool
/// </summary>
public object Value { get; set; }
/// <summary>
/// 需要从PLC读取数据更新
/// </summary>
public bool IsNeedUpdate { get; set; }
public event PropertyChangedEventHandler PropertyChanged;
/// <summary>
///
/// </summary>
/// <returns></returns>
public override string ToString()
{
return PropertyName + " [" + ((int)DataArea).ToString() + "](" + Addr + ")";
}
}
}
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