forked from abdelmounaime/Maekawa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
enum_type.py
41 lines (35 loc) · 796 Bytes
/
enum_type.py
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
#!/usr/bin/python
# -*- coding: utf-8 -*-
from enum import IntEnum
# Author: Hao Luo
class STATE(IntEnum):
"""Enum class that represents node state"""
INIT = 0
REQUEST = 1
HELD = 2
RELEASE = 3
class MSG_TYPE(IntEnum):
"""Enum class that represents message type"""
REQUEST = 0
GRANT = 1
RELEASE = 2
FAIL = 3
INQUIRE = 4
YIELD = 5
def __json__(self):
return self
def to_str(self):
if self == 0:
return 'REQUEST'
elif self == 1:
return 'GRANT'
elif self == 2:
return 'RELEASE'
elif self == 3:
return 'FAIL'
elif self == 4:
return 'INQUIRE'
elif self == 5:
return 'YIELD'
else:
return None