Commit d17b0a44 authored by 潘栩锋's avatar 潘栩锋 🚴
parents 6fb9b493 556f69da
......@@ -202,9 +202,9 @@
<ItemsControl.ItemTemplate>
<DataTemplate>
<Button Style="{StaticResource ButtonStyle_empty}" Background="{Binding Background}" Tag="{Binding .}" Click="button_componentNew_Click" Margin="5" BorderBrush="#FF0C0C0C">
<StackPanel Orientation="Vertical" Margin="10">
<TextBlock Text="{Binding Header}" FontSize="20" TextWrapping = "Wrap" />
<TextBlock Text="{Binding Count}" FontSize="15" Margin="0,20,0,0"/>
<StackPanel Margin="10">
<TextBlock Text="{Binding Header}" FontSize="18" TextWrapping = "Wrap" />
<TextBlock Text="{Binding Count}" FontSize="12" Margin="0,20,0,0"/>
</StackPanel>
</Button>
</DataTemplate>
......
......@@ -6,44 +6,45 @@ using System.Windows.Data;
namespace FLY.ControlLibrary.Converter
{
/// <summary>
/// 3个输入,
/// [0]比例分子;
/// [1]比例分母;
/// [2]控件最大长度
/// </summary>
public class RatioConverter: IMultiValueConverter
public class RatioConverter : IMultiValueConverter
{
#region IMultiValueConverter 成员
double getValue(object value)
{
if ((value is int) && (!Misc.MyBase.ISVALIDATA((int)value)))
return 0;
try
{
return System.Convert.ToDouble(value);
}
catch
{
return 0;
}
}
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (values.Length == 3 && (values[0] is int) && (values[1] is int) && (values[2] is double))//必须要检查,不然 界面生成器 会错误,提示转换异常
if (values.Length != 3) //必须要检查,不然 界面生成器 会错误,提示转换异常
{
double ratio ;
int value = (int)values[0];
if (value == 99999998)
value = 0;
int max = (int)values[1];
double ActualWidth = (double)values[2];
return 100;
}
if(max <=0)
ratio = 0;
else
ratio = (double)value / max;
double ratio;
double value = getValue(values[0]);
double max = getValue(values[1]);
double ActualWidth = getValue(values[2]);
if (ratio < 0)
ratio = 0;
else if (ratio > 1)
ratio = 1;
if (max <= 0)
ratio = 0;
else
ratio = (double)value / max;
return ActualWidth * ratio;
}
else
{
return 100;
}
if (ratio < 0)
ratio = 0;
else if (ratio > 1)
ratio = 1;
return ActualWidth * ratio;
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
......
......@@ -349,8 +349,8 @@ namespace FlyADBase
ID,
FLYAD7_OBJ_INTERFACE.FLYIO_OBJ_INTERFACE.GET_IO);
NotifyPropertyChanged("Pos1LCShift");//写入到AD盒
NotifyPropertyChanged("Pos2Comp");//写入到AD盒
NotifyPropertyChanged(nameof(Pos1LCShift));//写入到AD盒
NotifyPropertyChanged(nameof(Pos2Comp));//写入到AD盒
SyncPos2Clear();
SyncClear();
......@@ -516,12 +516,12 @@ namespace FlyADBase
Array.Copy(pack.code, Code, pack.code.Length);
Code[6] = 0x06;
NotifyPropertyChanged("Code");
NotifyPropertyChanged(nameof(Code));
Surplus = pack.surplus;
Array.Copy(pack.access, Access, pack.access.Length);
NotifyPropertyChanged("Access");
NotifyPropertyChanged(nameof(Access));
} break;
case FLYAD7_OBJ_INTERFACE.SYS_DATA_INTERFACE.GET_ZERO_POS:
......@@ -976,12 +976,12 @@ namespace FlyADBase
public int ADMax { get; } = 65535;
/// <summary>
/// 输入口状态,只有12位有效
/// 输入口状态,只有12位有效, 大AD盒 16位
/// </summary>
public UInt16 IStatus { get; private set; } = 0xffff;
/// <summary>
/// 输出口状态,只有4位有效
/// 输出口状态,只有4位有效, 大AD盒 8位
/// </summary>
public UInt16 OStatus { get; private set; } = 0xffff;
......
using FLY.OBJComponents.Common;
using FLY.OBJComponents.IService;
using FLY.OBJComponents.OBJ_INTERFACE;
using FObjBase;
using Newtonsoft.Json;
......@@ -6,6 +7,7 @@ using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using System.Text;
namespace FLY.OBJComponents.Client
......@@ -71,6 +73,23 @@ namespace FLY.OBJComponents.Client
/// <param name="e"></param>
void Data_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
PropertyInfo property = sender.GetType().GetProperty(e.PropertyName);
if (!property.CanWrite) {
return;
}
if (sender is IPropertyOpt)
{
var opt = (IPropertyOpt)sender;
string[] nosync = opt.GetNoSyncPropNames();
if (nosync != null && nosync.Count()!=0) {
if (nosync.Contains(e.PropertyName)) {
//这个不需要同步
return;
}
}
}
string objname = (from kv in ObjNames where kv.Value == sender select kv.Key).First();
Dictionary<string, Dictionary<string, object>> DsDso = new Dictionary<string, Dictionary<string, object>>
......
......@@ -25,10 +25,16 @@ namespace FLY.OBJComponents.Common
{
throw new Exception("PropertiesManager_JSON 类型="+obj.GetType().ToString()+" 不能找到 属性名=" + propertyName, e);
}
if (!property.CanWrite) {
throw new Exception("PropertiesManager_JSON 类型=" + obj.GetType().ToString() + " 属性名=" + propertyName +" 不能set");
}
if (property != null)
{
if (v.GetType() == property.PropertyType)
{
property.SetValue(obj, v, null);
}
else
......
......@@ -46,7 +46,6 @@ namespace FLY.OBJComponents.Server
public string property;
public byte code;
public string msg;
public bool offIsError;
}
Dictionary<INotifyPropertyChanged, ErrorAction> obj_error = new Dictionary<INotifyPropertyChanged, ErrorAction>();
......@@ -60,14 +59,12 @@ namespace FLY.OBJComponents.Server
{
//肯定有,没有就让它出错!!!
string desp = (propertyInfo.GetCustomAttributes(typeof(DescriptionAttribute), false).First() as DescriptionAttribute).Description;
//bool offIsError = (propertyInfo.GetCustomAttributes(typeof(IsErrorAttribute), false).First() as IsErrorAttribute).OffIsError;
//报警如果是反向, 会被设置为放大=-1, 所以 最后属性 肯定是 true 时报警, offIsError没有用
ErrorInfo errorInfo = new ErrorInfo()
{
property = propertyInfo.Name,
msg = desp,
//offIsError = offIsError,
code = ErrCode
};
error_property.Add(errorInfo);
......@@ -105,7 +102,7 @@ namespace FLY.OBJComponents.Server
FObjBase.PollModule.Current.Poll_Config(PollModule.POLL_CONFIG.ADD,
() =>
{
Misc.BindingOperations.SetBinding(PLCos, "IsConnectedWithPLC", () =>
Misc.BindingOperations.SetBinding(PLCos, nameof(PLCos.IsConnectedWithPLC), () =>
{
bool b = !PLCos.IsConnectedWithPLC;
......@@ -119,23 +116,51 @@ namespace FLY.OBJComponents.Server
}, TimeSpan.FromSeconds(3), true, false, this, MARKNO_DELAY_ISCONNECTED, true);
//--------------------------------------------------------------------------------
//把全部报警状态取反,也就是不报警!!!
foreach (var kv in obj_error)
//启动定时器,每1秒查报警,防止 以为报警复位了,但其实还在报警
//FObjBase.PollModule.Current.Poll_Config(PollModule.POLL_CONFIG.ADD,
// () =>
// {
// foreach(var objError in obj_error)
// {
// object sender = objError.Key;
// ErrorAction errorAction = objError.Value;
// foreach (var ei in errorAction.error_property)
// {
// //获取描述
// var type = sender.GetType();
// var property = type.GetProperty(ei.property);
// bool b = (bool)property.GetValue(sender, null);
// string desp = ei.msg;
// ERR_STATE state = b ? ERR_STATE.ON : ERR_STATE.OFF;
// byte errcode = ei.code;//每个报警必须不一样!!
// string description = desp;
// errorAction.action?.Invoke(ref description, errorAction.state);
// mWarning.Add(errcode, description, state);
// }
// }
// }, TimeSpan.FromSeconds(1));
}
public void ResetError(INotifyPropertyChanged sender)
{
var type = sender.GetType();
foreach (var ei in obj_error[sender as INotifyPropertyChanged].error_property)
{
object sender = kv.Key;
foreach (var ei in kv.Value.error_property)
{
if (ei.offIsError)
{
Misc.PropertiesManager.SetValue(sender, ei.property, true);
}
//false 不用写,默认值就是
}
var property = type.GetProperty(ei.property);
property.SetValue(sender, false);
}
}
public void ResetError()
{
foreach (var sender in obj_error.Keys) {
ResetError(sender);
}
}
void Obj_PropertyChanged_ForError(object sender, PropertyChangedEventArgs e)
{
ErrorAction errorAction = obj_error[sender as INotifyPropertyChanged];
......@@ -150,13 +175,8 @@ namespace FLY.OBJComponents.Server
var property = type.GetProperty(ei.property);
bool b = (bool)property.GetValue(sender, null);
string desp = ei.msg;
bool offIsError = ei.offIsError;
ERR_STATE state;
if (offIsError)
state = !b ? ERR_STATE.ON : ERR_STATE.OFF;
else
state = b ? ERR_STATE.ON : ERR_STATE.OFF;
ERR_STATE state = b ? ERR_STATE.ON : ERR_STATE.OFF;
byte errcode = ei.code;//每个报警必须不一样!!
string description = desp;
......
......@@ -103,23 +103,43 @@
<StackPanel >
<StackPanel Orientation="Horizontal" Margin="2">
<TextBlock Text="入" Style="{StaticResource ItemHeaderStyle}" />
<StackPanel Orientation="Horizontal" Margin="4,0">
<Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=15}" Style="{StaticResource IOStyle}"/>
<Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=14}" Style="{StaticResource IOStyle}"/>
<Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=13}" Style="{StaticResource IOStyle}"/>
<Grid>
<Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=12}" Style="{StaticResource IOStyle}"/>
<TextBlock Text="13" Style="{StaticResource IOTextStyle}"/>
</Grid>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="4,0">
<Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=11}" Style="{StaticResource IOStyle}"/>
<Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=10}" Style="{StaticResource IOStyle}"/>
<Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=9}" Style="{StaticResource IOStyle}"/>
<Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=8}" Style="{StaticResource IOStyle}"/>
<Grid>
<Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=8}" Style="{StaticResource IOStyle}"/>
<TextBlock Text="9" Style="{StaticResource IOTextStyle}"/>
</Grid>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="4,0">
<Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=7}" Style="{StaticResource IOStyle}"/>
<Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=6}" Style="{StaticResource IOStyle}"/>
<Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=5}" Style="{StaticResource IOStyle}"/>
<Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=4}" Style="{StaticResource IOStyle}"/>
<Grid>
<Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=4}" Style="{StaticResource IOStyle}"/>
<TextBlock Text="5" Style="{StaticResource IOTextStyle}"/>
</Grid>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="4,0">
<Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=3}" Style="{StaticResource IOStyle}"/>
<Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=2}" Style="{StaticResource IOStyle}"/>
<Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=1}" Style="{StaticResource IOStyle}"/>
<Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=0}" Style="{StaticResource IOStyle}"/>
<Grid>
<Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=0}" Style="{StaticResource IOStyle}"/>
<TextBlock Text="1" Style="{StaticResource IOTextStyle}"/>
</Grid>
</StackPanel>
</StackPanel>
<Grid Margin="2">
......@@ -129,11 +149,23 @@
</Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal" VerticalAlignment="Top">
<TextBlock Text="出" Style="{StaticResource ItemHeaderStyle}" />
<StackPanel Orientation="Horizontal" Margin="4,0">
<Rectangle Fill="{Binding OStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=7}" Style="{StaticResource IOStyle}"/>
<Rectangle Fill="{Binding OStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=6}" Style="{StaticResource IOStyle}"/>
<Rectangle Fill="{Binding OStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=5}" Style="{StaticResource IOStyle}"/>
<Grid>
<Rectangle Fill="{Binding OStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=4}" Style="{StaticResource IOStyle}"/>
<TextBlock Text="5" Style="{StaticResource IOTextStyle}"/>
</Grid>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="4,0">
<Rectangle Fill="{Binding OStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=3}" Style="{StaticResource IOStyle}"/>
<Rectangle Fill="{Binding OStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=2}" Style="{StaticResource IOStyle}"/>
<Rectangle Fill="{Binding OStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=1}" Style="{StaticResource IOStyle}"/>
<Rectangle Fill="{Binding OStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=0}" Style="{StaticResource IOStyle}"/>
<Grid>
<Rectangle Fill="{Binding OStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=0}" Style="{StaticResource IOStyle}"/>
<TextBlock Text="1" Style="{StaticResource IOTextStyle}"/>
</Grid>
</StackPanel>
</StackPanel>
<Grid Margin="1" >
......
......@@ -16,10 +16,16 @@
<Setter Property="Margin" Value="5,0"/>
</Style>
<Style x:Key="IOStyle" TargetType="Rectangle" >
<Setter Property="Width" Value="11" />
<Setter Property="Width" Value="10" />
<Setter Property="Height" Value="12" />
<Setter Property="Margin" Value="1" />
</Style>
<Style x:Key="IOTextStyle" TargetType="TextBlock">
<Setter Property="Foreground" Value="#FF119EDA" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="FontSize" Value="10"/>
</Style>
<Style x:Key="BtnStyle" TargetType="{x:Type Button}" BasedOn="{StaticResource ButtonStyle_empty}">
<Setter Property="Margin" Value="2"/>
<Setter Property="Foreground" Value="{StaticResource AccentBaseColorBrush}"/>
......
......@@ -9,8 +9,6 @@ namespace SQLite
public class DBTable<T> : IDBTable
where T : new()
{
public List<SQLiteHelper.ArrayFieldTypeInfo> ArrayFieldTypeInfos = new List<SQLiteHelper.ArrayFieldTypeInfo>();
public string TableName { get; private set; }
private long freeID = 0;
......@@ -32,10 +30,7 @@ namespace SQLite
{
get
{
if (ArrayFieldTypeInfos.Count() == 0)
return ddl;
else
return SQLiteHelper.GetCreateTableCommandText(typeof(T), ArrayFieldTypeInfos.ToArray());
return ddl;
}
}
......@@ -81,7 +76,7 @@ namespace SQLite
sql += " " + condition;
DataTable dataTable = sqliteHelper.ExecuteReader(sql);
return SQLiteHelper.ToObjs<T>(dataTable, ArrayFieldTypeInfos.ToArray());
return SQLiteHelper.ToObjs<T>(dataTable);
}
/// <summary>
......
......@@ -11,15 +11,6 @@ namespace SQLite
}
}
public class BortherAttribute : Attribute
{
}
public class ChildAttribute : Attribute
{
}
public class PropertyIndexAttribute : Attribute
{
......
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