pry 2 years ago
parent
commit
0878242b15
50 changed files with 2816 additions and 116 deletions
  1. +2
    -0
      BPASmartClient.Compiler/BPASmartClient.Compiler.csproj
  2. +68
    -0
      BPASmartClient.Compiler/FJson.cs
  3. +170
    -0
      BPASmartClient.Compiler/FRedisClient.cs
  4. +69
    -0
      BPASmartClient.Compiler/RedisHelper.cs
  5. +1
    -1
      BPASmartClient.CustomResource/Pages/View/MainView.xaml
  6. +3
    -0
      BPASmartClient.CustomResource/Pages/ViewModel/AlarmViewModel.cs
  7. +1
    -1
      BPASmartClient.CustomResource/Pages/ViewModel/MainViewModel.cs
  8. +1
    -1
      BPASmartClient.DATABUS/Class_DataBus.cs
  9. +4
    -0
      BPASmartClient.MessageName/EnumHelp/DataTypeEnum.cs
  10. +75
    -11
      BPASmartClient.SCADAControl/BPASmartClient.SCADAControl.csproj
  11. +173
    -0
      BPASmartClient.SCADAControl/Converters/RelayCommandSimple.cs
  12. +59
    -0
      BPASmartClient.SCADAControl/Converters/Style3ArcConverter.cs
  13. +6
    -3
      BPASmartClient.SCADAControl/CustomerControls/NumberBox.cs
  14. +0
    -1
      BPASmartClient.SCADAControl/CustomerControls/Silos.xaml
  15. +88
    -18
      BPASmartClient.SCADAControl/CustomerControls/Silos.xaml.cs
  16. +63
    -0
      BPASmartClient.SCADAControl/CustomerControls/TheBlueProgressBar.cs
  17. +75
    -7
      BPASmartClient.SCADAControl/CustomerControls/TheButton.xaml.cs
  18. +7
    -0
      BPASmartClient.SCADAControl/CustomerControls/TheCheckBox.xaml
  19. +5
    -2
      BPASmartClient.SCADAControl/CustomerControls/TheComboBox.xaml.cs
  20. +64
    -0
      BPASmartClient.SCADAControl/CustomerControls/TheGreenProgressBar.cs
  21. +3
    -0
      BPASmartClient.SCADAControl/CustomerControls/TheGroupBox.xaml.cs
  22. +19
    -5
      BPASmartClient.SCADAControl/CustomerControls/TheProgressBar.cs
  23. +3
    -0
      BPASmartClient.SCADAControl/CustomerControls/TheRadioButton.cs
  24. +64
    -0
      BPASmartClient.SCADAControl/CustomerControls/TheRedProgressBar.cs
  25. +15
    -0
      BPASmartClient.SCADAControl/CustomerControls/TheRedis.xaml
  26. +319
    -0
      BPASmartClient.SCADAControl/CustomerControls/TheRedis.xaml.cs
  27. +128
    -0
      BPASmartClient.SCADAControl/CustomerControls/TheTextBlock.cs
  28. +0
    -9
      BPASmartClient.SCADAControl/CustomerControls/TheTextBlock.xaml
  29. +88
    -4
      BPASmartClient.SCADAControl/CustomerControls/TheTextBox.cs
  30. +3
    -0
      BPASmartClient.SCADAControl/CustomerControls/WaveProgressBar.cs
  31. BIN
     
  32. BIN
     
  33. BIN
     
  34. BIN
     
  35. BIN
     
  36. BIN
     
  37. BIN
     
  38. BIN
     
  39. BIN
     
  40. BIN
     
  41. +1223
    -43
      BPASmartClient.SCADAControl/Themes/Generic.xaml
  42. +1
    -2
      FryPot_DosingSystem/App.xaml.cs
  43. +0
    -1
      FryPot_DosingSystem/Control/DosingLogicControl.cs
  44. +3
    -2
      FryPot_DosingSystem/Model/AlarmInfo.cs
  45. +1
    -1
      FryPot_DosingSystem/View/FryPotMonitorView.xaml
  46. +8
    -1
      FryPot_DosingSystem/View/RecipeManageView.xaml.cs
  47. +1
    -1
      FryPot_DosingSystem/View/SqliteDataView.xaml
  48. +1
    -1
      FryPot_DosingSystem/ViewModel/RecipeSetViewModel.cs
  49. +1
    -1
      SCADA.Test/MainWindow.xaml.cs
  50. +1
    -0
      SCADA.Test/SCADA.Test.csproj

+ 2
- 0
BPASmartClient.Compiler/BPASmartClient.Compiler.csproj View File

@@ -10,6 +10,8 @@
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.3.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.3.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="ServiceStack.Redis" Version="6.3.0" />
<PackageReference Include="StackExchange.Redis" Version="2.6.66" />
</ItemGroup>

<ItemGroup>


+ 68
- 0
BPASmartClient.Compiler/FJson.cs View File

@@ -0,0 +1,68 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.Compiler
{
public class FJson<T> where T : class, new()
{
private static string path
{
get
{
Directory.CreateDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"AccessFile\\JSON"));
return AppDomain.CurrentDomain.BaseDirectory + "AccessFile\\JSON\\" + typeof(T).Name + ".json";
}
}

public static T Data
{
get;
set;
} = new T();


public static void Save()
{
string contents = JsonConvert.SerializeObject(Data);
File.WriteAllText(path,contents);
}

public static void Read()
{
if (File.Exists(path))
{
T val = JsonConvert.DeserializeObject<T>(File.ReadAllText(path));
if (val != null)
{
Data = val;
}
}
}

public static void SaveInterface()
{
JsonSerializerSettings jsonSerializerSettings = new JsonSerializerSettings();
jsonSerializerSettings.TypeNameHandling = TypeNameHandling.Objects;
string contents = JsonConvert.SerializeObject(Data,Formatting.Indented,jsonSerializerSettings);
File.WriteAllText(path,contents);
}

public static void ReadInterface()
{
if (File.Exists(path))
{
JsonSerializerSettings jsonSerializerSettings = new JsonSerializerSettings();
jsonSerializerSettings.TypeNameHandling = TypeNameHandling.Objects;
T val = JsonConvert.DeserializeObject<T>(File.ReadAllText(path),jsonSerializerSettings);
if (val != null)
{
Data = val;
}
}
}
}
}

+ 170
- 0
BPASmartClient.Compiler/FRedisClient.cs View File

