Explorar el Código

增加测试按钮

样式分支
fyf hace 2 años
padre
commit
02409db2f4
Se han modificado 4 ficheros con 128 adiciones y 87 borrados
  1. +4
    -1
      BPASmartClient.SCADAControl/Converters/BoolToVisibilityConverter.cs
  2. +9
    -9
      BPASmartClient.SCADAControl/CustomerControls/Silos.xaml.cs
  3. +107
    -71
      BPASmartClient.SCADAControl/CustomerControls/TheRedis.xaml.cs
  4. +8
    -6
      BeDesignerSCADA/Controls/MainCanvasPanel.xaml

+ 4
- 1
BPASmartClient.SCADAControl/Converters/BoolToVisibilityConverter.cs Ver fichero

@@ -46,7 +46,10 @@ namespace BPASmartClient.SCADAControl.Converters
{
Newtonsoft.Json.Linq.JToken mj = (value as Newtonsoft.Json.Linq.JToken);
if (mj.Type == JTokenType.Boolean) return ((bool)mj);
else return mj;
else if (mj.Type == JTokenType.Integer) return ((int)mj);
else if (mj.Type == JTokenType.Float) return ((float)mj);
else if(mj.Type == JTokenType.String) return ((string)mj);
else return mj.ToString();
}
}



+ 9
- 9
BPASmartClient.SCADAControl/CustomerControls/Silos.xaml.cs Ver fichero

@@ -188,29 +188,29 @@ namespace BPASmartClient.SCADAControl.CustomerControls
[Category("值设定")]
public string KgValue
{
get { return (string)GetValue(ValueProperty); }
set { SetValue(ValueProperty,value); }
get { return (string)GetValue(KgValueProperty); }
set { SetValue(KgValueProperty, value); }
}
public static readonly DependencyProperty ValueProperty =
public static readonly DependencyProperty KgValueProperty =
DependencyProperty.Register("KgValue", typeof(string),typeof(Silos),new PropertyMetadata(new PropertyChangedCallback(onTargetChanged)));
private static void onTargetChanged(DependencyObject d,DependencyPropertyChangedEventArgs e) => (d as Silos)?.TargetRefresh();

[Category("值设定")]
public string WLText
{
get { return (string)GetValue(TextProperty); }
set { SetValue(TextProperty,value); }
get { return (string)GetValue(WLTextProperty); }
set { SetValue(WLTextProperty, value); }
}
public static readonly DependencyProperty TextProperty =
public static readonly DependencyProperty WLTextProperty =
DependencyProperty.Register("WLText", typeof(string),typeof(Silos),new PropertyMetadata(new PropertyChangedCallback(onTargetChanged)));

[Category("值设定")]
public string WLTitle
{
get { return (string)GetValue(TitleProperty); }
set { SetValue(TitleProperty,value); }
get { return (string)GetValue(WLTitleProperty); }
set { SetValue(WLTitleProperty, value); }
}
public static readonly DependencyProperty TitleProperty =
public static readonly DependencyProperty WLTitleProperty =
DependencyProperty.Register("WLTitle", typeof(string),typeof(Silos),new PropertyMetadata(new PropertyChangedCallback(onTargetChanged)));

[Category("值设定")]


+ 107
- 71
BPASmartClient.SCADAControl/CustomerControls/TheRedis.xaml.cs Ver fichero

