|
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using BPASmartClient.CustomResource;
- using BPA.Helper;
- using BPASmartClient.Model;
- using BPASmartClient.MorkS.Model;
- using BPA.Helper;
-
- using Org.BouncyCastle.Utilities;
-
- namespace BPASmartClient.MorkS.ViewModel
- {
- public class ParSetViewModel : NotifyBase
- {
- public ParSetViewModel()
- {
- SaveInfoCommand = new BPARelayCommand(SaveSettingData);
- SoupSootForwardCommand = new BPARelayCommand(SoupSootForward);
- SoupSootBackwardCommand = new BPARelayCommand(SoupSootBackward);
- SoupSootStopCommand = new BPARelayCommand(SoupSootStop);
-
-
- ActionManage.GetInstance.Register(SaveSettingData, "初始化设定煮面时间");
-
-
- CommandStart = new BPARelayCommand(async () =>
- {
- ActionManage.GetInstance.Send(new WritePar() { Address = "M0.6", Value = true }, "WriteBools");
- await Task.Delay((int)DelayTime * 1000);
- ActionManage.GetInstance.Send(new WritePar() { Address = "M0.6", Value = false }, "WriteBools");
- });
-
- if (Json<MorksPar>.Data.DishLibraryParSets.Count < 5)
- {
- Json<MorksPar>.Data.DishLibraryParSets.Clear();
- for (int i = 0; i < 5; i++)
- {
- Json<MorksPar>.Data.DishLibraryParSets.Add(new ParSet()
- {
- Minute = 2,
- Second = 0,
- TextBlockContext = $"{i + 1}"
- });
- }
- }
-
- //VoicePlayTest = new BPARelayCommand(() => {
- // VoiceAPI.Speak(new Random().Next(1,100).ToString());
- //});
- }
-
- public BPARelayCommand SaveInfoCommand { get; set; }
- public BPARelayCommand CommandStart { get; set; }
- public BPARelayCommand SoupSootForwardCommand { get; set; }
- public BPARelayCommand SoupSootBackwardCommand { get; set; }
- public BPARelayCommand SoupSootStopCommand { get; set; }
-
- #region 时间设定
- /// <summary>
- /// 间隔时间设定
- /// </summary>
- public ushort IntervalTime { get { return Json<MorksPar>.Data.IntervalTime; } set { Json<MorksPar>.Data.IntervalTime = value; OnPropertyChanged(); } }
- /// <summary>
- /// 反转抽汤时间设定
- /// </summary>
- public ushort BackwardSoupSootTime { get { return Json<MorksPar>.Data.BackwardSoupSootTime; } set { Json<MorksPar>.Data.BackwardSoupSootTime = value; OnPropertyChanged(); } }
- /// <summary>
- /// 反转过后再次出汤时间设定
- /// </summary>
- public ushort BackwardedOutSoupTime { get { return Json<MorksPar>.Data.BackwardedOutSoupTime; } set { Json<MorksPar>.Data.BackwardedOutSoupTime = value; OnPropertyChanged(); } }
- /// <summary>
- /// 未反转抽汤下时间设定
- /// </summary>
- public ushort UnBackwardSoupSootTime { get { return Json<MorksPar>.Data.UnBackwardSoupSootTime; } set { Json<MorksPar>.Data.UnBackwardSoupSootTime = value; OnPropertyChanged(); } }
- //public BPARelayCommand VoicePlayTest { get; set; }
-
-
- /// <summary>
- /// 加汤时间设置
- /// </summary>
- //public ushort AddSoup { get { return Json<MorksPar>.Data.AddSoupTime; } set { Json<MorksPar>.Data.AddSoupTime = value; OnPropertyChanged(); } }
- #endregion
-
-
- public ObservableCollection<ParSet> parSets { get; set; } = Json<MorksPar>.Data.parSets;
- public int OpenUseNumber { get { return Json<MorksPar>.Data.InvertedNoodles_OpenBusyNum; } set { Json<MorksPar>.Data.InvertedNoodles_OpenBusyNum = value; OnPropertyChanged(); } }
- public ObservableCollection<ParSet> DishLibraryParSets { get; set; } = Json<MorksPar>.Data.DishLibraryParSets;
-
- public float DelayTime { get { return _DelayTime; } set { _DelayTime = value; OnPropertyChanged(); } }
- private float _DelayTime;
-
-
-
- private void SaveSettingData()
- {
- List<ushort> values = new List<ushort>();
- values.Clear();
-
- List<bool> bools = new List<bool>();
- bools.Clear();
-
- for (int i = 0; i < Json<MorksPar>.Data.parSets.Count; i++)
- {
- values.Clear();
- values.Add(Json<MorksPar>.Data.parSets[i].Minute);
- values.Add(Json<MorksPar>.Data.parSets[i].Second);
- bools.Add(Json<MorksPar>.Data.parSets[i].IsShield);
- ActionManage.GetInstance.Send(new WritePar() { Address = $"VW{116 + (i * 6)}", Value = values.ToArray() }, "WriteVW");
- }
- //ushort times = Convert.ToUInt16(Json<MorksPar>.Data.AddSoupTime * 10);
- //ActionManage.GetInstance.Send("WriteVW", new WritePar() { Address = "VW2282", Value = times });
-
- ActionManage.GetInstance.Send(new WritePar() { Address = "VW2282", Value = (ushort)(UnBackwardSoupSootTime * 10) }, "WriteVW");
- ActionManage.GetInstance.Send(new WritePar() { Address = "VW2284", Value = (ushort)(IntervalTime * 10) }, "WriteVW");
- ActionManage.GetInstance.Send(new WritePar() { Address = "VW2286", Value = (ushort)(BackwardSoupSootTime * 10) }, "WriteVW");
- ActionManage.GetInstance.Send(new WritePar() { Address = "VW2288", Value = (ushort)(BackwardedOutSoupTime * 10) }, "WriteVW");
-
- ActionManage.GetInstance.Send(new WritePar() { Address = "M260.0", Value = bools.ToArray() }, "WriteBools");
- Json<MorksPar>.Save();
-
- //WriteTimeSet(IntervalTime);
- //WriteTimeSet(BackwardSoupSootTime);
- //WriteTimeSet(BackwardedOutSoupTime);
- //WriteTimeSet(UnBackwardSoupSootTime);
- }
-
- private void WriteTimeSet(float TimePar)
- {
- ushort paras = Convert.ToUInt16(TimePar * 10);
- ActionManage.GetInstance.Send(new WritePar() { Address = "VW2282", Value = paras }, "WriteVW");
- }
-
- private async void SoupSootForward()
- {
- ActionManage.GetInstance.Send(new WritePar() { Address = "M1.0", Value = true }, "WriteBools");
- await Task.Delay((int)DelayTime * 1000);
- ActionManage.GetInstance.Send(new WritePar() { Address = "M1.0", Value = false }, "WriteBools");
- }
- private async void SoupSootBackward()
- {
- ActionManage.GetInstance.Send(new WritePar() { Address = "M1.1", Value = true }, "WriteBools");
- await Task.Delay((int)DelayTime * 1000);
- ActionManage.GetInstance.Send(new WritePar() { Address = "M1.1", Value = false }, "WriteBools");
- }
- private async void SoupSootStop()
- {
- ActionManage.GetInstance.Send(new WritePar() { Address = "M1.2", Value = true }, "WriteBools");
- await Task.Delay((int)DelayTime * 1000);
- ActionManage.GetInstance.Send(new WritePar() { Address = "M1.2", Value = false }, "WriteBools");
- }
- }
- }
|