123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- using Aitex.Core.Util;
- using Caliburn.Micro.Core;
- using Caliburn.Micro;
- using FurnaceUI.Models;
- using FurnaceUI.Views.Operations;
- using MECF.Framework.Common.DataCenter;
- using MECF.Framework.Common.Equipment;
- using MECF.Framework.Common.OperationCenter;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Controls;
- using OpenSEMI.ClientBase;
- namespace FurnaceUI.Views.Maintenances
- {
- public class BufferRobotViewModel : FurnaceUIViewModelBase
- {
- #region Buffer Data
- [Subscription("PM1.BufferServo.CurrentPosition")]
- public float BufferCurrentPosition { get; set; }
- [Subscription("PM1.BufferServo.CurrentSpeed")]
- public float BufferCurrentSpeed { get; set; }
- [Subscription("PM1.BufferServo.IsServoOn")]
- public bool BufferIsServoOn { get; set; }
- [Subscription("PM1.BufferServo.IsReady")]
- public bool BufferIsReady { get; set; }
- [Subscription("PM1.BufferServo.Status")]
- public string BufferStatus { get; set; }
- [Subscription("PM1.BufferServo.IsMotorRun")]
- public bool BufferIsMotorRun { get; set; }
- #endregion
- [Subscription("Rt.Status")]
- public string RtStatus { get; set; }
- public bool IsSystemStaus => (RtStatus != "AutoRunning");
- //public bool IsPermission { get => this.Permission >= 3 && ClientApp.Instance.UserContext.RoleName == "Service"; }
- public bool IsPermission { get => this.Permission >= 3; }
- private List<string> _targetPosition = new List<string>();
- public List<string> TargetPosition
- {
- get => _targetPosition;
- set
- {
- _targetPosition = value;
- NotifyOfPropertyChange(nameof(TargetPosition));
- }
- }
- public double BufferAxisMoveSpeed { get; set; }
- public double BufferAxisLimitSpeed { get; set; }
- private string _selectedTargetPosition;
- public string SelectedTargetPosition
- {
- get => _selectedTargetPosition;
- set
- {
- _selectedTargetPosition = value;
- NotifyOfPropertyChange(nameof(SelectedTargetPosition));
- }
- }
- private BufferRobotView _view;
- protected override void OnViewLoaded(object view)
- {
- base.OnViewLoaded(view);
- _view = view as BufferRobotView;
-
- BufferAxisLimitSpeed = (double)QueryDataClient.Instance.Service.GetConfig($"BufferServo.BufferAxisLimitSpeed");
- }
- private void InitData()
- {
- BufferAxisMoveSpeed = (double)QueryDataClient.Instance.Service.GetConfig($"BufferServo.MoveSpeed");
- }
- protected override void InvokeAfterUpdateProperty(Dictionary<string, object> data)
- {
- InitData();
- if (_view != null)
- {
- var rsetValueBool = double.TryParse(_view?.tbMoveSpeed.Text, out double setZValue);
- if (!rsetValueBool)
- _view.tbMoveSpeed.Text = "0";
- if (!string.IsNullOrEmpty(_view?.tbMoveSpeed.Text) && rsetValueBool && setZValue > BufferAxisLimitSpeed)
- {
- _view.tbMoveSpeed.Text = "0";
- DialogBox.ShowWarning($"Max Move Speed is {BufferAxisLimitSpeed}");
- }
-
- }
- }
- private Dictionary<string, string> _targetPositionDic = new Dictionary<string, string>()
- {
- { "1-A", "1" },
- { "1-B", "2" },
- { "1-C", "3" },
- { "1-D", "4" },
- { "2-A", "5" },
- { "2-B", "6" },
- { "2-C", "7" },
- { "2-D", "8" },
- { "3-A", "9" },
- { "3-B", "10" },
- { "3-C", "11" },
- { "3-D", "12" },
- { "4-A", "13" },
- { "4-B", "14" },
- { "4-C", "15" },
- { "4-D", "16" },
- };
- public BufferRobotViewModel()
- {
- foreach(var target in _targetPositionDic.Keys)
- {
- _targetPosition.Add(target);
- }
- }
- public void SetValue()
- {
- var target = _targetPositionDic.ContainsKey(SelectedTargetPosition) ? _targetPositionDic[SelectedTargetPosition] : SelectedTargetPosition;
- InvokeClient.Instance.Service.DoOperation($"PM1.BufferServo.ServoTargetPosition", target);
- }
- public void MoveTo()
- {
- InvokeClient.Instance.Service.DoOperation($"PM1.BufferServo.ServoMoveTo", "");
- }
- public void SetServoOn(object target, object isOn)
- {
- InvokeClient.Instance.Service.DoOperation($"{target}", $"{isOn}");
- }
- public void BufferSaveValue(object obj, object tb)
- {
- switch (obj)
- {
-
- case "MoveSpeed":
- var setValue = double.Parse((tb as TextBox)?.Text);
- if (setValue > BufferAxisLimitSpeed)
- {
- DialogBox.ShowWarning($"Max MoveSpeed is {BufferAxisLimitSpeed}");
- break;
- }
- InvokeClient.Instance.Service.DoOperation("System.SetConfig", $"BufferServo.{obj}", (tb as TextBox)?.Text);
- break;
- }
- }
- public void Stop(object target)
- {
- InvokeClient.Instance.Service.DoOperation($"{target}.ServoStop");
- }
- public void Reset(object target)
- {
- InvokeClient.Instance.Service.DoOperation($"{target}.ServoResetAlarm");
- }
- }
- }
|