| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.ComponentModel;
- using System.Runtime.CompilerServices;
- using Newtonsoft.Json;
- using TeamAAS.Feeder.Enums;
- namespace TeamAAS.Feeder.Models
- {
- public enum SequenceStepType
- {
- [Description("方向振动")]
- Direction,
- [Description("延时等待")]
- Delay,
- }
- public class SequenceStep : INotifyPropertyChanged
- {
- private int _index;
- private SequenceStepType _stepType = SequenceStepType.Direction;
- private FeederAction _direction = FeederAction.Right;
- private int _timeMs = 500;
- private string _note = "";
- private bool _enabled = true;
- [JsonIgnore]
- public int Index
- {
- get { return _index; }
- set { SetProperty(ref _index, value); }
- }
- public SequenceStepType StepType
- {
- get { return _stepType; }
- set { SetProperty(ref _stepType, value); }
- }
- public FeederAction Direction
- {
- get { return _direction; }
- set { SetProperty(ref _direction, value); }
- }
- /// <summary>
- /// 统一时间字段:方向振动时=振动时长(ms),延时等待时=延时时长(ms)
- /// </summary>
- public int TimeMs
- {
- get { return _timeMs; }
- set { SetProperty(ref _timeMs, value); }
- }
- public string Note
- {
- get { return _note; }
- set { SetProperty(ref _note, value); }
- }
- public bool Enabled
- {
- get { return _enabled; }
- set { SetProperty(ref _enabled, value); }
- }
- public event PropertyChangedEventHandler PropertyChanged;
- protected virtual bool SetProperty<T>(ref T storage, T value, [CallerMemberName] string propertyName = null)
- {
- if (EqualityComparer<T>.Default.Equals(storage, value)) return false;
- storage = value;
- PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
- return true;
- }
- }
- public class SequenceSet : INotifyPropertyChanged
- {
- private string _name = "";
- private string _description = "";
- public string Name
- {
- get { return _name; }
- set { SetProperty(ref _name, value); }
- }
- public string Description
- {
- get { return _description; }
- set { SetProperty(ref _description, value); }
- }
- public ObservableCollection<SequenceStep> Steps { get; set; }
- = new ObservableCollection<SequenceStep>();
- public SequenceSet Clone()
- {
- var json = JsonConvert.SerializeObject(this);
- return JsonConvert.DeserializeObject<SequenceSet>(json);
- }
- public event PropertyChangedEventHandler PropertyChanged;
- protected virtual bool SetProperty<T>(ref T storage, T value, [CallerMemberName] string propertyName = null)
- {
- if (EqualityComparer<T>.Default.Equals(storage, value)) return false;
- storage = value;
- PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
- return true;
- }
- }
- }
|