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 @@
<sys:Double x:Key="FontSize_title">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_mid">36</sys:Double>
<Style x:Key="TextBlockStyle_title" TargetType="TextBlock">
<Setter Property="FontSize" Value="{StaticResource FontSize_title}"/>
<Setter Property="Foreground" Value="{StaticResource Color_title}"/>
......
......@@ -17,27 +17,27 @@
<Border Style="{StaticResource BorderStyle_block}" d:DataContext="{StaticResource unittests_weighters}">
<Viewbox MaxHeight="90" HorizontalAlignment="Left" VerticalAlignment="Top">
<StackPanel Orientation="Horizontal">
<Viewbox Margin="15,5" MaxHeight="90" >
<Button Style="{StaticResource Styles.Button.Empty}" Background="Transparent" Click="button_ratio_Click" Margin="30,5">
<Viewbox Margin="15,5" MaxHeight="90" >
<Button Style="{StaticResource Styles.Button.Empty}" Background="Transparent" Click="button_ratio_Click" >
<StackPanel Orientation="Horizontal">
<control:PieChart Margin="10" Width="120" Height="120"
<control:PieChart Width="60" Height="60" Margin="10"
ItemValueBinding="CurrentFlow" ItemColorBinding="Color"
ItemsSource="{Binding Items}"
/>
<StackPanel VerticalAlignment="Bottom">
<StackPanel Margin="3" >
<StackPanel Orientation="Horizontal">
<TextBlock Text="总流量" Style="{StaticResource TextBlockStyle_title_activity}" Margin="3,0"/>
<TextBlock>
<Run Text="{Binding Accessory.TotalFlowSetting,StringFormat={}{0:F0}}" Style="{StaticResource RunStyle_text_activity}" FontSize="30"/>
<StackPanel Orientation="Horizontal">
<TextBlock Text="设置&#13;总流量" Style="{StaticResource TextBlockStyle_title_activity}" Margin="3,0"/>
<TextBlock>
<Run Text="{Binding Accessory.TotalFlowSetting,StringFormat={}{0:F0}}" Style="{StaticResource RunStyle_text_activity}" FontSize="{StaticResource FontSize_text_mid}"/>
<Run Text="kg/h" Style="{StaticResource RunStyle_unit}" />
</TextBlock>
</StackPanel>
</TextBlock>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="当前&#13;总流量" Style="{StaticResource TextBlockStyle_title}" Margin="3,0"/>
<TextBlock>
<Run Text="{Binding Accessory.TotalFlow,StringFormat={}{0:F0}}" Style="{StaticResource RunStyle_text_activity}" FontSize="72" />
<Run Text="kg/h" Style="{StaticResource RunStyle_unit}" />
<Run Text="{Binding Accessory.TotalFlow,StringFormat={}{0:F0}}" Style="{StaticResource RunStyle_text}" />
<Run Text="kg/h" Style="{StaticResource RunStyle_unit}" />
</TextBlock>
</StackPanel>
</StackPanel>
......@@ -67,7 +67,7 @@
<Button Style="{StaticResource Styles.Button.Empty}" HorizontalAlignment="Right" Grid.Column="2" Grid.RowSpan="2" VerticalAlignment="Top" Click="button_clear_Click">
<Grid Style="{StaticResource GridStyle_ButtonShadow}">
<Grid Style="{StaticResource Styles.Shadow}">
<Grid Width="50" Height="50">
<Ellipse Fill="White" Stretch="Uniform" Margin="2"/>
<Path Data="{StaticResource Geometry_close-circle}" Fill="{StaticResource Color_off}" Stretch="Uniform" />
......@@ -76,10 +76,10 @@
</Button>
<TextBlock Grid.Row="1" Grid.RowSpan="2" VerticalAlignment="Bottom" Grid.ColumnSpan="2" Margin="0,0,0,-0.64">
<Run Text="{Binding Accessory.TotalProduction,StringFormat={}{0:F0}}" Style="{StaticResource RunStyle_text}" FontSize="50" />
<TextBlock Grid.Row="1" Grid.RowSpan="2" VerticalAlignment="Bottom" Grid.ColumnSpan="2" >
<Run Text="{Binding Accessory.TotalProduction,StringFormat={}{0:F0}}" Style="{StaticResource RunStyle_text}" />
</TextBlock>
<TextBlock Grid.Row="2" Grid.Column="2" Margin="0,0.5,0,0.36" >
<TextBlock Grid.Row="2" Grid.Column="2" >
<Run Text="kg" Style="{StaticResource RunStyle_unit}" />
</TextBlock>
</Grid>
......@@ -88,50 +88,49 @@
<Viewbox Margin="15,5" MaxHeight="90">
<Button Style="{StaticResource Styles.Button.Empty}" Background="Transparent" Click="button_thickness_Click" >
<StackPanel Orientation="Horizontal">
<StackPanel>
<StackPanel Margin="3" >
<TextBlock Text="吹膜宽度" Style="{StaticResource TextBlockStyle_title_activity}"/>
<StackPanel Margin="3">
<StackPanel Orientation="Horizontal" >
<TextBlock Text="吹膜&#13;宽度" Style="{StaticResource TextBlockStyle_title_activity}" Margin="3,0" />
<TextBlock >
<Run Text="{Binding Accessory.TotalFilmWidth,StringFormat={}{0:F0}}" Style="{StaticResource RunStyle_text_activity}" />
<Run Text="mm" Style="{StaticResource RunStyle_unit}" />
<Run Text="{Binding Accessory.TotalFilmWidth,StringFormat={}{0:F0}}" Style="{StaticResource RunStyle_text_activity}" />
<Run Text="mm" Style="{StaticResource RunStyle_unit}" />
</TextBlock>
</StackPanel>
<StackPanel Margin="3">
<TextBlock Text="平均密度" Style="{StaticResource TextBlockStyle_title}" />
<Viewbox Height="{StaticResource FontSize_text}" HorizontalAlignment="Left" >
<TextBlock >
<Run Text="{Binding Accessory.Density,StringFormat={}{0:F3}}" Style="{StaticResource RunStyle_text}" />
<Run Text="kg/m³" Style="{StaticResource RunStyle_unit}" />
</TextBlock>
</Viewbox>
<StackPanel Orientation="Horizontal" >
<TextBlock Text="平均&#13;密度" Style="{StaticResource TextBlockStyle_title}" Margin="3,0"/>
<TextBlock >
<Run Text="{Binding Accessory.Density,StringFormat={}{0:F3}}" Style="{StaticResource RunStyle_text}"
FontSize="{StaticResource FontSize_text_mid}"/>
<Run Text="kg/m³" Style="{StaticResource RunStyle_unit}" />
</TextBlock>
</StackPanel>
</StackPanel>
<StackPanel>
<StackPanel Margin="3" >
<TextBlock Text="设置厚度" Style="{StaticResource TextBlockStyle_title_activity}"/>
<StackPanel Margin="3">
<StackPanel Orientation="Horizontal">
<TextBlock Text="设置&#13;厚度" Style="{StaticResource TextBlockStyle_title_activity}" Margin="3,0"/>
<TextBlock >
<Run Text="{Binding Accessory.SetThickness,StringFormat={}{0:F0}}" Style="{StaticResource RunStyle_text_activity}" />
<Run Text="um" Style="{StaticResource RunStyle_unit}" />
<Run Text="{Binding Accessory.SetThickness,StringFormat={}{0:F0}}" Style="{StaticResource RunStyle_text_activity}" />
<Run Text="um" Style="{StaticResource RunStyle_unit}" />
</TextBlock>
</StackPanel>
<StackPanel Margin="3" Background="{StaticResource Color_background2}" >
<TextBlock Text="当前厚度" Style="{StaticResource TextBlockStyle_title}" />
<StackPanel Orientation="Horizontal" Background="{StaticResource Color_background2}" >
<TextBlock Text="当前&#13;厚度" Style="{StaticResource TextBlockStyle_title}" Margin="3,0"/>
<TextBlock >
<Run Text="{Binding Accessory.Thickness,StringFormat={}{0:F1}}" Style="{StaticResource RunStyle_text}" />
<Run Text="m/min" Style="{StaticResource RunStyle_unit}" />
<Run Text="{Binding Accessory.Thickness,StringFormat={}{0:F1}}" Style="{StaticResource RunStyle_text}" />
<Run Text="m/min" Style="{StaticResource RunStyle_unit}" />
</TextBlock>
</StackPanel>
</StackPanel>
<StackPanel>
<StackPanel Margin="3" Background="{StaticResource Color_background2}" >
<TextBlock Text="当前线速度" Style="{StaticResource TextBlockStyle_title}" />
<StackPanel Margin="3">
<StackPanel Orientation="Horizontal" Background="{StaticResource Color_background2}" Margin="3,0">
<TextBlock Text="当前&#13;速度" Style="{StaticResource TextBlockStyle_title}" />
<TextBlock >
<Run Text="{Binding Accessory.CurrentVelocity,StringFormat={}{0:F1}}" Style="{StaticResource RunStyle_text}" />
<Run Text="m/min" Style="{StaticResource RunStyle_unit}" />
<Run Text="{Binding Accessory.CurrentVelocity,StringFormat={}{0:F1}}" Style="{StaticResource RunStyle_text}" />
<Run Text="m/min" Style="{StaticResource RunStyle_unit}" />
</TextBlock>
</StackPanel>
<StackPanel Margin="3" >
<TextBlock Text="理论线速度" Style="{StaticResource TextBlockStyle_title}" />
<StackPanel Orientation="Horizontal" >
<TextBlock Text="理论&#13;速度" Style="{StaticResource TextBlockStyle_title}" Margin="3,0"/>
<TextBlock >
<Run Text="{Binding Accessory.TargetVelocity,StringFormat={}{0:F1}}" Style="{StaticResource RunStyle_text}" />
<Run Text="m/min" Style="{StaticResource RunStyle_unit}" />
......
......@@ -5,7 +5,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:FLY.Weight.UI.Server"
mc:Ignorable="d"
d:DesignWidth="200"
d:DesignWidth="450"
Title="PgMain">
<Page.Resources>
<local:PgMainVmUt x:Key="viewModel"/>
......@@ -15,12 +15,23 @@
<Grid x:Name="grid_plcos"/>
<Grid x:Name="grid_WeightSystem"/>
<StackPanel Margin="5">
<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>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<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.ItemTemplate>
<DataTemplate>
......
......@@ -35,7 +35,7 @@ namespace FLY.Weight.UI.Server
//grid_plc.DataContext = plsos.PLCs[0];
grid_WeightSystem.DataContext = gage.mData;
this.itemcontrol.ItemsSource = plsos.PLCs;
sp_sysParam.DataContext = gage.mSysParam;
}
private void btnSetupClick(object sender, RoutedEventArgs e)
......
......@@ -51,6 +51,6 @@ using System.Windows;
// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("7.0.0.0")]
[assembly: AssemblyFileVersion("7.0.0.0")]
[assembly: AssemblyVersion("7.0.1.0")]
[assembly: AssemblyFileVersion("7.0.1.0")]
[assembly: Guid("AC4FFE57-FF42-4B4D-9E23-FF583D78187D")]
......@@ -7,6 +7,8 @@
mc:Ignorable="d"
Title="DRList" Height="450" Width="800">
<Grid>
<DataGrid x:Name="dataGrid" AutoGenerateColumns="True" IsReadOnly="True"/>
</Grid>
</Window>
......@@ -28,21 +28,33 @@ namespace FLY.Weight.UI.Server
{
InitializeComponent();
}
public void Init(Modbus.WithThread.ModbusMapper_Client plc)
public void Init(Modbus.WithThread.ModbusMapper_Client 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 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()
{
dr = dr,
Addr = dr.addr,
DataArea = dr.dataArea,
IsNeedUpdate = dr.isNeedUpdate,
PropertyName =dr.propertyName,
PropertyName = dr.propertyName,
Description = description,
Value = dr.value
});
}
......@@ -67,7 +79,8 @@ namespace FLY.Weight.UI.Server
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++)
{
var dr = plc.DRmap[i];
......@@ -81,7 +94,7 @@ namespace FLY.Weight.UI.Server
/// Data: PC 属性
/// Regs: PLC 对象(寄存器、线圈)
/// </summary>
public class DataToRegsView:INotifyPropertyChanged
public class DataToRegsView : INotifyPropertyChanged
{
public DataToRegs dr;
/// <summary>
......@@ -99,6 +112,10 @@ namespace FLY.Weight.UI.Server
/// </summary>
public string PropertyName { get; set; }
/// <summary>
/// property 描述
/// </summary>
public string Description { get; set; }
/// <summary>
/// property 的值, 没有缩小. 只有 double 与 bool
/// </summary>
......
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FLY.Weight.Server
{
public class SysParam : Misc.ISaveToXml
public class SysParam : INotifyPropertyChanged
{
/// <summary>
/// OBJ服务端口
......@@ -19,30 +21,45 @@ namespace FLY.Weight.Server
public string BlowingAddr { get; set; } = "127.0.0.1:20006";
/// <summary>
/// 数据库保持时间 默认6个月
/// 测厚仪宽度与 吹膜宽度mm 绑定在一起
/// </summary>
public int DBKeepMonth { get; set; } = 6;
public bool BindingTotalFilmWidth { get; set; } = true;
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;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Threading;
namespace FLY.Weight.Server
{
......@@ -53,6 +54,8 @@ namespace FLY.Weight.Server
System.Environment.CurrentDirectory = mParamDirectory;
mSysParam = new SysParam();
if (!mSysParam.Load())
mSysParam.Save();
mData = new WeightSystem();
......@@ -99,12 +102,46 @@ namespace FLY.Weight.Server
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)
{
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);
v = Math.Round(v * 10);
......
......@@ -33,7 +33,7 @@ namespace FLY.Weight.Server
public WeighterAccessory Accessory { get; } = new WeighterAccessory();
private PLCProxySystem plcos = new PLCProxySystem();
public PLCProxySystem plcos = new PLCProxySystem();
/// <summary>
/// PLC代理系统
/// </summary>
......@@ -504,8 +504,7 @@ namespace FLY.Weight.Server
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