@@ -0,0 +1,170 @@
using StackExchange.Redis;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace BPASmartClient.Compiler
{
public class FRedisClient
{
#region 单例模式
//private static FRedisClient instance = null;
//public static FRedisClient Instance()
//{
// if (instance == null) instance = new FRedisClient();
// return instance;
//}
#endregion

#region 变量
/// <summary>
/// IP地址
/// </summary>
public string redisconnection = "124.222.238.75:16000,password=123456";
/// <summary>
/// redis 连接状态
/// </summary>
public ConnectionMultiplexer _connection = null;
/// <summary>
/// 数据存储位置
/// </summary>
public IDatabase _database = null;
/// <summary>
/// 通道建立连接
/// </summary>
public ISubscriber subscibe = null;
#endregion

#region 外部访问
/// <summary>
/// 委托出去
/// </summary>
public Action<string,string> LogMeaage = null;
#endregion

public void Connect()
{
_connection = ConnectionMultiplexer.Connect(ConfigurationOptions.Parse(redisconnection));
_database = _connection.GetDatabase(0);//默认使用db0
subscibe = _connection.GetSubscriber();
}
public void Connect(string connection)
{
_connection = ConnectionMultiplexer.Connect(ConfigurationOptions.Parse(connection));
if (connection.Contains("defaultDatabase="))
{
string[] str=connection.Split(',');
string stro = str.ToList().Find(s => s.Contains("defaultDatabase="));
int dbi = 0;
try
{
dbi=int.Parse(stro.Replace("defaultDatabase=",""));
}
catch (Exception ex)
{

throw;
}
_database = _connection.GetDatabase(dbi);//默认使用db0
}
else
{
_database = _connection.GetDatabase();//默认使用db0
}
subscibe = _connection.GetSubscriber();
}

/// <summary>
/// 获取设备列表
/// </summary>
/// <returns></returns>
public Dictionary<string,string> GetKeys()
{
Dictionary<string,string> keys = new Dictionary<string,string>();
foreach (var endPoint in _connection.GetEndPoints())
{
//获取指定服务器
var server = _connection.GetServer(endPoint);
//在指定服务器上使用 keys 或者 scan 命令来遍历key
foreach (var key in server.Keys(0,"设备列表:*"))
{
//获取key对于的值
var val = _database.StringGet(key);
Console.WriteLine($"key: {key}, value: {val}");
keys[key] = val;
}
}
return keys;
}

/// <summary>
/// 订阅通道消息
/// </summary>
public void SubscribeChanne(string channelname)
{
if (subscibe == null) return;
subscibe.Subscribe(channelname,(channel,message) =>
{
MessageLog(channel,message);
});
}

/// <summary>
/// 发布通道消息
/// </summary>
public void PublishChanne(string channelname,string value)
{
if (subscibe == null) return;
subscibe.Publish(channelname,value);
}

/// <summary>
/// 获取 key 值
/// </summary>
public RedisValue RedisGet(string key,string hashField = "")
{
if (_database == null) return new RedisValue();
RedisValue result;
if (string.IsNullOrEmpty(hashField))
{
result = _database.StringGet(key);
}
else
{
result = _database.HashGet(key,hashField);
}
return result;
//MessageLog(key,result);
}
/// <summary>
/// 设置 redis 的值
/// </summary>
public bool RedisSet(string key,string hashField,string value)
{
bool result;
if (string.IsNullOrEmpty(hashField))
{
result = _database.StringSet(key,value);
}
else
{
result = _database.HashSet(key,hashField,value);
}
return result;
}

/// <summary>
/// 消息打印
/// </summary>
private void MessageLog(string key,string msg)
{
if (LogMeaage != null)
{
LogMeaage.Invoke(key,msg);
}
}
}
}

+ 69
- 0
BPASmartClient.Compiler/RedisHelper.cs View File

@@ -0,0 +1,69 @@
using ServiceStack.Redis;
using System.Diagnostics;

namespace BPASmartClient.Compiler
{
public class RedisHelper
{

private volatile static RedisHelper _Instance;
public static RedisHelper GetInstance => _Instance ?? (_Instance = new RedisHelper());
private RedisHelper() { }
RedisClient client;

public async Task<bool> ConnectAsync(string redisconnection)
{
return await Task.Factory.StartNew(new Func<bool>(() =>
{
if (client == null)
{
//"124.222.238.75:16000,password=123456";
client = new RedisClient("124.222.238.75",16000,"123456",1);
client.ConnectTimeout = 5000;
Stopwatch sw = new Stopwatch();
sw.Start();
while (!client.IsSocketConnected())
{
if (sw.ElapsedMilliseconds >= client.ConnectTimeout) break;
Thread.Sleep(1000);
}
string status = client.IsSocketConnected() ? "成功" : "失败";
}
return client.IsSocketConnected();
}));

}

/// <summary>
/// 清除所有redis 数据
/// </summary>
public void FlushDb()
{
client?.FlushDb();
}

/// <summary>
/// 设置值
/// </summary>
/// <typeparam name="TValue"></typeparam>
/// <param name="key"></param>
/// <param name="value"></param>
public void SetValue<TValue>(string key,TValue value)
{
var res = client?.Set<TValue>(key,value);
}

/// <summary>
/// 获取值
/// </summary>
/// <typeparam name="TResult"></typeparam>
/// <param name="key"></param>
/// <returns></returns>
public TResult GetValue<TResult>(string key)
{
if (client == null) return default(TResult);
return client.Get<TResult>(key);
}

}
}

+ 1
- 1
BPASmartClient.CustomResource/Pages/View/MainView.xaml View File

@@ -517,7 +517,7 @@
</Grid.RowDefinitions>
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
<CheckBox
Margin="5,0,5,0"
Margin="5,0,8,0"
Content="开机启动"
IsChecked="{Binding AutoStart}"
Style="{StaticResource checkBoxStyle}" />


+ 3
- 0
BPASmartClient.CustomResource/Pages/ViewModel/AlarmViewModel.cs View File

@@ -65,6 +65,9 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel
return;
}
});

//AlarmInfos = AlarmHelper<AlarmInfo>.Alarms;

}

private void GetHistoryAlarm()


+ 1
- 1
BPASmartClient.CustomResource/Pages/ViewModel/MainViewModel.cs View File

@@ -45,7 +45,7 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel

private void DoNavChanged(object obj)
{
ActionManage.GetInstance.Send("RecipeIsChange");

if (obj != null && obj is SubMenumodel menumodel)
{


+ 1
- 1
BPASmartClient.DATABUS/Class_DataBus.cs View File

@@ -28,7 +28,7 @@ namespace BPASmartClient.DATABUS
/// <summary>
/// 设备数据
/// </summary>
public ConcurrentDictionary<string, object> Dic_DeviceData = new ConcurrentDictionary<string, object>(); //原始目标链表
public ConcurrentDictionary<string, Dictionary<string,object>> Dic_DeviceData = new ConcurrentDictionary<string,Dictionary<string,object>>(); //原始目标链表
#endregion
}
}

+ 4
- 0
BPASmartClient.MessageName/EnumHelp/DataTypeEnum.cs View File

@@ -20,6 +20,10 @@ namespace BPASmartClient.MessageName.EnumHelp
/// </summary>
MQTT,
/// <summary>
/// Redis拉取数据
/// </summary>
Redis,
/// <summary>
/// 本地数据推送
/// </summary>
本地源,


+ 75
- 11
BPASmartClient.SCADAControl/BPASmartClient.SCADAControl.csproj View File

@@ -9,9 +9,19 @@

<ItemGroup>
<None Remove="Fonts\ds-digib.ttf" />
<None Remove="Images\2609.png" />
<None Remove="Images\biogebj.png" />
<None Remove="Images\bj.png" />
<None Remove="Images\btn_normal.png" />
<None Remove="Images\button1.png" />
<None Remove="Images\button2.png" />
<None Remove="Images\Cb_Checked.png" />
<None Remove="Images\Cb_HalfChecked.png" />
<None Remove="Images\databj.png" />
<None Remove="Images\nbbj.png" />
<None Remove="Images\redis.png" />
<None Remove="Images\redisrun.png" />
<None Remove="Images\redisstop.png" />
<None Remove="Images\State0.png" />
<None Remove="Images\State1.png" />
<None Remove="Images\State11.png" />
@@ -29,7 +39,9 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\BPASmart.Model\BPASmart.Model.csproj" />
<ProjectReference Include="..\BPASmartClient.Compiler\BPASmartClient.Compiler.csproj" />
<ProjectReference Include="..\BPASmartClient.DATABUS\BPASmartClient.DATABUS.csproj" />
<ProjectReference Include="..\BPASmartClient.MessageCommunication\BPASmartClient.MessageCommunication.csproj" />
<ProjectReference Include="..\BPASmartClient.MessageName\BPASmartClient.MessageName.csproj" />
</ItemGroup>
@@ -45,17 +57,69 @@

