source: framspy/gui/framsutils/FramsInterface.py @ 1302

Last change on this file since 1302 was 1198, checked in by Maciej Komosinski, 22 months ago

Added simple Python GUI for Framsticks library/server

File size: 4.8 KB
Line 
1from typing import Dict, List, Any, Tuple
2from abc import ABC, abstractmethod
3import enum
4from xmlrpc.client import Boolean
5from gui.framsutils.creature import Creature
6from gui.framsutils.framsProperty import Property
7import glm
8
9class TreeNode:
10        def __init__(self, node: Property, children: List[Property] = None, parent: "TreeNode" = None) -> None:
11                self.node = node
12                self.parent = parent
13                self.children = []
14                if children is not None:
15                        for child in children:
16                                self.addChild(child)
17
18        def addChild(self, child):
19                assert isinstance(child, TreeNode)
20                self.children.append(child)
21
22        def setParent(self, parent):
23                self.parent = parent
24
25class InterfaceType(enum.Enum):
26        SOCKET = 1
27        LIB = 2
28
29class FramsInterface(ABC):
30        interfaceType: InterfaceType
31
32        @abstractmethod
33        def connect(self, address: str, port: int):
34                raise NotImplementedError
35
36        @abstractmethod
37        def disconnect(self):
38                raise NotImplementedError
39
40        @abstractmethod
41        def start(self):
42                raise NotImplementedError
43               
44        @abstractmethod
45        def getError(self):
46                raise NotImplementedError
47       
48        @abstractmethod
49        def stop(self):
50                raise NotImplementedError
51               
52        @abstractmethod
53        def step(self):
54                raise NotImplementedError
55               
56        @abstractmethod
57        def listTree(self, path="/") -> List[Property]:
58                raise NotImplementedError
59               
60        @abstractmethod
61        def listTreeList(self, path) -> List[Property]:
62                raise NotImplementedError
63
64        @abstractmethod
65        def makeInfoTree(self) -> TreeNode:
66                raise NotImplementedError
67       
68        @abstractmethod
69        def readCreatures(self, colors: Boolean) -> List[Creature]:
70                """read all creatures to render"""
71                raise NotImplementedError
72
73        @abstractmethod
74        def readGenePoolsGroups(self) -> Dict[str, int]:
75                """returns dict of {name, index} of gene pools groups."""
76                raise NotImplementedError
77
78        @abstractmethod
79        def readGenePools(self, props: List[str]) -> Dict[str, List[Dict[str, Any]]]:
80                """returns list of props and values for every gene pool group in format {gp group, [{prop, value}]}."""
81                raise NotImplementedError
82
83        @abstractmethod
84        def readPopulationsGroups(self) -> Dict[str, int]:
85                """returns dict of {name, index} of populations groups."""
86                raise NotImplementedError
87
88        @abstractmethod
89        def readPopulations(self, props: List[str]) -> Dict[str, List[Dict[str, Any]]]:
90                """returns list of props and values for every population group in format {pop group, [{prop, value}]}."""
91                raise NotImplementedError
92
93        @abstractmethod
94        def readCreatureDetails(self, group: int, index: str) -> List[Property]:
95                """read all details of creature specified by group and index."""
96                raise NotImplementedError
97
98        @abstractmethod
99        def readGenotypeDetails(self, group: int, index: str) -> List[Property]:
100                """read all details of genotype specified by group and index."""
101                raise NotImplementedError
102
103        @abstractmethod
104        def readParameterDetails(self, prop: str) -> List[Property]:
105                """read all property details, prop is the standard server path."""
106                raise NotImplementedError
107
108        @abstractmethod
109        def writeCreatureDetail(self, creatureNo: str, prop: str, value: str):
110                """write value to property of creature."""
111                raise NotImplementedError
112
113        @abstractmethod
114        def writeGenotypeDetail(self, genotypeNo: str, prop: str, value: str):
115                """write value to property of genotype."""
116                raise NotImplementedError
117
118        @abstractmethod
119        def writeParameterDetail(self, path: str, prop: str, value: str):
120                """write value to property of path."""
121                raise NotImplementedError
122
123        @abstractmethod
124        def getMotd(self) -> str:
125                """get message of the day."""
126                raise NotImplementedError
127
128        @abstractmethod
129        def loadFile(self, path: str) -> None:
130                """load file from path into frams."""
131                raise NotImplementedError
132
133        @abstractmethod
134        def importFile(self, path: str, options: int) -> None:
135                """import file from path into frams with options."""
136                raise NotImplementedError
137
138        @abstractmethod
139        def saveFile(self, path: str, options: int) -> None:
140                """save file into path from frams with options."""
141                raise NotImplementedError
142
143        @abstractmethod
144        def getWorldType(self) -> int:
145                """get type of the world."""
146                raise NotImplementedError
147
148        @abstractmethod
149        def getWorldSize(self) -> float:
150                raise NotImplementedError
151
152        @abstractmethod
153        def getWorldWaterLevel(self) -> float:
154                raise NotImplementedError
155
156        @abstractmethod
157        def getWorldBoundaries(self) -> int:
158                raise NotImplementedError
159
160        @abstractmethod
161        def getWorldMap(self) -> str:
162                """get geometry of the world."""
163                raise NotImplementedError
164
165        @abstractmethod
166        def getSimtype(self) -> int:
167                raise NotImplementedError
168
169        @abstractmethod
170        def getFPSDefinitions(self) -> List[Tuple[int, int]]:
171                """get list of the fps definitions for fps combobox
172                first value determines fps limit, second number of steps per frame.
173                """
174                raise NotImplementedError
Note: See TracBrowser for help on using the repository browser.