|
|
@@ -0,0 +1,223 @@
|
|
|
+using MECF.Framework.Common.CommonData.PUF;
|
|
|
+using MECF.Framework.Common.DataCenter;
|
|
|
+using MECF.Framework.Common.Equipment;
|
|
|
+using MECF.Framework.Common.Utilities;
|
|
|
+using Prism.Mvvm;
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Linq;
|
|
|
+using System.Text;
|
|
|
+using System.Threading.Tasks;
|
|
|
+using System.Windows.Threading;
|
|
|
+
|
|
|
+namespace PunkHPX8_MainPages.ViewModels
|
|
|
+{
|
|
|
+ public class PlatingCellSetupViewModel : BindableBase
|
|
|
+ {
|
|
|
+ #region 常量
|
|
|
+ private const string MOTION_DATA = "MotionData";
|
|
|
+ private const string IS_SWITCH_ON = "IsSwitchOn";
|
|
|
+ private const string CURRENT_STATION = "CurrentStation";
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 内部变量
|
|
|
+
|
|
|
+ #region PlatingCell1_2Vertical
|
|
|
+ /// <summary>
|
|
|
+ /// 模块名称
|
|
|
+ /// </summary>
|
|
|
+ private string _platingCell1_2VerticalName;
|
|
|
+ /// <summary>
|
|
|
+ /// 运动数据
|
|
|
+ /// </summary>
|
|
|
+ private CommandMotionData _platingCell1_2VerticalMotionData;
|
|
|
+ /// <summary>
|
|
|
+ /// 当前位置
|
|
|
+ /// </summary>
|
|
|
+ private string _platingCell1_2VerticalCurrentStation;
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region PlatingCell3_4Vertical
|
|
|
+ /// <summary>
|
|
|
+ /// 模块名称
|
|
|
+ /// </summary>
|
|
|
+ private string _platingCell3_4VerticalName;
|
|
|
+ /// <summary>
|
|
|
+ /// 运动数据
|
|
|
+ /// </summary>
|
|
|
+ private CommandMotionData _platingCell3_4VerticalMotionData;
|
|
|
+ /// <summary>
|
|
|
+ /// 当前位置
|
|
|
+ /// </summary>
|
|
|
+ private string _platingCell3_4VerticalCurrentStation;
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 系统数据
|
|
|
+ /// <summary>
|
|
|
+ /// 定时器
|
|
|
+ /// </summary>
|
|
|
+ DispatcherTimer _timer;
|
|
|
+ /// <summary>
|
|
|
+ /// 查询后台数据集合
|
|
|
+ /// </summary>
|
|
|
+ private List<string> _rtDataKeys = new List<string>();
|
|
|
+ /// <summary>
|
|
|
+ /// rt查询key数值字典
|
|
|
+ /// </summary>
|
|
|
+ private Dictionary<string, object> _rtDataValueDic = new Dictionary<string, object>();
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ #region 属性
|
|
|
+
|
|
|
+ #region PlatingCell1_2Vertical
|
|
|
+ /// <summary>
|
|
|
+ ///名称
|
|
|
+ /// </summary>
|
|
|
+ public string PlatingCell1_2VerticalName
|
|
|
+ {
|
|
|
+ get { return _platingCell1_2VerticalName; }
|
|
|
+ set { SetProperty(ref _platingCell1_2VerticalName, value); }
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// SRD1Arm运动数据
|
|
|
+ /// </summary>
|
|
|
+ public CommandMotionData PlatingCell1_2VerticalMotionData
|
|
|
+ {
|
|
|
+ get { return _platingCell1_2VerticalMotionData; }
|
|
|
+ set { SetProperty(ref _platingCell1_2VerticalMotionData, value); }
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// SRD1Arm当前位置
|
|
|
+ /// </summary>
|
|
|
+ public string PlatingCell1_2VerticalCurrentStation
|
|
|
+ {
|
|
|
+ get { return _platingCell1_2VerticalCurrentStation; }
|
|
|
+ set { SetProperty(ref _platingCell1_2VerticalCurrentStation, value); }
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region PlatingCell3_4Vertical
|
|
|
+ /// <summary>
|
|
|
+ ///名称
|
|
|
+ /// </summary>
|
|
|
+ public string PlatingCell3_4VerticalName
|
|
|
+ {
|
|
|
+ get { return _platingCell3_4VerticalName; }
|
|
|
+ set { SetProperty(ref _platingCell3_4VerticalName, value); }
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// SRD1Arm运动数据
|
|
|
+ /// </summary>
|
|
|
+ public CommandMotionData PlatingCell3_4VerticalMotionData
|
|
|
+ {
|
|
|
+ get { return _platingCell3_4VerticalMotionData; }
|
|
|
+ set { SetProperty(ref _platingCell3_4VerticalMotionData, value); }
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// SRD1Arm当前位置
|
|
|
+ /// </summary>
|
|
|
+ public string PlatingCell3_4VerticalCurrentStation
|
|
|
+ {
|
|
|
+ get { return _platingCell3_4VerticalCurrentStation; }
|
|
|
+ set { SetProperty(ref _platingCell3_4VerticalCurrentStation, value); }
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 构造函数
|
|
|
+ /// </summary>
|
|
|
+ public PlatingCellSetupViewModel()
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// 加载数据
|
|
|
+ /// </summary>
|
|
|
+ public void LoadData(string systemName)
|
|
|
+ {
|
|
|
+ PlatingCell1_2VerticalName = $"PlatingCell1_2.Vertical";
|
|
|
+ PlatingCell3_4VerticalName = $"PlatingCell3_4.Vertical";
|
|
|
+ AddDataKeys();
|
|
|
+ if (_timer == null)
|
|
|
+ {
|
|
|
+ _timer = new DispatcherTimer();
|
|
|
+ _timer.Interval = TimeSpan.FromMilliseconds(200);
|
|
|
+ _timer.Tick += Timer_Tick; ;
|
|
|
+ }
|
|
|
+ _timer.Start();
|
|
|
+
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// 定时器执行
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="sender"></param>
|
|
|
+ /// <param name="e"></param>
|
|
|
+ private void Timer_Tick(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ OnTimer();
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// 隐藏
|
|
|
+ /// </summary>
|
|
|
+ public void Hide()
|
|
|
+ {
|
|
|
+ if (_timer != null)
|
|
|
+ {
|
|
|
+ _timer.Stop();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// 初始化查询数据集合
|
|
|
+ /// </summary>
|
|
|
+ private void AddDataKeys()
|
|
|
+ {
|
|
|
+ _rtDataKeys.Clear();
|
|
|
+ _rtDataKeys.Add($"{PlatingCell1_2VerticalName}.{MOTION_DATA}");
|
|
|
+ _rtDataKeys.Add($"{PlatingCell1_2VerticalName}.{IS_SWITCH_ON}");
|
|
|
+ _rtDataKeys.Add($"{PlatingCell1_2VerticalName}.{CURRENT_STATION}");
|
|
|
+
|
|
|
+ _rtDataKeys.Add($"{PlatingCell3_4VerticalName}.{MOTION_DATA}");
|
|
|
+ _rtDataKeys.Add($"{PlatingCell3_4VerticalName}.{IS_SWITCH_ON}");
|
|
|
+ _rtDataKeys.Add($"{PlatingCell3_4VerticalName}.{CURRENT_STATION}");
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// 定时器
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ private Boolean OnTimer()
|
|
|
+ {
|
|
|
+ if (_rtDataKeys.Count != 0)
|
|
|
+ {
|
|
|
+ _rtDataValueDic = QueryDataClient.Instance.Service.PollData(_rtDataKeys);
|
|
|
+ if (_rtDataValueDic != null)
|
|
|
+ {
|
|
|
+ PlatingCell1_2VerticalMotionData = CommonFunction.GetValue<CommandMotionData>(_rtDataValueDic, $"{PlatingCell1_2VerticalName}.{MOTION_DATA}");
|
|
|
+ PlatingCell1_2VerticalCurrentStation = CommonFunction.GetCurrentStationLastContent(CommonFunction.GetValue<string>(_rtDataValueDic, $"{PlatingCell1_2VerticalName}.{CURRENT_STATION}"), PlatingCell1_2VerticalName);
|
|
|
+
|
|
|
+ PlatingCell3_4VerticalMotionData = CommonFunction.GetValue<CommandMotionData>(_rtDataValueDic, $"{PlatingCell3_4VerticalName}.{MOTION_DATA}");
|
|
|
+ PlatingCell3_4VerticalCurrentStation = CommonFunction.GetCurrentStationLastContent(CommonFunction.GetValue<string>(_rtDataValueDic, $"{PlatingCell3_4VerticalName}.{CURRENT_STATION}"), PlatingCell3_4VerticalName);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+}
|