<ItemGroup>
<Resource Include="Fonts\ds-digib.ttf" />
<Resource Include="Images\bj.png" />
<Resource Include="Images\databj.png" />
<Resource Include="Images\State0.png" />
<Resource Include="Images\State1.png" />
<Resource Include="Images\State11.png" />
<Resource Include="Images\State2.png" />
<Resource Include="Images\timericon.png" />
<Resource Include="Images\借出.png" />
<Resource Include="Images\光柱.png" />
<Resource Include="Images\biogebj.png" />
<Resource Include="Images\退出.png" />
<Resource Include="Images\2609.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\bj.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\btn_normal.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\Cb_Checked.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\Cb_HalfChecked.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\databj.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\nbbj.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\redis.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\redisrun.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\redisstop.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\State0.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\State1.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\State11.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\State2.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\timericon.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\借出.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\光柱.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\biogebj.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\button1.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\button2.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Images\退出.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
</ItemGroup>

</Project>

+ 173
- 0
BPASmartClient.SCADAControl/Converters/RelayCommandSimple.cs View File

@@ -0,0 +1,173 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
namespace BPASmartClient.SCADAControl.Converters
{
public class RelayCommandSimple :ICommand, IDisposable
{
private Action _executeCallback;
private Func<bool> _canExecute;

public RelayCommandSimple(Action execute)
{
_executeCallback = execute;
}

public RelayCommandSimple(Action execute,Func<bool> canExecute)
: this(execute)
{
_canExecute = canExecute;
}

public bool CanExecute(object parameter)
{
if (_canExecute == null)
return true;
return _canExecute();
}

public void Execute(object parameter)
{
_executeCallback();
}

public void Dispose()
{
_executeCallback = null;
_canExecute = null;
}

public event EventHandler CanExecuteChanged
{
add
{
if (this._canExecute != null)
{
CommandManager.RequerySuggested += value;
}
}
remove
{
if (this._canExecute != null)
{
CommandManager.RequerySuggested -= value;
}
}
}
}

public class RelayCommandSimple<TParam> :ICommand
{
private Action<TParam> _executeCallback;
private Func<TParam,bool> _canExecute;

public RelayCommandSimple(Action<TParam> execute)
{
if (execute == null)
throw new ArgumentNullException("execute");

_executeCallback = execute;
}

public RelayCommandSimple(Action<TParam> execute,Func<TParam,bool> canExecute)
: this(execute)
{
_canExecute = canExecute;
}

public bool CanExecute(object parameter)
{
if (_canExecute == null)
return true;

if (parameter != null && parameter is TParam)
{
return _canExecute((TParam)parameter);
}
return true;
}

public void Execute(object parameter)
{
if (parameter != null && parameter is TParam)
{
_executeCallback((TParam)parameter);
}
}

public event EventHandler CanExecuteChanged
{
add
{
if (this._canExecute != null)
{
CommandManager.RequerySuggested += value;
}
}
remove
{
if (this._canExecute != null)
{
CommandManager.RequerySuggested -= value;
}
}
}
}


public class RelayCommandSimpleNull<T> :ICommand
{
private Action<T> _executeCallback;
private Func<T,bool> _canExecute;

public RelayCommandSimpleNull(Action<T> execute)
{
if (execute == null)
throw new ArgumentNullException("execute");

_executeCallback = execute;
}

public RelayCommandSimpleNull(Action<T> execute,Func<T,bool> canExecute)
: this(execute)
{
_canExecute = canExecute;
}

public bool CanExecute(object parameter)
{
if (_canExecute == null)
return true;


return _canExecute((T)parameter);

}

public void Execute(object parameter)
{
_executeCallback((T)parameter);
}

public event EventHandler CanExecuteChanged
{
add
{
if (this._canExecute != null)
{
CommandManager.RequerySuggested += value;
}
}
remove
{
if (this._canExecute != null)
{
CommandManager.RequerySuggested -= value;
}
}
}
}
}

+ 59
- 0
BPASmartClient.SCADAControl/Converters/Style3ArcConverter.cs View File

@@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows.Media;
namespace BPASmartClient.SCADAControl.Converters
{
public class Style3ArcConverter :IMultiValueConverter
{
public object Convert(object[] values,Type targetType,object parameter,CultureInfo culture)
{
double value = (double)values[0];
double thickness = (double)values[1];

double radius = 40;

double 周长 = Math.PI * (2 * radius - thickness) / thickness;

double showPrecent = value / 100 * 周长;

var converter = TypeDescriptor.GetConverter(typeof(DoubleCollection));

return (DoubleCollection)converter.ConvertFrom($"{showPrecent} {周长}");
}

public object[] ConvertBack(object value,Type[] targetTypes,object parameter,CultureInfo culture)
{
throw new NotImplementedException();
}
}

public class Style3DashConverter :IValueConverter
{
public object Convert(object value,Type targetType,object parameter,CultureInfo culture)
{
double v = (double)value;

if (v == 0)
{
return PenLineCap.Flat;
}
else
{
return PenLineCap.Round;
}

}

public object ConvertBack(object value,Type targetType,object parameter,CultureInfo culture)
{
throw new NotImplementedException();
}
}

}

+ 6
- 3
BPASmartClient.SCADAControl/CustomerControls/NumberBox.cs View File

@@ -45,10 +45,13 @@ namespace BPASmartClient.SCADAControl.CustomerControls
Height = 30;
CurValue = 0.01;
Digits = 2;
FontSize = 16;
VerticalContentAlignment = VerticalAlignment.Center;
Style = Application.Current.Resources["DesignNumberBox"] as Style;//FindResource("DesignNumberBox") as Style;
ResourceDictionary languageResDic = new ResourceDictionary();
languageResDic.Source = new Uri(@"/BPASmartClient.SCADAControl;component/Themes/Generic.xaml",UriKind.RelativeOrAbsolute);
this.Resources.MergedDictionaries.Add(languageResDic);

//Style = Application.Current.Resources["DesignNumberBox"] as Style;//FindResource("DesignNumberBox") as Style;

this.TextChanged += NumberBox_TextChanged;
this.PreviewKeyDown += NumberBox_KeyDown;


+ 0
- 1
BPASmartClient.SCADAControl/CustomerControls/Silos.xaml View File

@@ -74,7 +74,6 @@
<StackPanel Tag="ControlEvent" HorizontalAlignment="Right" Orientation="Vertical" Grid.Row="1" VerticalAlignment="Bottom" >
<Image Margin="20,10,0,0" Tag="出料" Source="/BPASmartClient.SCADAControl;component/Images/借出.png" Cursor="Hand" ToolTip="出料" Width="24" ></Image>
<Image Margin="20,10,0,10" Tag="停止出料" Source="/BPASmartClient.SCADAControl;component/Images/退出.png" Cursor="Hand" Width="24" ToolTip="停止出料"></Image>
</StackPanel>
</Grid>
</UserControl>

+ 88
- 18
BPASmartClient.SCADAControl/CustomerControls/Silos.xaml.cs View File

@@ -1,4 +1,5 @@
using BPASmartClient.Compiler;
using BPASmartClient.DATABUS;
using BPASmartClient.MessageCommunication;
using BPASmartClient.MessageCommunication.MsgControl;
using BPASmartClient.MessageName;
@@ -14,6 +15,7 @@ using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Drawing.Design;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
@@ -26,6 +28,7 @@ using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;

