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

称重

1. 修改 V6 总流量组件 字体大小
2. 添加 膜宽<100mm 不写入 PLC
3. 添加 膜宽写入PLC 的绑定开关
4. 添加 WdDRList 中文注解
5. 修改 sysparam 保存为 param.json 文件
parent 3f202ac0
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<sys:Double x:Key="FontSize_title">18</sys:Double> <sys:Double x:Key="FontSize_title">18</sys:Double>
<sys:Double x:Key="FontSize_unit">18</sys:Double> <sys:Double x:Key="FontSize_unit">18</sys:Double>
<sys:Double x:Key="FontSize_text">48</sys:Double> <sys:Double x:Key="FontSize_text">48</sys:Double>
<sys:Double x:Key="FontSize_text_mid">36</sys:Double>
<Style x:Key="TextBlockStyle_title" TargetType="TextBlock"> <Style x:Key="TextBlockStyle_title" TargetType="TextBlock">
<Setter Property="FontSize" Value="{StaticResource FontSize_title}"/> <Setter Property="FontSize" Value="{StaticResource FontSize_title}"/>
<Setter Property="Foreground" Value="{StaticResource Color_title}"/> <Setter Property="Foreground" Value="{StaticResource Color_title}"/>
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:FLY.Weight.UI.Server" xmlns:local="clr-namespace:FLY.Weight.UI.Server"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignWidth="200" d:DesignWidth="450"
Title="PgMain"> Title="PgMain">
<Page.Resources> <Page.Resources>
<local:PgMainVmUt x:Key="viewModel"/> <local:PgMainVmUt x:Key="viewModel"/>
...@@ -15,12 +15,23 @@ ...@@ -15,12 +15,23 @@
<Grid x:Name="grid_plcos"/> <Grid x:Name="grid_plcos"/>
<Grid x:Name="grid_WeightSystem"/> <Grid x:Name="grid_WeightSystem"/>
<StackPanel Margin="5"> <StackPanel Margin="5">
<StackPanel Margin="5" DataContext="{Binding ElementName=grid_WeightSystem,Path=DataContext}"> <Grid>
<TextBlock Text="当前线速度设置m/min" /> <Grid.ColumnDefinitions>
<TextBlock FontSize="20"> <ColumnDefinition Width="auto"/>
<Run Text="{Binding Accessory.CurrentVelocitySet,StringFormat={}{0:F1}, Mode=OneWay}" /> <ColumnDefinition/>
</TextBlock> </Grid.ColumnDefinitions>
</StackPanel> <StackPanel Margin="5" DataContext="{Binding ElementName=grid_WeightSystem,Path=DataContext}">
<TextBlock Text="当前线速度设置m/min" />
<TextBlock FontSize="20">
<Run Text="{Binding Accessory.CurrentVelocitySet,StringFormat={}{0:F1}, Mode=OneWay}" />
</TextBlock>
</StackPanel>
<StackPanel x:Name="sp_sysParam" Orientation="Horizontal" Grid.Column="1" Margin="5">
<CheckBox Content="吹膜宽度mm 绑定 测厚仪"
IsChecked="{Binding BindingTotalFilmWidth}"/>
</StackPanel>
</Grid>
<ItemsControl x:Name="itemcontrol" ItemsSource="{Binding PLCs}"> <ItemsControl x:Name="itemcontrol" ItemsSource="{Binding PLCs}">
<ItemsControl.ItemTemplate> <ItemsControl.ItemTemplate>
<DataTemplate> <DataTemplate>
......
...@@ -35,7 +35,7 @@ namespace FLY.Weight.UI.Server ...@@ -35,7 +35,7 @@ namespace FLY.Weight.UI.Server
//grid_plc.DataContext = plsos.PLCs[0]; //grid_plc.DataContext = plsos.PLCs[0];
grid_WeightSystem.DataContext = gage.mData; grid_WeightSystem.DataContext = gage.mData;
this.itemcontrol.ItemsSource = plsos.PLCs; this.itemcontrol.ItemsSource = plsos.PLCs;
sp_sysParam.DataContext = gage.mSysParam;
} }
private void btnSetupClick(object sender, RoutedEventArgs e) private void btnSetupClick(object sender, RoutedEventArgs e)
......
...@@ -51,6 +51,6 @@ using System.Windows; ...@@ -51,6 +51,6 @@ using System.Windows;
// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值, // 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值,
// 方法是按如下所示使用“*”: // 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("7.0.0.0")] [assembly: AssemblyVersion("7.0.1.0")]
[assembly: AssemblyFileVersion("7.0.0.0")] [assembly: AssemblyFileVersion("7.0.1.0")]
[assembly: Guid("AC4FFE57-FF42-4B4D-9E23-FF583D78187D")] [assembly: Guid("AC4FFE57-FF42-4B4D-9E23-FF583D78187D")]
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
mc:Ignorable="d" mc:Ignorable="d"
Title="DRList" Height="450" Width="800"> Title="DRList" Height="450" Width="800">
<Grid> <Grid>
<DataGrid x:Name="dataGrid" AutoGenerateColumns="True" IsReadOnly="True"/> <DataGrid x:Name="dataGrid" AutoGenerateColumns="True" IsReadOnly="True"/>
</Grid> </Grid>
</Window> </Window>
...@@ -28,21 +28,33 @@ namespace FLY.Weight.UI.Server ...@@ -28,21 +28,33 @@ namespace FLY.Weight.UI.Server
{ {
InitializeComponent(); InitializeComponent();
} }
public void Init(Modbus.WithThread.ModbusMapper_Client plc) public void Init(Modbus.WithThread.ModbusMapper_Client plc)
{ {
this.plc = plc; this.plc = plc;
//plsos.PLCs[0].mAreaManager[0].regs[0].isNeedUpdate
//plsos.PLCs[0].NameDataChanged for (int i = 0; i < plc.DRmap.Count(); i++)
for (int i = 0; i < plc.DRmap.Count(); i++)
{ {
var dr = plc.DRmap[i]; var dr = plc.DRmap[i];
//获取描述
var type = dr.owner.GetType();
var propertyInfo = type.GetProperty(dr.propertyName);
var attributes = propertyInfo.GetCustomAttributes(typeof(DescriptionAttribute), false);
string description = "";
if (attributes.Length > 0)
{
description = (attributes.First() as DescriptionAttribute).Description;
}
dataToRegsViews.Add(new DataToRegsView() dataToRegsViews.Add(new DataToRegsView()
{ {
dr = dr, dr = dr,
Addr = dr.addr, Addr = dr.addr,
DataArea = dr.dataArea, DataArea = dr.dataArea,
IsNeedUpdate = dr.isNeedUpdate, IsNeedUpdate = dr.isNeedUpdate,
PropertyName =dr.propertyName, PropertyName = dr.propertyName,
Description = description,
Value = dr.value Value = dr.value
}); });
} }
...@@ -67,7 +79,8 @@ namespace FLY.Weight.UI.Server ...@@ -67,7 +79,8 @@ namespace FLY.Weight.UI.Server
private void Plc_PropertyChanged(object sender, PropertyChangedEventArgs e) private void Plc_PropertyChanged(object sender, PropertyChangedEventArgs e)
{ {
if (e.PropertyName == nameof(plc.PlanUpdateTime)) { if (e.PropertyName == nameof(plc.PlanUpdateTime))
{
for (int i = 0; i < plc.DRmap.Count(); i++) for (int i = 0; i < plc.DRmap.Count(); i++)
{ {
var dr = plc.DRmap[i]; var dr = plc.DRmap[i];
...@@ -81,7 +94,7 @@ namespace FLY.Weight.UI.Server ...@@ -81,7 +94,7 @@ namespace FLY.Weight.UI.Server
/// Data: PC 属性 /// Data: PC 属性
/// Regs: PLC 对象(寄存器、线圈) /// Regs: PLC 对象(寄存器、线圈)
/// </summary> /// </summary>
public class DataToRegsView:INotifyPropertyChanged public class DataToRegsView : INotifyPropertyChanged
{ {
public DataToRegs dr; public DataToRegs dr;
/// <summary> /// <summary>
...@@ -99,6 +112,10 @@ namespace FLY.Weight.UI.Server ...@@ -99,6 +112,10 @@ namespace FLY.Weight.UI.Server
/// </summary> /// </summary>
public string PropertyName { get; set; } public string PropertyName { get; set; }
/// <summary>
/// property 描述
/// </summary>
public string Description { get; set; }
/// <summary> /// <summary>
/// property 的值, 没有缩小. 只有 double 与 bool /// property 的值, 没有缩小. 只有 double 与 bool
/// </summary> /// </summary>
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace FLY.Weight.Server namespace FLY.Weight.Server
{ {
public class SysParam : Misc.ISaveToXml public class SysParam : INotifyPropertyChanged
{ {
/// <summary> /// <summary>
/// OBJ服务端口 /// OBJ服务端口
...@@ -19,30 +21,45 @@ namespace FLY.Weight.Server ...@@ -19,30 +21,45 @@ namespace FLY.Weight.Server
public string BlowingAddr { get; set; } = "127.0.0.1:20006"; public string BlowingAddr { get; set; } = "127.0.0.1:20006";
/// <summary> /// <summary>
/// 数据库保持时间 默认6个月 /// 测厚仪宽度与 吹膜宽度mm 绑定在一起
/// </summary> /// </summary>
public int DBKeepMonth { get; set; } = 6; public bool BindingTotalFilmWidth { get; set; } = true;
public SysParam() public SysParam()
{ {
Load();
} }
public void Save()
public event PropertyChangedEventHandler PropertyChanged;
string filePath = "system.json";
public bool Save()
{ {
Misc.SaveToXmlHepler.Save("system.xml", this); try
{
string json = Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented);
File.WriteAllText(filePath, json);
return true;
}
catch {
return false;
}
} }
public void Load() public bool Load()
{ {
Misc.SaveToXmlHepler.Load("system.xml", this); if (!File.Exists(filePath))
return false;
try
{
string json = File.ReadAllText(filePath);
Newtonsoft.Json.JsonConvert.PopulateObject(json, this);
return true;
}
catch {
return false;
}
} }
public string[] GetSavePropertyNames()
{
return new string[]{
"OBJ_Port",
"BlowingAddr",
"DBKeepMonth"
};
}
} }
} }
...@@ -9,6 +9,7 @@ using System.Linq; ...@@ -9,6 +9,7 @@ using System.Linq;
using System.Net; using System.Net;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Threading;
namespace FLY.Weight.Server namespace FLY.Weight.Server
{ {
...@@ -53,6 +54,8 @@ namespace FLY.Weight.Server ...@@ -53,6 +54,8 @@ namespace FLY.Weight.Server
System.Environment.CurrentDirectory = mParamDirectory; System.Environment.CurrentDirectory = mParamDirectory;
mSysParam = new SysParam(); mSysParam = new SysParam();
if (!mSysParam.Load())
mSysParam.Save();
mData = new WeightSystem(); mData = new WeightSystem();
...@@ -99,12 +102,46 @@ namespace FLY.Weight.Server ...@@ -99,12 +102,46 @@ namespace FLY.Weight.Server
tDGageServiceClient.DynArea.PropertyChanged += DynArea_PropertyChanged; tDGageServiceClient.DynArea.PropertyChanged += DynArea_PropertyChanged;
this.mSysParam.PropertyChanged += MSysParam_PropertyChanged;
timer_saveSysParam = new DispatcherTimer();
timer_saveSysParam.Interval = TimeSpan.FromSeconds(5);
timer_saveSysParam.Tick += Timer_saveSysParam_Tick;
//这个是从测厚仪获取的,每几秒就写一次,不调试!!!!!
mData.plcos.IgnoreLogProperties.Add(new SenderProperty() { sender = mData.Accessory, propertyName = nameof(mData.Accessory.CurrentVelocitySet) });
mData.plcos.IgnoreLogProperties.Add(new SenderProperty() { sender = mData.Accessory, propertyName = nameof(mData.Accessory.TotalFilmWidth) });
}
private void Timer_saveSysParam_Tick(object sender, EventArgs e)
{
timer_saveSysParam.Stop();
mSysParam.Save();
}
DispatcherTimer timer_saveSysParam;
private void MSysParam_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(SysParam.BindingTotalFilmWidth)) {
//5秒后保存
timer_saveSysParam.Start();
}
} }
private void DynArea_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) private void DynArea_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{ {
if (e.PropertyName == nameof(Thick.Base.Common.DynArea.Width)) if (e.PropertyName == nameof(Thick.Base.Common.DynArea.Width))
{ {
if (!mSysParam.BindingTotalFilmWidth)
return;
if (tDGageServiceClient.DynArea.Width <= 100)
return;//小于100,肯定异常
double v = Math.Round(tDGageServiceClient.DynArea.Width / 10.0); double v = Math.Round(tDGageServiceClient.DynArea.Width / 10.0);
v = Math.Round(v * 10); v = Math.Round(v * 10);
......
...@@ -33,7 +33,7 @@ namespace FLY.Weight.Server ...@@ -33,7 +33,7 @@ namespace FLY.Weight.Server
public WeighterAccessory Accessory { get; } = new WeighterAccessory(); public WeighterAccessory Accessory { get; } = new WeighterAccessory();
private PLCProxySystem plcos = new PLCProxySystem(); public PLCProxySystem plcos = new PLCProxySystem();
/// <summary> /// <summary>
/// PLC代理系统 /// PLC代理系统
/// </summary> /// </summary>
...@@ -504,8 +504,7 @@ namespace FLY.Weight.Server ...@@ -504,8 +504,7 @@ namespace FLY.Weight.Server
return objnames; return objnames;
}); });
//这个是从测厚仪获取的,每几秒就写一次,不调试!!!!!
plcos.IgnoreLogProperties.Add(new SenderProperty() { sender = Accessory, propertyName = nameof(Accessory.CurrentVelocitySet) });
} }
......
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