@@ -27,7 +27,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls
/// <summary>
/// TheRedis.xaml 的交互逻辑
/// </summary>
public partial class TheRedis :UserControl, IExecutable, IDisposable
public partial class TheRedis : UserControl, IExecutable, IDisposable
{
Image imageZC = null;
Image imageYC = null;
@@ -41,7 +41,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls
Height = 40;
this.SizeChanged += TheRedis_SizeChanged;
}
private void TheRedis_SizeChanged(object sender,SizeChangedEventArgs e)
private void TheRedis_SizeChanged(object sender, SizeChangedEventArgs e)
{
if (textBlock == null)
{
@@ -84,7 +84,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls
{
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(depObj); i++)
{
DependencyObject child = VisualTreeHelper.GetChild(depObj,i);
DependencyObject child = VisualTreeHelper.GetChild(depObj, i);
if (child != null && child is T)
{
yield return (T)child;
@@ -108,7 +108,6 @@ namespace BPASmartClient.SCADAControl.CustomerControls
if (IsExecuteState)
{
Register();
//Style = null;
}
}
}
@@ -135,73 +134,90 @@ namespace BPASmartClient.SCADAControl.CustomerControls
timer.Start();

}
Task<bool> isSuccess;
private async void Timer_Tick(object sender,EventArgs e)
private async void Timer_Tick(object sender, EventArgs e)
{
Config.GetInstance().RunJsScipt(TikcExecute);
if (fRedisClient._connection != null && fRedisClient._connection.IsConnected)

if (TestData)
{
Direction = 1;
keyValuePairs1.Clear();
for (int i = 0; i < 20; i++)
{
Random ran = new Random();
int n = ran.Next(0, 100);
keyValuePairs1[i.ToString()] = "10." + n;
}
Class_DataBus.GetInstance().Dic_RedisData["Test"] = keyValuePairs1;
Class_DataBus.GetInstance().Dic_RedisDataBinding = JsonConvert.DeserializeObject<Dictionary<string, object>>(JsonConvert.SerializeObject(Class_DataBus.GetInstance().Dic_RedisData));
Class_DataBus.GetInstance().refreshDataAction("Test");
}
else
{
Direction = 0;
try
if (fRedisClient._connection != null && fRedisClient._connection.IsConnected)
{
if (!string.IsNullOrEmpty(DataSouceInformation))
fRedisClient.Connect(DataSouceInformation);
Direction = 1;
}
catch (Exception ex)
else
{
Direction = 2;
Direction = 0;
try
{
if (!string.IsNullOrEmpty(DataSouceInformation))
fRedisClient.Connect(DataSouceInformation);
}
catch (Exception ex)
{
Direction = 2;
}
}
}
if (Direction == 1) //定时读取数据
{
try
if (Direction == 1) //定时读取数据
{
if (!string.IsNullOrEmpty(DeviceName))
try
{
RedisValue obj = fRedisClient.RedisGet(DeviceName);
List<ReeisDataModel> str = JsonConvert.DeserializeObject<List<ReeisDataModel>>(obj.ToString());
Dictionary<string, object> keyValues = new Dictionary<string, object>();
Dictionary<string, string> keyValuesType = new Dictionary<string, string>();
str?.ForEach(jon =>
if (!string.IsNullOrEmpty(DeviceName))
{
keyValues[jon.VarName] = GetValuesType(jon.DataType, jon.VarVaule);
keyValuesType[jon.VarName] = jon.DataType.ToString();
});
Class_DataBus.GetInstance().Dic_RedisData[DeviceName] = keyValues;
Class_DataBus.GetInstance().Dic_RedisDataBinding = JsonConvert.DeserializeObject<Dictionary<string, object>>(JsonConvert.SerializeObject(Class_DataBus.GetInstance().Dic_RedisData));
Class_DataBus.GetInstance().Dic_RedisDataType[DeviceName] = keyValuesType;
Class_DataBus.GetInstance().refreshDataAction(DeviceName);
if (PropertyChange != null) PropertyChange(this,null);
}
else
{
fRedisClient.GetKeys()?.ToList().ForEach(par => {
//所有变量集合
//PublishInfo
List<ReeisDataModel> str = JsonConvert.DeserializeObject<List<ReeisDataModel>>(par.Value);
Dictionary<string,object> keyValues = new Dictionary<string,object>();
RedisValue obj = fRedisClient.RedisGet(DeviceName);
List<ReeisDataModel> str = JsonConvert.DeserializeObject<List<ReeisDataModel>>(obj.ToString());
Dictionary<string, object> keyValues = new Dictionary<string, object>();
Dictionary<string, string> keyValuesType = new Dictionary<string, string>();
str?.ForEach(jon =>
{
keyValues[jon.VarName] = GetValuesType(jon.DataType, jon.VarVaule);
keyValuesType[jon.VarName] = jon.DataType.ToString();
keyValuesType[jon.VarName] = jon.DataType.ToString();
});
Class_DataBus.GetInstance().Dic_RedisData[par.Key] = keyValues;
Class_DataBus.GetInstance().Dic_RedisData[DeviceName] = keyValues;
Class_DataBus.GetInstance().Dic_RedisDataBinding = JsonConvert.DeserializeObject<Dictionary<string, object>>(JsonConvert.SerializeObject(Class_DataBus.GetInstance().Dic_RedisData));
Class_DataBus.GetInstance().Dic_RedisDataType[par.Key] = keyValuesType;
Class_DataBus.GetInstance().refreshDataAction(par.Key);
Class_DataBus.GetInstance().Dic_RedisDataType[DeviceName] = keyValuesType;
Class_DataBus.GetInstance().refreshDataAction(DeviceName);
if (PropertyChange != null) PropertyChange(this, null);
}
else
{
fRedisClient.GetKeys()?.ToList().ForEach(par =>
{
//所有变量集合
//PublishInfo
List<ReeisDataModel> str = JsonConvert.DeserializeObject<List<ReeisDataModel>>(par.Value);
Dictionary<string, object> keyValues = new Dictionary<string, object>();
Dictionary<string, string> keyValuesType = new Dictionary<string, string>();
str?.ForEach(jon =>
{
keyValues[jon.VarName] = GetValuesType(jon.DataType, jon.VarVaule);
keyValuesType[jon.VarName] = jon.DataType.ToString();
});
Class_DataBus.GetInstance().Dic_RedisData[par.Key] = keyValues;
Class_DataBus.GetInstance().Dic_RedisDataBinding = JsonConvert.DeserializeObject<Dictionary<string, object>>(JsonConvert.SerializeObject(Class_DataBus.GetInstance().Dic_RedisData));
Class_DataBus.GetInstance().Dic_RedisDataType[par.Key] = keyValuesType;
Class_DataBus.GetInstance().refreshDataAction(par.Key);

});
if (PropertyChange != null) PropertyChange(this,null);
});
if (PropertyChange != null) PropertyChange(this, null);
}
}
}
catch (Exception ex)
{
catch (Exception ex)
{

}
}
}
}
@@ -212,7 +228,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls
/// <param name="eData"></param>
/// <param name="Value"></param>
/// <returns></returns>
public object GetValuesType(EDataType eData,string Value)
public object GetValuesType(EDataType eData, string Value)
{
try
{
@@ -265,16 +281,36 @@ namespace BPASmartClient.SCADAControl.CustomerControls
}

#region 属性
public bool TestData
{
get { return (bool)GetValue(TestDataProperty); }
set { SetValue(TestDataProperty, value); }
}
public static readonly DependencyProperty TestDataProperty =
DependencyProperty.Register("TestData", typeof(bool), typeof(TheRedis),
new PropertyMetadata(false, new PropertyChangedCallback(OnTestDataPropertyChanged)));
private static void OnTestDataPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
(d as TheRedis)?.RefreshTest();
}
#region MyRegion
Dictionary<string, object> keyValuePairs1 = new Dictionary<string, object>();
#endregion
public void RefreshTest()
{
}
[Category("值设定")]
public int Direction
{
get { return (int)GetValue(DirectionProperty); }
set { SetValue(DirectionProperty,value); }
set { SetValue(DirectionProperty, value); }
}
public static readonly DependencyProperty DirectionProperty =
DependencyProperty.Register("Direction",typeof(int),typeof(TheRedis),
new PropertyMetadata(0,new PropertyChangedCallback(OnPropertyChanged)));
private static void OnPropertyChanged(DependencyObject d,DependencyPropertyChangedEventArgs e)
DependencyProperty.Register("Direction", typeof(int), typeof(TheRedis),
new PropertyMetadata(0, new PropertyChangedCallback(OnPropertyChanged)));
private static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
(d as TheRedis)?.Refresh();
}
@@ -318,10 +354,10 @@ namespace BPASmartClient.SCADAControl.CustomerControls
public string TikcExecute
{
get { return (string)GetValue(TikcExecuteProperty); }
set { SetValue(TikcExecuteProperty,value); }
set { SetValue(TikcExecuteProperty, value); }
}
public static readonly DependencyProperty TikcExecuteProperty =
DependencyProperty.Register("TikcExecute",typeof(string),typeof(TheRedis),new PropertyMetadata(string.Empty));
DependencyProperty.Register("TikcExecute", typeof(string), typeof(TheRedis), new PropertyMetadata(string.Empty));
#endregion