namespace BPASmartClient.SCADAControl.CustomerControls
{
@@ -33,7 +36,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls
/// Silos.xaml 的交互逻辑
/// 物料仓
/// </summary>
public partial class Silos :UserControl, IExecutable
public partial class Silos :UserControl, IExecutable, IDisposable
{
#region 临时变量
TextBlock textBlockCLKZ = null;
@@ -317,14 +320,14 @@ namespace BPASmartClient.SCADAControl.CustomerControls

#region 数据绑定模块
public event EventHandler PropertyChange; //声明一个事件
[Category("数据绑定-数据来源")]
public DataTypeEnum DataSouceType
{
get { return (DataTypeEnum)GetValue(DataSouceTypeProperty); }
set { SetValue(DataSouceTypeProperty,value); }
}
public static readonly DependencyProperty DataSouceTypeProperty =
DependencyProperty.Register("DataSouceType",typeof(DataTypeEnum),typeof(Silos),new PropertyMetadata(DataTypeEnum.静态数据));
//[Category("数据绑定-数据来源")]
//public DataTypeEnum DataSouceType
//{
// get { return (DataTypeEnum)GetValue(DataSouceTypeProperty); }
// set { SetValue(DataSouceTypeProperty,value); }
//}
//public static readonly DependencyProperty DataSouceTypeProperty =
// DependencyProperty.Register("DataSouceType",typeof(DataTypeEnum),typeof(Silos),new PropertyMetadata(DataTypeEnum.静态数据));
[Category("数据绑定-数据来源")]
public int TimeCount
{
@@ -333,14 +336,30 @@ namespace BPASmartClient.SCADAControl.CustomerControls
}
public static readonly DependencyProperty TimeCountProperty =
DependencyProperty.Register("TimeCount",typeof(int),typeof(Silos),new PropertyMetadata(5));
[Category("数据绑定-数据来源")]
public string DataSouceInformation
{
get { return (string)GetValue(DataSouceInformationProperty); }
set { SetValue(DataSouceInformationProperty,value); }
}
public static readonly DependencyProperty DataSouceInformationProperty =
DependencyProperty.Register("DataSouceInformation",typeof(string),typeof(Silos),new PropertyMetadata(string.Empty));
//[Category("数据绑定-数据来源")]
//public string DataSouceInformation
//{
// get { return (string)GetValue(DataSouceInformationProperty); }
// set { SetValue(DataSouceInformationProperty,value); }
//}
//public static readonly DependencyProperty DataSouceInformationProperty =
// DependencyProperty.Register("DataSouceInformation",typeof(string),typeof(Silos),new PropertyMetadata(string.Empty));
//[Category("数据绑定-数据来源")]
//public string DeviceName
//{
// get { return (string)GetValue(DeviceNameProperty); }
// set { SetValue(DeviceNameProperty,value); }
//}
//public static readonly DependencyProperty DeviceNameProperty =
// DependencyProperty.Register("DeviceName",typeof(string),typeof(Silos),new PropertyMetadata(string.Empty));
//[Category("数据绑定-数据来源")]
//public string DeviceValuleName
//{
// get { return (string)GetValue(DeviceValuleNameProperty); }
// set { SetValue(DeviceValuleNameProperty,value); }
//}
//public static readonly DependencyProperty DeviceValuleNameProperty =
// DependencyProperty.Register("DeviceValuleName",typeof(string),typeof(Silos),new PropertyMetadata(string.Empty));

[Category("数据绑定")]
public string FDataSouce
@@ -369,7 +388,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls

}
}
public static string _code = " public string main(string message) \n { \n //请在此填写你的代码\n\n return message; \n }\n";
public static string _code = "public string main(string message) \n{ \n //请在此填写你的代码\n\n return message; \n}\n";
[Category("数据绑定")]
public string Code
{
@@ -486,6 +505,8 @@ namespace BPASmartClient.SCADAControl.CustomerControls
#endregion

#region 运行事件
DispatcherTimer timer = new DispatcherTimer();
Dictionary<string, string> propertyBing = new Dictionary<string,string>();
List<string> MessageNameL = null;
public void Register()
{
@@ -500,6 +521,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls

}
}

if (!string.IsNullOrEmpty(EventSendNameListStr))
{
try
@@ -520,7 +542,50 @@ namespace BPASmartClient.SCADAControl.CustomerControls
MessageNameL = MessageNameNew;
}

PropertyInfo[] propertyInfos = this.GetType().GetProperties();
foreach (PropertyInfo propertyInfo in propertyInfos)
{
var propName = propertyInfo?.GetValue(this,null);
if (propName is string && propName != null && propName.ToString().Contains("Binding ") && propName.ToString().Contains("."))
{
propertyBing[propertyInfo.Name] = propName.ToString();
}
}

timer.Interval = TimeSpan.FromMilliseconds(TimeCount);
timer.Tick += Timer_Tick; ;
timer.Start();

}

private void Timer_Tick(object? sender,EventArgs e)
{
try
{
foreach (var item in propertyBing)
{
//{Binding 测试设备.VAR_A_2}
string[] str= item.Value.Replace("{Binding ","").Replace("}","").Split(".");
if (str.Length > 1)
{
if (Class_DataBus.GetInstance().Dic_DeviceData.ContainsKey(str[0]))
{
Dictionary<string,object> b= Class_DataBus.GetInstance().Dic_DeviceData[str[0]];
if (b!=null && b.ContainsKey(str[1]))
{
object _value = b[str[1]];
this.GetType().GetProperty(item.Key).SetValue(this,_value);
}
}
}
}
}
catch (Exception ex)
{

}
}

/// <summary>
/// 统一事件消息处理中心
/// </summary>
@@ -564,6 +629,11 @@ namespace BPASmartClient.SCADAControl.CustomerControls
#endregion

#region 发送消息事件
public void Dispose()
{
timer.Stop();
}

/// <summary>
/// 按钮按下
/// </summary>


+ 63
- 0
BPASmartClient.SCADAControl/CustomerControls/TheBlueProgressBar.cs View File

@@ -0,0 +1,63 @@
using BPASmartClient.Compiler;
using BPASmartClient.SCADAControl;
using System;
using System.Collections.Generic;
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.Navigation;
using System.Windows.Shapes;
namespace BPASmartClient.SCADAControl.CustomerControls
{
public class TheBlueProgressBar :ProgressBar, IExecutable, IDisposable
{
public event EventHandler PropertyChange; //声明一个事件

public TheBlueProgressBar()
{
ResourceDictionary languageResDic = new ResourceDictionary();
languageResDic.Source = new Uri(@"/BPASmartClient.SCADAControl;component/Themes/Generic.xaml",UriKind.RelativeOrAbsolute);
this.Resources.MergedDictionaries.Add(languageResDic);
SetCurrentValue(WidthProperty,100d);
SetCurrentValue(HeightProperty,100d);
SetCurrentValue(ValueProperty,50d);
}
static TheBlueProgressBar()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(TheBlueProgressBar),new FrameworkPropertyMetadata(typeof(TheBlueProgressBar)));
}

public string ControlType => "控件";

private bool isExecuteState;
public bool IsExecuteState
{
get { return isExecuteState; }
set
{
isExecuteState = value;
if (IsExecuteState)
{
Register();
Style = null;
}
}
}

public void Register()
{

}

public void Dispose()
{
}
}
}

+ 75
- 7
BPASmartClient.SCADAControl/CustomerControls/TheButton.xaml.cs View File

@@ -1,8 +1,10 @@
using BPASmartClient.Compiler;
using BPASmartClient.DATABUS;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
@@ -14,6 +16,7 @@ using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;

