-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added general compability for tableGenerator (SWTbahn-Game) #132
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Jochen Mehlich <[email protected]>
Signed-off-by: Jochen Mehlich <[email protected]>
Signed-off-by: Jochen Mehlich <[email protected]>
Signed-off-by: Jochen Mehlich <[email protected]>
Signed-off-by: Jochen Mehlich <[email protected]>
Signed-off-by: Jochen Mehlich <[email protected]>
Signed-off-by: Jochen Mehlich <[email protected]>
…ion file Signed-off-by: Jochen Mehlich <[email protected]>
Signed-off-by: Jochen Mehlich <[email protected]>
Signed-off-by: Jochen Mehlich <[email protected]>
Signed-off-by: Jochen Mehlich <[email protected]>
Have you tested that the Game still works? I don't think the Game works anymore. The generated |
Currently the platforms have to been set manual. For an automatic solution the issue #131 have to be fixed. |
Signed-off-by: Jochen Mehlich <[email protected]>
blacklist feature is now added |
Are you also testing that the initial loading of the game script still works? |
shouldnt work currently cause the dependency selection is broken (need who am I API). |
For pull requests to be merged, the software needs to run correctly. We can't leave the software in a broken state. function getPlatformName() {
return "swtbahn-full";
} Use this function in the |
Signed-off-by: Jochen Mehlich <[email protected]>
need to be verified next week on hardware |
var allPossibleDestinations = null; | ||
var signalFlagMap = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of removing the comments, improve/adapt them to fit the new situation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably better to keep the old-style comments, which offer a clearer per-variable explanation (i.e., what is each var for)
### Map the Signals with the Symbols | ||
* Create a CSV Document with the following Scheme to the flagMappingsFolder (it should have the same name, like the configuration folder): [signalId],[coloCode] | ||
* insert your mapping attributes | ||
* link the csv to generator.py and converter.py |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand what that means
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not yet resolved, still unclear what this means.
* link the csv to generator.py and converter.py | ||
* run generator.py | ||
* run converter.py | ||
* link the generated files to the game |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does "link" mean here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still unclear.
Signed-off-by: Jochen Mehlich <[email protected]>
Signed-off-by: Jochen Mehlich <[email protected]>
Signed-off-by: Jochen Mehlich <[email protected]>
Signed-off-by: Jochen Mehlich <[email protected]>
Signed-off-by: Jochen Mehlich <[email protected]>
Signed-off-by: Jochen Mehlich <[email protected]>
var signalFlagMap = null; | ||
|
||
function getPlatformName(){ | ||
return "swtbahn-full"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a "/// TODO:" here with a comment to indicate that this will need to be adapted once the corresponding server endpoint exists.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(also will have to think about error handling in the future here, as well as blocking this to only return once ready)
# Table Generator for SWTbahn Game | ||
|
||
This python script generates the configuration json files for the swtbahn game client, which are required for the signal-symbol mapping and the route suggestion mechanics. | ||
The script will automatically find a suitable route (which the least nodes) and store it for the game client, it will do this action only for signals which are listed in the mapping-csv to reduce storage usage. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"The script will automatically find a suitable route" -> to where? The latter part of the sentence implies it is done with all signals from the mapping-csv as the source, but it is not quite clear where these routes are leading.
"which the least nodes" -> grammar/incorrect english; rather say something like "find the shortest possible route from ... /(for all..) to ..." or something like that.
|
||
## How to get started | ||
### Map the Signals with the Symbols | ||
* Create a CSV Document with the following Scheme to the flagMappings directory (the filename should match with the name of the configuration folder of the model railway): [signalId],[colorCode] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Scheme" -> "content formatting"
"to the flagMappings directory" -> "in the flagMappings directory"
### Map the Signals with the Symbols | ||
* Create a CSV Document with the following Scheme to the flagMappingsFolder (it should have the same name, like the configuration folder): [signalId],[coloCode] | ||
* insert your mapping attributes | ||
* link the csv to generator.py and converter.py |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not yet resolved, still unclear what this means.
* link the csv to generator.py and converter.py | ||
* run generator.py | ||
* run converter.py | ||
* link the generated files to the game |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still unclear.
Signed-off-by: Jochen Mehlich <[email protected]>
Signed-off-by: Jochen Mehlich <[email protected]>
Signed-off-by: Jochen Mehlich <[email protected]>
Signed-off-by: Jochen Mehlich <[email protected]>
Signed-off-by: Jochen Mehlich <[email protected]>
Signed-off-by: Jochen Mehlich <[email protected]>
Signed-off-by: Jochen Mehlich <[email protected]>
…tity name string Signed-off-by: Jochen Mehlich <[email protected]>
Signed-off-by: Jochen Mehlich <[email protected]>
Signed-off-by: Jochen Mehlich <[email protected]>
Signed-off-by: Jochen Mehlich <[email protected]>
Signed-off-by: Jochen Mehlich <[email protected]>
works. |
namedMap = "allPossibleDestinations_" + platform; | ||
str = "allPossibleDestinations =" + namedMap; | ||
eval (str); | ||
namedMap = "signalFlagMap_" + platform; | ||
str = "signalFlagMap =" + namedMap; | ||
eval (str); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate code?
@@ -796,6 +805,16 @@ function initialise() { | |||
null // trainId | |||
); | |||
|
|||
var platform = getPlatformName(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const
namedMap = "allPossibleDestinations_" + platform; | ||
str = "allPossibleDestinations =" + namedMap; | ||
eval (str); | ||
namedMap = "signalFlagMap_" + platform; | ||
str = "signalFlagMap =" + namedMap; | ||
eval (str); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't reuse variables (namedMap
, str
) for different purposes!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not limit the evaluation to the rhs of each variable assignment?
allPossibleDestinations = eval("allPossibleDestinations_" + platform);
signalFlagMap = eval("signalFlagMap_" + platform);
Doing: | ||
Roll over all Blocks and search for a RouteID for the destination and insert the details based on start block, destination signal. Data were read from the interlocking table | ||
""" | ||
originalResultData = copy.copy(copy.copy(resultData)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why double copy?
destinations.append(destination) | ||
destinationsSorted = [] | ||
print(destinations) | ||
with open(groupingFile, "r") as csvFile: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just open the readonly file groupingFile
once at the start of this function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better aproach because it closes the file automatically so it use less ressources.
flagMappings = [] | ||
for entry in mappingFolderContent: | ||
if entry.is_file() and entry.name[-4:] == ".csv": | ||
flagMappings.append(entry.name[:-4]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does flagMappings
have to be recomputed all the time?
|
||
blocktypes = ["blocks", "platforms"] | ||
|
||
for blockType in blocktypes: # Roll over all Blocktypes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the goal of this loop? Could be simplified if I knew its goal...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
loop over the two blocktypes which we currrently have in our interlocking file (platforms + blocks), but also has the option to extend it, if we need.
if int(number) == 6: | ||
number = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this? numberToWord(6)
would return "Six".
number %= 7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
currently we dont have six as symbol
|
||
## Requirements | ||
* Python3 | ||
* Configuration w for the model railway |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"w"?
Where do you expect the files to be?
![](docs/rw5.png) | ||
|
||
## How to get started | ||
### Map the Signals with the Symbols |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is your working directory located?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its relative, so in the same folder like the markdown file - should be fine.
Signed-off-by: Jochen Mehlich <[email protected]>
Signed-off-by: Jochen Mehlich <[email protected]>
Signed-off-by: Jochen Mehlich <[email protected]>
Signed-off-by: Jochen Mehlich <[email protected]>
Signed-off-by: Jochen Mehlich <[email protected]>
Changed the tableGenerator to automatically generate all configuration files which are needed for the driver-game, as soon a mappingFile is existing.