#region 数据绑定模块
@@ -330,43 +366,43 @@ namespace BPASmartClient.SCADAControl.CustomerControls
public int TimeCount
{
get { return (int)GetValue(TimeCountProperty); }
set { SetValue(TimeCountProperty,value); }
set { SetValue(TimeCountProperty, value); }
}
public static readonly DependencyProperty TimeCountProperty =
DependencyProperty.Register("TimeCount",typeof(int),typeof(TheRedis),new PropertyMetadata(100));
DependencyProperty.Register("TimeCount", typeof(int), typeof(TheRedis), new PropertyMetadata(100));
[Category("数据绑定-数据来源")]
public string DataSouceInformation
{
get { return (string)GetValue(DataSouceInformationProperty); }
set { SetValue(DataSouceInformationProperty,value); }
set { SetValue(DataSouceInformationProperty, value); }
}
public static readonly DependencyProperty DataSouceInformationProperty =
DependencyProperty.Register("DataSouceInformation",typeof(string),typeof(TheRedis),new PropertyMetadata("124.222.238.75:16000,password=123456,defaultDatabase=1"));
DependencyProperty.Register("DataSouceInformation", typeof(string), typeof(TheRedis), new PropertyMetadata("124.222.238.75:16000,password=123456,defaultDatabase=1"));
[Category("数据绑定-数据来源")]
public string DeviceName
{
get { return (string)GetValue(DeviceNameProperty); }
set { SetValue(DeviceNameProperty,value); }
set { SetValue(DeviceNameProperty, value); }
}
public static readonly DependencyProperty DeviceNameProperty =
DependencyProperty.Register("DeviceName",typeof(string),typeof(TheRedis),new PropertyMetadata(string.Empty));
DependencyProperty.Register("DeviceName", typeof(string), typeof(TheRedis), new PropertyMetadata(string.Empty));
[Category("数据绑定")]
public string FDataSouce
{
get { return (string)GetValue(FDataSouceProperty); }
set { SetValue(FDataSouceProperty,value); }
set { SetValue(FDataSouceProperty, value); }
}
public static readonly DependencyProperty FDataSouceProperty =
DependencyProperty.Register("FDataSouce",typeof(string),typeof(TheRedis),new PropertyMetadata(string.Empty,new PropertyChangedCallback(onFDataSouceChanged)));
private static void onFDataSouceChanged(DependencyObject d,DependencyPropertyChangedEventArgs e) => (d as TheRedis)?.DataSouceRefresh();
DependencyProperty.Register("FDataSouce", typeof(string), typeof(TheRedis), new PropertyMetadata(string.Empty, new PropertyChangedCallback(onFDataSouceChanged)));
private static void onFDataSouceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) => (d as TheRedis)?.DataSouceRefresh();
public void DataSouceRefresh()
{
try
{
//if (!string.IsNullOrEmpty(FDataSouce))
{
GenerateData = (string)CSharpConfig.GetInstance().RunCSharp(Code,new object[] { FDataSouce });
GenerateData = (string)CSharpConfig.GetInstance().RunCSharp(Code, new object[] { FDataSouce });
}
}
catch (Exception ex)
@@ -379,10 +415,10 @@ namespace BPASmartClient.SCADAControl.CustomerControls
public string Code
{
get { return (string)GetValue(CodeProperty); }
set { SetValue(CodeProperty,value); }
set { SetValue(CodeProperty, value); }
}
public static readonly DependencyProperty CodeProperty =
DependencyProperty.Register("Code",typeof(string),typeof(TheRedis),new PropertyMetadata(_code));
DependencyProperty.Register("Code", typeof(string), typeof(TheRedis), new PropertyMetadata(_code));
[Category("数据绑定")]
public bool IsRun
{
@@ -407,10 +443,10 @@ namespace BPASmartClient.SCADAControl.CustomerControls
public string GenerateData
{
get { return (string)GetValue(GenerateDataProperty); }
set { SetValue(GenerateDataProperty,value); }
set { SetValue(GenerateDataProperty, value); }
}
public static readonly DependencyProperty GenerateDataProperty =
DependencyProperty.Register("GenerateData",typeof(string),typeof(TheRedis),new PropertyMetadata(string.Empty));
DependencyProperty.Register("GenerateData", typeof(string), typeof(TheRedis), new PropertyMetadata(string.Empty));
#endregion




+ 8
- 6
BeDesignerSCADA/Controls/MainCanvasPanel.xaml Ver fichero

@@ -216,7 +216,9 @@
<mypro:PropertyDefinition DisplayName="物料描述" Category="基本属性" DisplayOrder="2" Name="WLText" Description="物料描述"/>
<mypro:PropertyDefinition DisplayName="物料标题" Category="基本属性" DisplayOrder="2" Name="WLTitle" Description="物料标题"/>
<mypro:PropertyDefinition DisplayName="标题" Category="基本属性" DisplayOrder="2" Name="Title" Description="标题"/>
<mypro:PropertyDefinition DisplayName="运行状态" Category="基本属性" DisplayOrder="2" Name="Direction" Description="Direction"/>

<mypro:PropertyDefinition DisplayName="最大值" Category="基本属性" DisplayOrder="3" Name="MaxValue" Description="MaxValue"/>
<mypro:PropertyDefinition DisplayName="最小值" Category="基本属性" DisplayOrder="3" Name="MinValue" Description="MinValue"/>
<mypro:PropertyDefinition DisplayName="最大值" Category="基本属性" DisplayOrder="3" Name="Maximum" Description="Maximum"/>
@@ -251,7 +253,9 @@
<mypro:PropertyDefinition DisplayName="文本提示" Category="基本属性" DisplayOrder="9" Name="ToolTip"/>
<mypro:PropertyDefinition DisplayName="左边距" Category="基本属性" DisplayOrder="9" Name="(Canvas.Left)"/>
<mypro:PropertyDefinition DisplayName="上边距" Category="基本属性" DisplayOrder="9" Name="(Canvas.Top)"/>
<mypro:PropertyDefinition DisplayName="启动测试" Category="基本属性" DisplayOrder="9" Name="TestData"/>

<mypro:PropertyDefinition DisplayName="数据来源类型" Category="数据绑定模块" DisplayOrder="0" Name="DataSouceType"/>
<mypro:PropertyDefinition DisplayName="设备名称" Category="数据绑定模块" DisplayOrder="0" Name="DeviceName"/>
<mypro:PropertyDefinition DisplayName="接口类型" Category="数据绑定模块" DisplayOrder="1" Name="InterfaceMode"/>
@@ -290,10 +294,8 @@
<mypro:PropertyDefinition DisplayName="勾选事件" Category="事件绑定" DisplayOrder="3" Name="CheckedExec" />
<mypro:PropertyDefinition DisplayName="取消勾选事件" Category="事件绑定" DisplayOrder="4" Name="UnCheckedExec" />
<mypro:PropertyDefinition DisplayName="接收消息集" Category="事件绑定" DisplayOrder="5" Name="EventReceiveNameList" />
<mypro:PropertyDefinition DisplayName="出料单击事件" Category="事件绑定" DisplayOrder="6" Name="出料单击事件" />
<mypro:PropertyDefinition DisplayName="停止出料单击事件" Category="事件绑定" DisplayOrder="7" Name="停止出料单击事件" />


<mypro:PropertyDefinition DisplayName="出料单击事件" Category="事件绑定" DisplayOrder="6" Name="ChuLiaoExecute" />
<mypro:PropertyDefinition DisplayName="停止出料单击事件" Category="事件绑定" DisplayOrder="7" Name="StopChuLiaoExecute" />
</mypro:PropertyGrid.PropertyDefinitions>

<mypro:PropertyGrid.EditorDefinitions>
@@ -334,7 +336,7 @@

<!--代码绑定模块-->
<mypro:EditorTemplateDefinition TargetProperties="ClickExec,ValueChangedExecute,TikcExecute,CheckedExec,UnCheckedExec" >
<mypro:EditorTemplateDefinition TargetProperties="ClickExec,ValueChangedExecute,TikcExecute,CheckedExec,UnCheckedExec,ChuLiaoExecute,StopChuLiaoExecute" >
<mypro:EditorTemplateDefinition.EditingTemplate>
<DataTemplate>
<Grid>
@@ -381,7 +383,7 @@
</mypro:EditorTemplateDefinition.EditingTemplate>
</mypro:EditorTemplateDefinition>

<mypro:EditorTemplateDefinition TargetProperties="Text,Title,Value,BindingIsChecked,Header,KgValue,WLText,WLTitle,DataSouceInformation" >
<mypro:EditorTemplateDefinition TargetProperties="Text,Title,Value,BindingIsChecked,Header,KgValue,WLText,WLTitle,DataSouceInformation,Direction" >
<mypro:EditorTemplateDefinition.EditingTemplate>
<DataTemplate>
<!--此处可自由发挥-->


Cargando…
Cancelar
Guardar