namespace BPASmartClient.SCADAControl.CustomerControls
{
@@ -23,15 +26,15 @@ namespace BPASmartClient.SCADAControl.CustomerControls
/// </summary>
public partial class TheButton : Button, IExecutable
{
public event EventHandler PropertyChange; //声明一个事件

public TheButton()
{
InitializeComponent();
ResourceDictionary languageResDic = new ResourceDictionary();
languageResDic.Source = new Uri(@"/BPASmartClient.SCADAControl;component/Themes/Generic.xaml",UriKind.RelativeOrAbsolute);
this.Resources.MergedDictionaries.Add(languageResDic);
Content = "按钮";
Width = 80;
Height = 30;
Style = Application.Current.Resources["DesignButton"] as Style;//FindResource("DesignButton") as Style;
}

public string ControlType => "控件";
@@ -60,17 +63,82 @@ namespace BPASmartClient.SCADAControl.CustomerControls
public static readonly DependencyProperty ClickExecProperty =
DependencyProperty.Register("ClickExec", typeof(string), typeof(TheButton), new PropertyMetadata(string.Empty));


private void MyButton_Click(object sender, RoutedEventArgs e)
{
Config.GetInstance().RunJsScipt(ClickExec);
}

#region 数据绑定模块
[Category("数据绑定-数据来源")]
public int TimeCount
{
get { return (int)GetValue(TimeCountProperty); }
set { SetValue(TimeCountProperty,value); }
}
public static readonly DependencyProperty TimeCountProperty =
DependencyProperty.Register("TimeCount",typeof(int),typeof(TheButton),new PropertyMetadata(5));
public event EventHandler PropertyChange; //声明一个事件
/// <summary>
/// 属性刷新器
/// </summary>
DispatcherTimer timer = new DispatcherTimer();
/// <summary>
/// 属性绑定变量集合
/// </summary>
Dictionary<string,string> propertyBing = new Dictionary<string,string>();
/// <summary>
/// 注册需要处理的事件
/// 运行事件
/// </summary>
public void Register()
{
this.Click += MyButton_Click;
}
PropertyInfo[] propertyInfos = this.GetType().GetProperties();
foreach (PropertyInfo propertyInfo in propertyInfos)
{
var propName = propertyInfo?.GetValue(this,null);
if (propName is string && propName != null && propName.ToString().Contains("Binding ") && propName.ToString().Contains("."))
{
propertyBing[propertyInfo.Name] = propName.ToString();
}
}

private void MyButton_Click(object sender, RoutedEventArgs e)
timer.Interval = TimeSpan.FromMilliseconds(TimeCount);
timer.Tick += Timer_Tick; ;
timer.Start();
}
/// <summary>
/// 属性刷新事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Timer_Tick(object? sender,EventArgs e)
{
Config.GetInstance().RunJsScipt(ClickExec);
try
{
foreach (var item in propertyBing)
{
//{Binding 测试设备.VAR_A_2}
string[] str = item.Value.Replace("{Binding ","").Replace("}","").Split(".");
if (str.Length > 1)
{
if (Class_DataBus.GetInstance().Dic_DeviceData.ContainsKey(str[0]))
{
Dictionary<string,object> b = Class_DataBus.GetInstance().Dic_DeviceData[str[0]];
if (b != null && b.ContainsKey(str[1]))
{
object _value = b[str[1]];
this.GetType().GetProperty(item.Key).SetValue(this,_value);
}
}
}
}
}
catch (Exception ex)
{

}
}
#endregion
}
}

+ 7
- 0
BPASmartClient.SCADAControl/CustomerControls/TheCheckBox.xaml View File

@@ -6,4 +6,11 @@
xmlns:local="clr-namespace:BPASmartClient.SCADAControl.CustomerControls"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<CheckBox.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/BPASmartClient.SCADAControl;component/Themes/Generic.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</CheckBox.Resources>
</CheckBox>

+ 5
- 2
BPASmartClient.SCADAControl/CustomerControls/TheComboBox.xaml.cs View File

@@ -28,9 +28,12 @@ namespace BPASmartClient.SCADAControl.CustomerControls
public TheComboBox()
{
InitializeComponent();
VerticalContentAlignment = VerticalAlignment.Center;
ResourceDictionary languageResDic = new ResourceDictionary();
languageResDic.Source = new Uri(@"/BPASmartClient.SCADAControl;component/Themes/Generic.xaml",UriKind.RelativeOrAbsolute);
this.Resources.MergedDictionaries.Add(languageResDic);
//VerticalContentAlignment = VerticalAlignment.Center;
ItemsString = new ItemsList() { "AA", "BB" };
Style = Application.Current.Resources["DesignComboBox"] as Style;
//Style = Application.Current.Resources["DesignComboBox"] as Style;
Width = 80;
Height = 30;
Focusable = false;


+ 64
- 0
BPASmartClient.SCADAControl/CustomerControls/TheGreenProgressBar.cs View File

@@ -0,0 +1,64 @@
using BPASmartClient.Compiler;
using BPASmartClient.SCADAControl;
using System;
using System.Collections.Generic;
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.Navigation;
using System.Windows.Shapes;

namespace BPASmartClient.SCADAControl.CustomerControls
{
public class TheGreenProgressBar :ProgressBar, IExecutable, IDisposable
{
public event EventHandler PropertyChange; //声明一个事件

public TheGreenProgressBar()
{
ResourceDictionary languageResDic = new ResourceDictionary();
languageResDic.Source = new Uri(@"/BPASmartClient.SCADAControl;component/Themes/Generic.xaml",UriKind.RelativeOrAbsolute);
this.Resources.MergedDictionaries.Add(languageResDic);
SetCurrentValue(WidthProperty,100d);
SetCurrentValue(HeightProperty,100d);
SetCurrentValue(ValueProperty,50d);
}
static TheGreenProgressBar()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(TheGreenProgressBar),new FrameworkPropertyMetadata(typeof(TheGreenProgressBar)));
}

public string ControlType => "控件";

private bool isExecuteState;
public bool IsExecuteState
{
get { return isExecuteState; }
set
{
isExecuteState = value;
if (IsExecuteState)
{
Register();
Style = null;
}
}
}

public void Register()
{

}

public void Dispose()
{
}
}
}

+ 3
- 0
BPASmartClient.SCADAControl/CustomerControls/TheGroupBox.xaml.cs View File

@@ -27,6 +27,9 @@ namespace BPASmartClient.SCADAControl.CustomerControls
public TheGroupBox()
{
InitializeComponent();
ResourceDictionary languageResDic = new ResourceDictionary();
languageResDic.Source = new Uri(@"/BPASmartClient.SCADAControl;component/Themes/Generic.xaml",UriKind.RelativeOrAbsolute);
this.Resources.MergedDictionaries.Add(languageResDic);
Width = 150;
Height = 150;
Header = "分组";


BPASmartClient.SCADAControl/CustomerControls/TheTextBlock.xaml.cs → BPASmartClient.SCADAControl/CustomerControls/TheProgressBar.cs View File

@@ -18,16 +18,24 @@ using System.Windows.Shapes;
namespace BPASmartClient.SCADAControl.CustomerControls
{
/// <summary>
/// TheTextBlock.xaml 的交互逻辑
/// 正常进度条
/// </summary>
public partial class TheTextBlock : TextBlock, IExecutable
public class TheProgressBar:ProgressBar, IExecutable, IDisposable
{
public event EventHandler PropertyChange; //声明一个事件

public TheTextBlock()
public TheProgressBar()
{
InitializeComponent();
Text = "文本块";
ResourceDictionary languageResDic = new ResourceDictionary();
languageResDic.Source = new Uri(@"/BPASmartClient.SCADAControl;component/Themes/Generic.xaml",UriKind.RelativeOrAbsolute);
this.Resources.MergedDictionaries.Add(languageResDic);
SetCurrentValue(WidthProperty,200d);
SetCurrentValue(HeightProperty,16d);
SetCurrentValue(ValueProperty,50d);
}
static TheProgressBar()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(TheProgressBar),new FrameworkPropertyMetadata(typeof(TheProgressBar)));
}

public string ControlType => "控件";
@@ -42,12 +50,18 @@ namespace BPASmartClient.SCADAControl.CustomerControls
if (IsExecuteState)
{
Register();
Style = null;
}
}
}

public void Register()
{

}

public void Dispose()
{
}
}
}

+ 3
- 0
BPASmartClient.SCADAControl/CustomerControls/TheRadioButton.cs View File

@@ -23,6 +23,9 @@ namespace BPASmartClient.SCADAControl.CustomerControls

public TheRadioButton()
{
ResourceDictionary languageResDic = new ResourceDictionary();
languageResDic.Source = new Uri(@"/BPASmartClient.SCADAControl;component/Themes/Generic.xaml",UriKind.RelativeOrAbsolute);
this.Resources.MergedDictionaries.Add(languageResDic);
SetCurrentValue(ContentProperty, "单选按钮");
}
static TheRadioButton()


