1 //
2 // Copyright (c) 2010-2024 Antmicro
3 //
4 // This file is licensed under the MIT License.
5 // Full license text is available in 'licenses/MIT.txt'.
6 //
7 using System;
8 using System.Collections.Generic;
9 
10 namespace Antmicro.Renode.Network.ExternalControl
11 {
12     public enum Command : byte
13     {
14         RunFor = 1,
15         GetTime,
16         GetMachine,
17         ADC,
18         GPIOPort,
19     }
20 
21     public interface ICommand
22     {
23         Command Identifier { get; }
24         byte Version { get; }
25         IMachineContainer Machines { get; }
26 
Invoke(List<byte> data)27         Response Invoke(List<byte> data);
28     }
29 
30     public abstract class BaseCommand : ICommand
31     {
BaseCommand(ExternalControlServer parent)32         public BaseCommand(ExternalControlServer parent)
33         {
34             this.parent = parent;
35         }
36 
Invoke(List<byte> data)37         public abstract Response Invoke(List<byte> data);
38 
39         public abstract Command Identifier { get; }
40         public abstract byte Version { get; }
41         public IMachineContainer Machines => parent.Machines;
42 
43         protected readonly ExternalControlServer parent;
44     }
45 
46     public interface IHasEvents : ICommand
47     {
48         event Action<Response> EventReported;
49     }
50 }
51