wenxiangchao
3 天以前 b544d5cccd76735e034c8055918a50927b437474
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using System;
using System.Collections.Generic;
using CommunityToolkit.Mvvm.ComponentModel;
 
namespace Plugin.DeviceDebug.Entity
{
    /// <summary>
    /// 调试命令基类
    /// </summary>
    public partial class DebugCommand : ObservableObject
    {
        public DebugCommand()
        {
            CommandId = Guid.NewGuid().ToString();
            CreatedAt = DateTime.Now;
            Parameters = new Dictionary<string, object>();
        }
 
        [ObservableProperty] private string _commandId = string.Empty;
        [ObservableProperty] private string _commandType = string.Empty;
        [ObservableProperty] private string _deviceId = string.Empty;
        [ObservableProperty] private int _channel;
        [ObservableProperty] private Dictionary<string, object> _parameters = new();
        [ObservableProperty] private DateTime _createdAt = DateTime.Now;
    }
 
    /// <summary>
    /// 电源设置命令
    /// </summary>
    public class PowerSetCommand : DebugCommand
    {
        public PowerSetCommand() { CommandType = "PowerSet"; }
        public double Voltage { get; set; }
        public double CurrentLimit { get; set; }
        public bool Output { get; set; }
    }
 
    /// <summary>
    /// 电源测量命令
    /// </summary>
    public class PowerMeasureCommand : DebugCommand
    {
        public PowerMeasureCommand() { CommandType = "PowerMeasure"; }
    }
 
    /// <summary>
    /// CAN发送命令
    /// </summary>
    public class CanSendCommand : DebugCommand
    {
        public CanSendCommand() { CommandType = "CanSend"; }
        public string Frame { get; set; } = string.Empty;
        public byte[] Data { get; set; } = Array.Empty<byte>();
    }
 
    /// <summary>
    /// PLC写入命令
    /// </summary>
    public class PlcWriteCommand : DebugCommand
    {
        public PlcWriteCommand() { CommandType = "PlcWrite"; }
        public string IoAddress { get; set; } = string.Empty;
        public bool Value { get; set; }
    }
}