+ 64
- 0
BPASmartClient.SCADAControl/CustomerControls/TheRedProgressBar.cs View File

@@ -0,0 +1,64 @@
using BPASmartClient.Compiler;
using BPASmartClient.SCADAControl;
using System;
using System.Collections.Generic;
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.Navigation;
using System.Windows.Shapes;

namespace BPASmartClient.SCADAControl.CustomerControls
{
public class TheRedProgressBar :ProgressBar, IExecutable, IDisposable
{
public event EventHandler PropertyChange; //声明一个事件

public TheRedProgressBar()
{
ResourceDictionary languageResDic = new ResourceDictionary();
languageResDic.Source = new Uri(@"/BPASmartClient.SCADAControl;component/Themes/Generic.xaml",UriKind.RelativeOrAbsolute);
this.Resources.MergedDictionaries.Add(languageResDic);
SetCurrentValue(WidthProperty,100d);
SetCurrentValue(HeightProperty,100d);
SetCurrentValue(ValueProperty,50d);
}
static TheRedProgressBar()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(TheRedProgressBar),new FrameworkPropertyMetadata(typeof(TheRedProgressBar)));
}

public string ControlType => "控件";

private bool isExecuteState;
public bool IsExecuteState
{
get { return isExecuteState; }
set
{
isExecuteState = value;
if (IsExecuteState)
{
Register();
Style = null;
}
}
}

public void Register()
{

}

public void Dispose()
{
}
}
}

+ 15
- 0
BPASmartClient.SCADAControl/CustomerControls/TheRedis.xaml View File

@@ -0,0 +1,15 @@
<UserControl x:Class="BPASmartClient.SCADAControl.CustomerControls.TheRedis"
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:BPASmartClient.SCADAControl.CustomerControls"
mc:Ignorable="d"
d:DesignHeight="40" d:DesignWidth="40" >
<Grid>
<Image Source="../Images/redis.png" Tag="正常" Visibility="Visible"/>
<Image Source="../Images/redisrun.png" Tag="运行" Visibility="Collapsed"/>
<Image Source="../Images/redisstop.png" Tag="故障" Visibility="Collapsed"/>
<TextBlock HorizontalAlignment="Center" Tag="显示文字" VerticalAlignment="Bottom" Foreground="#FF02F9FF" Margin="0,0,0,-8">未运行</TextBlock>
</Grid>
</UserControl>

+ 319
- 0
BPASmartClient.SCADAControl/CustomerControls/TheRedis.xaml.cs View File

@@ -0,0 +1,319 @@
using BPASmart.Model;
using BPASmartClient.Compiler;
using BPASmartClient.DATABUS;
using BPASmartClient.MessageName.EnumHelp;
using BPASmartClient.SCADAControl;
using Newtonsoft.Json;
using StackExchange.Redis;
using System;
using System.Collections.Generic;
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.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;

