-
Notifications
You must be signed in to change notification settings - Fork 0
/
Types.hs
87 lines (56 loc) · 1.48 KB
/
Types.hs
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
{-# LANGUAGE DeriveGeneric #-}
module Types where
import qualified Data.Map as M
import Data.Int (Int8, Int16, Int32, Int64)
import Data.Word (Word8, Word16, Word32, Word64)
import GHC.Generics
type Byte = Word8
type Frequency = Double
type MessageID = Byte
type CommandCode = Byte
--data Endianness = BE | LE
data Data = S (String, Int)
| B Bool
| I8 Int8
| W8 Word8
| I16 Int16
| W16 Word16
| I32 Int32
| W32 Word32
| I64 Int64
| W64 Word64
| F Float
| D Double
| Arr [Data]
| Var String deriving (Show)
data Parameter = Parameter String Data
data Variable = Variable String [Data] deriving (Show)
data Command = Command {
cc :: CommandCode
,arguments :: [Parameter]
} deriving (Generic)
data Telemetry = Telemetry {
parameters :: [Parameter]
} deriving (Generic)
data Message a = Message MessageID a
data MessageDef a = MessageDef {
variables :: [Variable]
,message :: Message a
} deriving (Generic)
data MessageMeta = MessageMeta {
file :: FilePath
,frequency :: Double
,times :: Int
} deriving (Generic)
data Controller = Controller {
meta :: ControllerMeta
,sequenced :: [MessageMeta]
,parallel :: [MessageMeta]
} deriving (Generic)
data ControllerMeta = ControllerMeta {
ip :: String
,port :: Integer
} deriving (Generic)
data Config = Config {
envC :: M.Map String Parameter
}