namespace BPASmartClient.SCADAControl.CustomerControls
{
/// <summary>
/// TheRedis.xaml 的交互逻辑
/// </summary>
public partial class TheRedis :UserControl, IExecutable, IDisposable
{
Image imageZC = null;
Image imageYC = null;
Image imageGZ = null;
TextBlock textBlock = null;
FRedisClient fRedisClient = new FRedisClient();
public TheRedis()
{
InitializeComponent();
Width = 40;
Height = 40;
this.SizeChanged += TheRedis_SizeChanged;
}
private void TheRedis_SizeChanged(object sender,SizeChangedEventArgs e)
{
if (textBlock == null)
{
foreach (Image tb in FindVisualChildren<Image>(this))
{
// do something with tb here
if (tb.Tag != null)
{
if (tb.Tag.ToString() == "正常")
{
imageZC = tb;
}

if (tb.Tag.ToString() == "运行")
{
imageYC = tb;
}

if (tb.Tag.ToString() == "故障")
{
imageGZ = tb;
}
}
}

foreach (TextBlock tb in FindVisualChildren<TextBlock>(this))
{
// do something with tb here
if (tb.Tag != null)
{
if (tb.Tag.ToString() == "显示文字")
{
textBlock = tb;
}
}
}
}
}
public static IEnumerable<T> FindVisualChildren<T>(DependencyObject depObj) where T : DependencyObject
{
if (depObj != null)
{
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(depObj); i++)
{
DependencyObject child = VisualTreeHelper.GetChild(depObj,i);
if (child != null && child is T)
{
yield return (T)child;
}

foreach (T childOfChild in FindVisualChildren<T>(child))
{
yield return childOfChild;
}
}
}
}
public string ControlType => "控件";
private bool isExecuteState;
public bool IsExecuteState
{
get { return isExecuteState; }
set
{
isExecuteState = value;
if (IsExecuteState)
{
Register();
Style = null;
}
}
}

DispatcherTimer timer = new DispatcherTimer();
public void Register()
{
if (Direction == 0)
{
try
{
if (!string.IsNullOrEmpty(DataSouceInformation))
fRedisClient.Connect(DataSouceInformation);

}
catch (Exception ex)
{
Direction = 2;
}
}
timer.Interval = TimeSpan.FromSeconds(TimeCount);
timer.Tick += Timer_Tick;
timer.Start();

}
Task<bool> isSuccess;
private async void Timer_Tick(object sender,EventArgs e)
{
Config.GetInstance().RunJsScipt(TikcExecute);
if (fRedisClient._connection != null && fRedisClient._connection.IsConnected)
{
Direction = 1;
}
else
{
Direction = 0;
try
{
if (!string.IsNullOrEmpty(DataSouceInformation))
fRedisClient.Connect(DataSouceInformation);
}
catch (Exception ex)
{
Direction = 2;
}
}
if (Direction == 1) //定时读取数据
{
if (!string.IsNullOrEmpty(DeviceName))
{
RedisValue obj = fRedisClient.RedisGet(DeviceName);
FDataSouce = obj.ToString();
List<ReeisDataModel> str = JsonConvert.DeserializeObject<List<ReeisDataModel>>(FDataSouce);
Dictionary<string,object> keys=new Dictionary<string, object>();
str?.ForEach(par =>
{
keys[par.VarName] = par.VarVaule;
});
Class_DataBus.GetInstance().Dic_DeviceData[DeviceName] = keys;
}
}
}

public void Start() => timer.Start();
public void Stop() => timer.Stop();

public void Dispose()
{
timer.Stop();
}

#region 属性
[Category("值设定")]
public int Direction
{
get { return (int)GetValue(DirectionProperty); }
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)
{
(d as TheRedis)?.Refresh();
}
public void Refresh()
{
if (textBlock != null)
{
if (Direction == 1)
{
imageZC.Visibility = Visibility.Collapsed;
imageYC.Visibility = Visibility.Visible;
imageGZ.Visibility = Visibility.Collapsed;
textBlock.Visibility = Visibility.Visible;
textBlock.Text = "运行中";
textBlock.Foreground = new SolidColorBrush((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#FF2077EC"));
}
else if (Direction == 2)
{
imageZC.Visibility = Visibility.Collapsed;
imageYC.Visibility = Visibility.Collapsed;
imageGZ.Visibility = Visibility.Visible;
textBlock.Visibility = Visibility.Visible;
textBlock.Text = "故障";
textBlock.Foreground = new SolidColorBrush((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#FFFF0202"));
}
else
{
imageZC.Visibility = Visibility.Visible;
imageYC.Visibility = Visibility.Collapsed;
imageGZ.Visibility = Visibility.Collapsed;
textBlock.Visibility = Visibility.Visible;
textBlock.Text = "未运行";
textBlock.Foreground = new SolidColorBrush((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#FF02F9FF"));
}
}
}
/// <summary>
/// 执行内容
/// </summary>
[Category("事件")]
public string TikcExecute
{
get { return (string)GetValue(TikcExecuteProperty); }
set { SetValue(TikcExecuteProperty,value); }
}
public static readonly DependencyProperty TikcExecuteProperty =
DependencyProperty.Register("TikcExecute",typeof(string),typeof(TheRedis),new PropertyMetadata(string.Empty));
#endregion

#region 数据绑定模块
public event EventHandler PropertyChange; //声明一个事件
[Category("数据绑定-数据来源")]
public int TimeCount
{
get { return (int)GetValue(TimeCountProperty); }
set { SetValue(TimeCountProperty,value); }
}
public static readonly DependencyProperty TimeCountProperty =
DependencyProperty.Register("TimeCount",typeof(int),typeof(TheRedis),new PropertyMetadata(5));
[Category("数据绑定-数据来源")]
public string DataSouceInformation
{
get { return (string)GetValue(DataSouceInformationProperty); }
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"));
[Category("数据绑定-数据来源")]
public string DeviceName
{
get { return (string)GetValue(DeviceNameProperty); }
set { SetValue(DeviceNameProperty,value); }
}
public static readonly DependencyProperty DeviceNameProperty =
DependencyProperty.Register("DeviceName",typeof(string),typeof(TheRedis),new PropertyMetadata(string.Empty));
[Category("数据绑定")]
public string FDataSouce
{
get { return (string)GetValue(FDataSouceProperty); }
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();
public void DataSouceRefresh()
{
try
{
if (!string.IsNullOrEmpty(FDataSouce))
{
GenerateData = (string)CSharpConfig.GetInstance().RunCSharp(Code,new object[] { FDataSouce });
if (PropertyChange != null)
{
PropertyChange(this,null);
}
}
}
catch (Exception ex)
{

}
}
public static string _code = "public string main(string message) \n{ \n //请在此填写你的代码\n\n return message; \n}\n";
[Category("数据绑定")]
public string Code
{
get { return (string)GetValue(CodeProperty); }
set { SetValue(CodeProperty,value); }
}
public static readonly DependencyProperty CodeProperty =
DependencyProperty.Register("Code",typeof(string),typeof(TheRedis),new PropertyMetadata(_code));
[Category("数据绑定")]
public string GenerateData
{
get { return (string)GetValue(GenerateDataProperty); }
set { SetValue(GenerateDataProperty,value); }
}
public static readonly DependencyProperty GenerateDataProperty =
DependencyProperty.Register("GenerateData",typeof(string),typeof(TheRedis),new PropertyMetadata(string.Empty));
#endregion


}
}

+ 128
- 0
BPASmartClient.SCADAControl/CustomerControls/TheTextBlock.cs View File

@@ -0,0 +1,128 @@
using BPASmartClient.Compiler;
using BPASmartClient.DATABUS;
using BPASmartClient.SCADAControl;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
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.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;


namespace BPASmartClient.SCADAControl.CustomerControls
{
public class TheTextBlock :TextBlock, IExecutable
{
static TheTextBlock()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(TheTextBlock),new FrameworkPropertyMetadata(typeof(TheTextBlock)));
}
public TheTextBlock()
{
ResourceDictionary languageResDic = new ResourceDictionary();
languageResDic.Source = new Uri(@"/BPASmartClient.SCADAControl;component/Themes/Generic.xaml",UriKind.RelativeOrAbsolute);
this.Resources.MergedDictionaries.Add(languageResDic);
}

public string ControlType => "控件";

private bool isExecuteState;
public bool IsExecuteState
{
get { return isExecuteState; }
set
{
isExecuteState = value;
if (IsExecuteState)
{
Register();
}
}
}

#region 数据绑定模块
[Category("数据绑定-数据来源")]
public int TimeCount
{
get { return (int)GetValue(TimeCountProperty); }
set { SetValue(TimeCountProperty,value); }
}
public static readonly DependencyProperty TimeCountProperty =
DependencyProperty.Register("TimeCount",typeof(int),typeof(TheTextBlock),new PropertyMetadata(5));
public event EventHandler PropertyChange; //声明一个事件
/// <summary>
/// 属性刷新器
/// </summary>
DispatcherTimer timer = new DispatcherTimer();
/// <summary>
/// 属性绑定变量集合
/// </summary>
Dictionary<string,string> propertyBing = new Dictionary<string,string>();
/// <summary>
/// 运行事件
/// </summary>
public void Register()
{
PropertyInfo[] propertyInfos = this.GetType().GetProperties();
foreach (PropertyInfo propertyInfo in propertyInfos)
{
var propName = propertyInfo?.GetValue(this,null);
if (propName is string && propName != null && propName.ToString().Contains("Binding ") && propName.ToString().Contains("."))
{
string va = string.Empty;
if (propName.ToString().StartsWith("{}")) va = propName.ToString().Replace("{}","");
else va = propName.ToString();
propertyBing[propertyInfo.Name] = va;
}
}

timer.Interval = TimeSpan.FromMilliseconds(TimeCount);
timer.Tick += Timer_Tick; ;
timer.Start();
}
/// <summary>
/// 属性刷新事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Timer_Tick(object? sender,EventArgs e)
{
try
{
foreach (var item in propertyBing)
{
//{Binding 测试设备.VAR_A_2}
string[] str = item.Value.Replace("{Binding ","").Replace("}","").Split(".");
if (str.Length > 1)
{
if (Class_DataBus.GetInstance().Dic_DeviceData.ContainsKey(str[0]))
{
Dictionary<string,object> b = Class_DataBus.GetInstance().Dic_DeviceData[str[0]];
if (b != null && b.ContainsKey(str[1]))
{
object _value = b[str[1]];
this.GetType().GetProperty(item.Key).SetValue(this,_value);
}
}
}
}
}
catch (Exception ex)
{

}
}
#endregion
}
}

+ 0
- 9
BPASmartClient.SCADAControl/CustomerControls/TheTextBlock.xaml View File

@@ -1,9 +0,0 @@
<TextBlock x:Class="BPASmartClient.SCADAControl.CustomerControls.TheTextBlock"
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:BPASmartClient.SCADAControl.CustomerControls"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
</TextBlock>

+ 88
- 4
BPASmartClient.SCADAControl/CustomerControls/TheTextBox.cs View File

@@ -1,8 +1,11 @@
using BPASmartClient.Compiler;
using BPASmartClient.DATABUS;
using BPASmartClient.SCADAControl;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
@@ -14,12 +17,13 @@ using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;

namespace BPASmartClient.SCADAControl.CustomerControls
{
public class TheTextBox : TextBox, IExecutable
{
public event EventHandler PropertyChange; //声明一个事件

static TheTextBox()
{
@@ -28,10 +32,20 @@ namespace BPASmartClient.SCADAControl.CustomerControls

public TheTextBox()
{
ResourceDictionary languageResDic = new ResourceDictionary();
languageResDic.Source = new Uri(@"/BPASmartClient.SCADAControl;component/Themes/Generic.xaml",UriKind.RelativeOrAbsolute);
this.Resources.MergedDictionaries.Add(languageResDic);
Text = "0.01";
VerticalContentAlignment = VerticalAlignment.Center;
Style = Application.Current.Resources["DesignTheTextBox"] as Style;//FindResource("DesignTheTextBox") as Style;
Focusable = false;
//VerticalContentAlignment = VerticalAlignment.Center;
//Style = Application.Current.Resources["DesignTheTextBox"] as Style;//FindResource("DesignTheTextBox") as Style;
//Focusable = false;
Height = 30;
Width = 80;
FontSize = 16;
//HorizontalAlignment = HorizontalAlignment.Left;
//VerticalAlignment = VerticalAlignment.Center;
//Foreground = new SolidColorBrush((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#a2c2e8"));
//BorderThickness=new Thickness(1);
}
public string ControlType => "控件";

@@ -52,8 +66,78 @@ namespace BPASmartClient.SCADAControl.CustomerControls
}
}



#region 数据绑定模块
[Category("数据绑定-数据来源")]
public int TimeCount
{
get { return (int)GetValue(TimeCountProperty); }
set { SetValue(TimeCountProperty,value); }
}
public static readonly DependencyProperty TimeCountProperty =
DependencyProperty.Register("TimeCount",typeof(int),typeof(TheTextBox),new PropertyMetadata(5));
public event EventHandler PropertyChange; //声明一个事件
/// <summary>
/// 属性刷新器
/// </summary>
DispatcherTimer timer = new DispatcherTimer();
/// <summary>
/// 属性绑定变量集合
/// </summary>
Dictionary<string,string> propertyBing = new Dictionary<string,string>();
/// <summary>
/// 运行事件
/// </summary>
public void Register()
{
PropertyInfo[] propertyInfos = this.GetType().GetProperties();
foreach (PropertyInfo propertyInfo in propertyInfos)
{
var propName = propertyInfo?.GetValue(this,null);
if (propName is string && propName != null && propName.ToString().Contains("Binding ") && propName.ToString().Contains("."))
{
propertyBing[propertyInfo.Name] = propName.ToString();
}
}

timer.Interval = TimeSpan.FromMilliseconds(TimeCount);
timer.Tick += Timer_Tick; ;
timer.Start();
}
/// <summary>
/// 属性刷新事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Timer_Tick(object? sender,EventArgs e)
{
try
{
foreach (var item in propertyBing)
{
//{Binding 测试设备.VAR_A_2}
string[] str = item.Value.Replace("{Binding ","").Replace("}","").Split(".");
if (str.Length > 1)
{
if (Class_DataBus.GetInstance().Dic_DeviceData.ContainsKey(str[0]))
{
Dictionary<string,object> b = Class_DataBus.GetInstance().Dic_DeviceData[str[0]];
if (b != null && b.ContainsKey(str[1]))
{
object _value = b[str[1]];
this.GetType().GetProperty(item.Key).SetValue(this,_value);
}
}
}
}
}
catch (Exception ex)
{

}
}
#endregion

}
}

+ 3
- 0
BPASmartClient.SCADAControl/CustomerControls/WaveProgressBar.cs View File

@@ -30,6 +30,9 @@ namespace BPASmartClient.SCADAControl.CustomerControls

public WaveProgressBar()
{
ResourceDictionary languageResDic = new ResourceDictionary();
languageResDic.Source = new Uri(@"/BPASmartClient.SCADAControl;component/Themes/Generic.xaml",UriKind.RelativeOrAbsolute);
this.Resources.MergedDictionaries.Add(languageResDic);
Loaded += (s, e) => UpdateWave(Value);
SetCurrentValue(WidthProperty, 200d);
SetCurrentValue(HeightProperty, 200d);


BIN
View File


BIN
View File


BIN
View File


BIN
View File


BIN
View File


BIN
View File


BIN
View File


BIN
View File


BIN
View File


BIN
View File


+ 1223
- 43
BPASmartClient.SCADAControl/Themes/Generic.xaml
File diff suppressed because it is too large
View File


+ 1
- 2
FryPot_DosingSystem/App.xaml.cs View File

@@ -16,7 +16,6 @@ using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using AlarmInfo = BPASmartClient.CustomResource.Pages.Model.AlarmInfo;

namespace FryPot_DosingSystem
{
@@ -128,7 +127,7 @@ namespace FryPot_DosingSystem
});
InfoLog.Add(new SubMenumodel()
{
SubMenuName = "炒锅状态记录",
SubMenuName = "炒锅历史状态",
SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员, Permission.观察员 },
AssemblyName = "FryPot_DosingSystem",
ToggleWindowPath = "View.SqliteDataView"


+ 0
- 1
FryPot_DosingSystem/Control/DosingLogicControl.cs View File

@@ -1568,7 +1568,6 @@ namespace FryPot_DosingSystem.Control
FryPotMonitorManage.GetInstance.fryFive.OilCapacity = globalVar.fryPotFive.OilCapacity;
FryPotMonitorManage.GetInstance.fryFive.TotalOilCapactiy += globalVar.fryPotFive.OilCapacity;
}

//炒锅状态实时显示
FryPotStatusDisplay();
RollerLineStatusDisplay();


BPASmartClient.CustomResource/Pages/Model/AlarmInfo.cs → FryPot_DosingSystem/Model/AlarmInfo.cs View File

@@ -1,10 +1,11 @@
using System;
using BPASmartClient.CustomResource.Pages.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.CustomResource.Pages.Model
namespace FryPot_DosingSystem.Model
{
public class AlarmInfo
{

+ 1
- 1
FryPot_DosingSystem/View/FryPotMonitorView.xaml View File

@@ -14,7 +14,7 @@
<Style x:Key="dataGrid" TargetType="DataGrid" >
<Setter Property="HorizontalGridLinesBrush" Value="#FF2AB2E7"/>
<Setter Property="VerticalGridLinesBrush" Value="#FF2AB2E7"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="BorderBrush" Value="#FF2AB2E7"/>
<Setter Property="CanUserResizeColumns" Value="False"/>
<Setter Property="HeadersVisibility" Value="Column"/>


+ 8
- 1
FryPot_DosingSystem/View/RecipeManageView.xaml.cs View File

@@ -1,4 +1,5 @@
using System;
using BPASmartClient.Helper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -23,6 +24,12 @@ namespace FryPot_DosingSystem.View
public RecipeManageView()
{
InitializeComponent();
this.Unloaded += RecipeManageView_Unloaded;
}

private void RecipeManageView_Unloaded(object sender, RoutedEventArgs e)
{
ActionManage.GetInstance.Send("RecipeIsChange");
}
}
}

+ 1
- 1
FryPot_DosingSystem/View/SqliteDataView.xaml View File

@@ -15,7 +15,7 @@
<Style x:Key="dataGrid" TargetType="DataGrid" >
<Setter Property="HorizontalGridLinesBrush" Value="#FF2AB2E7"/>
<Setter Property="VerticalGridLinesBrush" Value="#FF2AB2E7"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="BorderBrush" Value="#FF2AB2E7"/>
<Setter Property="CanUserResizeColumns" Value="False"/>
<Setter Property="HeadersVisibility" Value="Column"/>


+ 1
- 1
FryPot_DosingSystem/ViewModel/RecipeSetViewModel.cs View File

@@ -54,7 +54,7 @@ namespace FryPot_DosingSystem.ViewModel
int count = recipeModels.Count;
bool sign = false;
ActionManage.GetInstance.CancelRegister("RecipeIsChange");
ActionManage.GetInstance.Register(new Action(() =>
ActionManage.GetInstance.RegisterAsync(new Action(() =>
{
if (!sign)
{


+ 1
- 1
SCADA.Test/MainWindow.xaml.cs View File

@@ -45,7 +45,7 @@ namespace SCADA.Test
{
InitializeComponent();

RedisHelper.GetInstance.ConnectAsync(String.Empty);

string _code = " public string main(string message) \n { \n //请在此填写你的代码\n\n return message; \n }\n";
string GenerateData = (string)CSharpConfig.GetInstance().RunCSharp(_code,new object[] { "ERERERERE" });


+ 1
- 0
SCADA.Test/SCADA.Test.csproj View File

@@ -12,6 +12,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\BPASmart.Model\BPASmart.Model.csproj" />
<ProjectReference Include="..\BPASmartClient.Compiler\BPASmartClient.Compiler.csproj" />
<ProjectReference Include="..\BPASmartClient.MessageCommunication\BPASmartClient.MessageCommunication.csproj" />
<ProjectReference Include="..\BPASmartClient.MessageName\BPASmartClient.MessageName.csproj" />


Loading…
Cancel
Save