Browse Source

ursprünglichen Entwicklungsstand als Python-Projekt konserviert

lookup-tables
Stephan Richter 5 years ago
parent
commit
1f0270fd98
  1. 114
      .cproject
  2. 6
      .eric6project/Web4Rail.e4q
  3. 7
      .eric6project/Web4Rail.e4t
  4. 27
      .project
  5. 25
      .settings/language.settings.xml
  6. BIN
      .spyderproject
  7. 48
      Web4Rail.e4p
  8. 1
      Web4Rail.pidaproject
  9. 1
      Web4Rail.sublime-workspace
  10. 0
      __init__.py
  11. 4
      doc/trackplan.md
  12. 52
      src/ConnectDialog.py
  13. 52
      src/FileDialog.py
  14. 22
      src/Plan.py
  15. 63
      src/TileSelector.py
  16. 8
      src/Tiles/Tile.py
  17. 87
      src/TrackPlan.py
  18. 32
      src/YesNoDialog.py
  19. 290311
      src/gi
  20. 59
      src/server.py
  21. 1728
      src/sys
  22. 72
      src/web4rail.client.py
  23. 107
      src/web4rail.server.py
  24. 29
      web4rail.nja

114
.cproject

@ -0,0 +1,114 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="cdt.managedbuild.config.gnu.cross.exe.debug.1405866861">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.cross.exe.debug.1405866861" moduleId="org.eclipse.cdt.core.settings" name="Debug">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.cross.exe.debug.1405866861" name="Debug" parent="cdt.managedbuild.config.gnu.cross.exe.debug">
<folderInfo id="cdt.managedbuild.config.gnu.cross.exe.debug.1405866861." name="/" resourcePath="">
<toolChain id="cdt.managedbuild.toolchain.gnu.cross.exe.debug.1644046727" name="Cross GCC" superClass="cdt.managedbuild.toolchain.gnu.cross.exe.debug">
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.targetPlatform.gnu.cross.1303766094" isAbstract="false" osList="all" superClass="cdt.managedbuild.targetPlatform.gnu.cross"/>
<builder buildPath="${workspace_loc:/Web4Rail}/Debug" id="cdt.managedbuild.builder.gnu.cross.672807853" managedBuildOn="true" name="Gnu Make Builder.Debug" superClass="cdt.managedbuild.builder.gnu.cross"/>
<tool id="cdt.managedbuild.tool.gnu.cross.c.compiler.694485957" name="Cross GCC Compiler" superClass="cdt.managedbuild.tool.gnu.cross.c.compiler">
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.option.optimization.level.1374057072" superClass="gnu.c.compiler.option.optimization.level" useByScannerDiscovery="false" valueType="enumerated"/>
<option id="gnu.c.compiler.option.debugging.level.918458422" superClass="gnu.c.compiler.option.debugging.level" useByScannerDiscovery="false" value="gnu.c.debugging.level.max" valueType="enumerated"/>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1047272473" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.cross.cpp.compiler.712082266" name="Cross G++ Compiler" superClass="cdt.managedbuild.tool.gnu.cross.cpp.compiler">
<option id="gnu.cpp.compiler.option.optimization.level.1000432263" superClass="gnu.cpp.compiler.option.optimization.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
<option id="gnu.cpp.compiler.option.debugging.level.1101437688" superClass="gnu.cpp.compiler.option.debugging.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1451312963" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.cross.c.linker.69818503" name="Cross GCC Linker" superClass="cdt.managedbuild.tool.gnu.cross.c.linker"/>
<tool id="cdt.managedbuild.tool.gnu.cross.cpp.linker.589676943" name="Cross G++ Linker" superClass="cdt.managedbuild.tool.gnu.cross.cpp.linker">
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.561428176" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
</inputType>
</tool>
<tool id="cdt.managedbuild.tool.gnu.cross.archiver.1740643252" name="Cross GCC Archiver" superClass="cdt.managedbuild.tool.gnu.cross.archiver"/>
<tool id="cdt.managedbuild.tool.gnu.cross.assembler.1601436733" name="Cross GCC Assembler" superClass="cdt.managedbuild.tool.gnu.cross.assembler">
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.248950993" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
</tool>
</toolChain>
</folderInfo>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
<cconfiguration id="cdt.managedbuild.config.gnu.cross.exe.release.508243853">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.cross.exe.release.508243853" moduleId="org.eclipse.cdt.core.settings" name="Release">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.cross.exe.release.508243853" name="Release" parent="cdt.managedbuild.config.gnu.cross.exe.release">
<folderInfo id="cdt.managedbuild.config.gnu.cross.exe.release.508243853." name="/" resourcePath="">
<toolChain id="cdt.managedbuild.toolchain.gnu.cross.exe.release.656568956" name="Cross GCC" superClass="cdt.managedbuild.toolchain.gnu.cross.exe.release">
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.targetPlatform.gnu.cross.1320265402" isAbstract="false" osList="all" superClass="cdt.managedbuild.targetPlatform.gnu.cross"/>
<builder buildPath="${workspace_loc:/Web4Rail}/Release" id="cdt.managedbuild.builder.gnu.cross.901795139" managedBuildOn="true" name="Gnu Make Builder.Release" superClass="cdt.managedbuild.builder.gnu.cross"/>
<tool id="cdt.managedbuild.tool.gnu.cross.c.compiler.1625123960" name="Cross GCC Compiler" superClass="cdt.managedbuild.tool.gnu.cross.c.compiler">
<option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.option.optimization.level.683944520" superClass="gnu.c.compiler.option.optimization.level" useByScannerDiscovery="false" valueType="enumerated"/>
<option id="gnu.c.compiler.option.debugging.level.195702395" superClass="gnu.c.compiler.option.debugging.level" useByScannerDiscovery="false" value="gnu.c.debugging.level.none" valueType="enumerated"/>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.621693658" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.cross.cpp.compiler.964533540" name="Cross G++ Compiler" superClass="cdt.managedbuild.tool.gnu.cross.cpp.compiler">
<option id="gnu.cpp.compiler.option.optimization.level.595512828" superClass="gnu.cpp.compiler.option.optimization.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/>
<option id="gnu.cpp.compiler.option.debugging.level.1810402969" superClass="gnu.cpp.compiler.option.debugging.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/>
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1870972976" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.cross.c.linker.2023937626" name="Cross GCC Linker" superClass="cdt.managedbuild.tool.gnu.cross.c.linker"/>
<tool id="cdt.managedbuild.tool.gnu.cross.cpp.linker.1050043689" name="Cross G++ Linker" superClass="cdt.managedbuild.tool.gnu.cross.cpp.linker">
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.1373475507" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
</inputType>
</tool>
<tool id="cdt.managedbuild.tool.gnu.cross.archiver.959963102" name="Cross GCC Archiver" superClass="cdt.managedbuild.tool.gnu.cross.archiver"/>
<tool id="cdt.managedbuild.tool.gnu.cross.assembler.685015797" name="Cross GCC Assembler" superClass="cdt.managedbuild.tool.gnu.cross.assembler">
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1734534501" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
</tool>
</toolChain>
</folderInfo>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<project id="Web4Rail.cdt.managedbuild.target.gnu.cross.exe.1280646856" name="Executable" projectType="cdt.managedbuild.target.gnu.cross.exe"/>
</storageModule>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.exe.debug.1405866861;cdt.managedbuild.config.gnu.cross.exe.debug.1405866861.;cdt.managedbuild.tool.gnu.cross.c.compiler.694485957;cdt.managedbuild.tool.gnu.c.compiler.input.1047272473">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.exe.release.508243853;cdt.managedbuild.config.gnu.cross.exe.release.508243853.;cdt.managedbuild.tool.gnu.cross.cpp.compiler.964533540;cdt.managedbuild.tool.gnu.cpp.compiler.input.1870972976">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.exe.debug.1405866861;cdt.managedbuild.config.gnu.cross.exe.debug.1405866861.;cdt.managedbuild.tool.gnu.cross.cpp.compiler.712082266;cdt.managedbuild.tool.gnu.cpp.compiler.input.1451312963">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.exe.release.508243853;cdt.managedbuild.config.gnu.cross.exe.release.508243853.;cdt.managedbuild.tool.gnu.cross.c.compiler.1625123960;cdt.managedbuild.tool.gnu.c.compiler.input.621693658">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
</cproject>

6
.eric6project/Web4Rail.e4q

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE UserProject SYSTEM "UserProject-4.0.dtd">
<!-- eric6 user project file for project Web4Rail -->
<!-- Saved: 2018-03-23, 10:04:21 -->
<!-- Copyright (C) 2018 Stephan Richter, s.richter@keawe.de -->
<UserProject version="4.0"/>

7
.eric6project/Web4Rail.e4t

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Tasks SYSTEM "Tasks-5.1.dtd">
<!-- eric6 tasks file for project Web4Rail -->
<!-- Saved: 2018-03-23, 10:04:21 -->
<Tasks version="5.1">
<ProjectScanFilter></ProjectScanFilter>
</Tasks>

27
.project

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Web4Rail</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.core.ccnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
</projectDescription>

25
.settings/language.settings.xml

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project>
<configuration id="cdt.managedbuild.config.gnu.cross.exe.debug.1405866861" name="Debug">
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="-1044391501587018433" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
</extension>
</configuration>
<configuration id="cdt.managedbuild.config.gnu.cross.exe.release.508243853" name="Release">
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="-1044391501587018433" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
</extension>
</configuration>
</project>

BIN
.spyderproject

Binary file not shown.

48
Web4Rail.e4p

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Project SYSTEM "Project-5.1.dtd">
<!-- eric project file for project Web4Rail -->
<!-- Saved: 2018-03-23, 10:01:18 -->
<!-- Copyright (C) 2018 Stephan Richter, s.richter@keawe.de -->
<Project version="5.1">
<Language>en_US</Language>
<Hash>592977616a6db25bc13c494da577efc597388eed</Hash>
<ProgLanguage mixed="0">Python3</ProgLanguage>
<ProjectType>PyQt5</ProjectType>
<Description></Description>
<Version>0.1</Version>
<Author>Stephan Richter</Author>
<Email>s.richter@keawe.de</Email>
<Sources>
<Source>src/web4rail.client.py</Source>
<Source>src/ConnectDialog.py</Source>
<Source>src/__init__.py</Source>
<Source>src/TrackPlan.py</Source>
<Source>src/web4rail.server.py</Source>
<Source>src/TileSelector.py</Source>
<Source>src/YesNoDialog.py</Source>
<Source>src/Tiles.py</Source>
<Source>src/server.py</Source>
<Source>src/FileDialog.py</Source>
<Source>__init__.py</Source>
</Sources>
<Forms/>
<Translations/>
<Resources/>
<Interfaces/>
<Others/>
<MainScript>src/web4rail.client.py</MainScript>
<Vcs>
<VcsType>None</VcsType>
</Vcs>
<FiletypeAssociations>
<FiletypeAssociation pattern="*.idl" type="INTERFACES"/>
<FiletypeAssociation pattern="*.py" type="SOURCES"/>
<FiletypeAssociation pattern="*.py3" type="SOURCES"/>
<FiletypeAssociation pattern="*.pyw" type="SOURCES"/>
<FiletypeAssociation pattern="*.pyw3" type="SOURCES"/>
<FiletypeAssociation pattern="*.qm" type="TRANSLATIONS"/>
<FiletypeAssociation pattern="*.qrc" type="RESOURCES"/>
<FiletypeAssociation pattern="*.ts" type="TRANSLATIONS"/>
<FiletypeAssociation pattern="*.ui" type="FORMS"/>
</FiletypeAssociations>
</Project>

1
Web4Rail.pidaproject

@ -0,0 +1 @@
name = Web4Rail

1
Web4Rail.sublime-workspace vendored

@ -0,0 +1 @@
{}

0
src/__init__.py → __init__.py

4
doc/trackplan.md

@ -1,4 +1,4 @@
# Dateiaufbau für Anlagenplan: # Dateiaufbau für Anlagenplan:
plan.layout: Textdatei mit Einbuchstabencodes für Tiles, siehe tiles.dia `plan.layout`: Textdatei mit Einbuchstabencodes für Tiles, siehe tiles.dia
plan.config: Textdatei im Format `xxx yyy block-num config-string` `plan.config`: Textdatei im Format `xxx yyy block-num config-string`

52
src/ConnectDialog.py

@ -1,52 +0,0 @@
#!/usr/bin/python
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
class ConnectDialog(Gtk.Window):
host = None
port = None
def __init__(self):
Gtk.Window.__init__(self, title="Connect to server")
self.connect("delete-event", Gtk.main_quit)
grid = Gtk.Grid()
self.add(grid)
self.host_label = Gtk.Label('Hostname or IP')
self.host_input = Gtk.Entry()
self.host_input.set_text('localhost')
self.port_label = Gtk.Label('Port')
self.port_input = Gtk.Entry()
self.port_input.set_text('7668')
self.connect_btn = Gtk.Button(label="Connect")
self.connect_btn.connect("clicked", self.finish)
self.abort_btn = Gtk.Button(label="Abort")
self.abort_btn.connect("clicked", self.abort)
grid.attach(self.host_label, 0, 0, 1, 1)
grid.attach(self.host_input, 1, 0, 1, 1)
grid.attach(self.port_label, 0, 1, 1, 1)
grid.attach(self.port_input, 1, 1, 1, 1)
grid.attach(self.abort_btn, 0, 2, 1, 1)
grid.attach(self.connect_btn, 1, 2, 1, 1)
def abort(self, widget):
Gtk.main_quit()
def run(self):
self.show_all()
Gtk.main()
def finish(self, widget):
self.host = self.host_input.get_text()
self.port = int(self.port_input.get_text())
self.hide()
Gtk.main_quit()

52
src/FileDialog.py

@ -1,52 +0,0 @@
#!/usr/bin/python
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
class FileDialog(Gtk.Window):
def __init__(self,title,hint):
Gtk.Window.__init__(self, title=title)
self.connect("delete-event", Gtk.main_quit)
self.hint = Gtk.Label(hint);
self.dir_grid = Gtk.Grid()
self.dir_input = Gtk.Entry();
self.new_btn = Gtk.Button('Create')
self.new_btn.connect('clicked',self.new_btn_clck)
self.y = 0
def add_dir(self,name):
btn = Gtk.Button(label=name)
btn.connect("clicked",self.select_dir)
self.dir_grid.attach(btn,0,self.y,1,1)
self.y+=1
def new_btn_clck(self,widget):
self.dir = self.dir_input.get_text()
self.hide()
Gtk.main_quit()
def run(self):
scroll = Gtk.ScrolledWindow(hexpand=True, vexpand=True)
grid = Gtk.Grid()
scroll.add(self.dir_grid)
grid.attach(self.hint, 0,0,2,1)
grid.attach(scroll, 0,1,2,1)
grid.attach(self.dir_input, 0,2,1,1)
grid.attach(self.new_btn, 1,2,1,1)
self.add(grid)
self.set_size_request( 300, 900)
self.show_all()
Gtk.main()
def select_dir(self,widget):
self.dir = widget.get_label()
self.hide()
Gtk.main_quit()

22
src/Plan.py

@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
import gtk
class Plan():
def load(self,filename):
file = open(filename,'r')
lines = file.readlines()
print(lines)
dialog = gtk.FileChooserDialog("Open...",
None,
gtk.FILE_CHOOSER_ACTION_OPEN,
(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK))
response = dialog.run();
if response == gtk.RESPONSE_OK:
plan = Plan();
plan.load(dialog.get_filename())
dialog.destroy()

63
src/TileSelector.py

@ -1,63 +0,0 @@
#!/usr/bin/python
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
from Tiles import *
class TileSelector(Gtk.Window):
def __init__(self,connection):
Gtk.Window.__init__(self)
self.connect("destroy", Gtk.main_quit)
self.grid = Gtk.Grid()
x0=0
x1=0
x2=0
if connection in {Tile.LEFT,Tile.RIGHT,None}:
self.add_tile(StraightH,x0,0)
x0+=1
if connection in {Tile.TOP,Tile.BOTTOM,None}:
self.add_tile(StraightV,x0,0)
x0+=1
if connection in {Tile.TOP,Tile.LEFT,None}:
self.add_tile(Diag_TL,x1,1)
x1+=1
if connection in {Tile.TOP,Tile.RIGHT,None}:
self.add_tile(Diag_TR,x1,1)
x1+=1
if connection in {Tile.BOTTOM,Tile.RIGHT,None}:
self.add_tile(Diag_BR,x1,1)
x1+=1
if connection in {Tile.BOTTOM,Tile.LEFT,None}:
self.add_tile(Diag_BL,x1,1)
x1+=1
if connection in {Tile.BOTTOM,Tile.LEFT,Tile.RIGHT,None}:
self.add_tile(TO_BRL,0,2)
self.add_tile(TO_BLR,1,2)
if connection in {Tile.TOP,Tile.LEFT,Tile.RIGHT,None}:
self.add_tile(TO_TRL,0,3)
self.add_tile(TO_TLR,1,3)
self.add(self.grid)
self.show_all()
Gtk.main()
def add_tile(self,tile_class,x,y):
tile = tile_class()
tile.connect('button-press-event',self.select)
self.grid.attach(tile,x,y,1,1)
def select(self,btn,evt):
self.tile = btn.__class__
self.hide()
Gtk.main_quit()

8
src/Tiles/Tile.py

@ -0,0 +1,8 @@
# -*- coding: utf-8 -*-
class Tile():
def x(self):
raise NotImplementedError('Tile.x')
def y(self):
raise NotImplementedError('Tile.x')

87
src/TrackPlan.py

@ -1,87 +0,0 @@
#!/usr/bin/python
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
from TileSelector import *
import os
def dump_obj(obj, key='', level = 0):
for key, value in obj.__dict__.items():
if isinstance(value, (int, float, str, unicode, list, dict, set)):
print(" " * level + "%s -> %s" % (key, value))
else:
print(" " * level + "%s -> %s:" % (key, value.__class__.__name__))
dump_obj(value, key, level + 2)
class TrackPlan(Gtk.Window):
def __init__(self,json,server_sock):
Gtk.Window.__init__(self)
print(json)
self.server_sock = server_sock
self.connect("delete-event", Gtk.main_quit)
self.grid = Gtk.Grid()
self.putButton(0,0,None,None)
self.add(self.grid)
def select_tile(self,widget,origin,connection):
#print 'Button at ({},{}) pressed'.format(widget.x, widget.y)
tileSelector = TileSelector(connection)
tile = tileSelector.tile()
if origin != None:
if connection == Tile.TOP:
origin.bottom = tile
if connection == Tile.RIGHT:
origin.left = tile
if connection == Tile.BOTTOM:
origin.top = tile
if connection == Tile.LEFT:
origin.right = tile
self.putTile(tile,widget.x,widget.y)
widget.destroy()
def putButton(self,x,y,origin,connection):
#print 'putButton({},{})'.format(x,y)
btn = Gtk.Button('?')
btn.x = x
btn.y = y
btn.connect('clicked',self.select_tile,origin,connection)
self.grid.attach(btn,x,y,1,1)
btn.show()
def putTile(self,tile,x,y):
#print 'putTile({},{})'.format(x,y)
tile.x = x
tile.y = y
self.grid.attach(tile,x,y,1,1)
tile.show()
if tile.connects_left():
left = self.grid.get_child_at(x-1,y)
if left == None:
self.putButton(x-1,y,tile,Tile.RIGHT)
if tile.connects_right():
right = self.grid.get_child_at(x+1,y)
if right == None:
self.putButton(x+1,y,tile,Tile.LEFT)
if tile.connects_up():
top = self.grid.get_child_at(x,y-1)
if top == None:
self.putButton(x,y-1,tile,Tile.BOTTOM)
if tile.connects_down():
bottom = self.grid.get_child_at(x,y+1)
if bottom == None:
self.putButton(x,y+1,tile,Tile.TOP)
self.save()
def run(self):
self.show_all()
Gtk.main()
def save(self):
seed_tile = self.grid.get_child_at(0,0)
os.system('clear')
self.server_sock.send('UPDATE PLAN')
self.server_sock.send(seed_tile.json())
print('Sent plan')

32
src/YesNoDialog.py

@ -1,32 +0,0 @@
#!/usr/bin/python
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
class YesNoDialog(Gtk.Window):
def __init__(self,question):
Gtk.Window.__init__(self)
self.connect("delete-event", Gtk.main_quit)
grid = Gtk.Grid()
question = Gtk.Label(question);
yes = Gtk.Button('Yes')
yes.connect('clicked',self.evaluate)
no = Gtk.Button('No')
no.connect('clicked',self.evaluate)
grid.attach(question,0,0,2,1)
grid.attach(yes,0,1,1,1)
grid.attach(no,1,1,1,1)
self.add(grid)
self.answer = None
self.show_all()
Gtk.main()
def evaluate(self,widget):
self.answer=widget.get_label() == 'Yes'
self.hide()
Gtk.main_quit()

290311
src/gi

File diff suppressed because it is too large Load Diff

59
src/server.py

@ -1,59 +0,0 @@
'''
Simple socket server using threads
'''
import socket
import sys
from thread import *
HOST = '' # Symbolic name meaning all available interfaces
PORT = 8888 # Arbitrary non-privileged port
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print 'Socket created'
#Bind socket to local host and port
try:
s.bind((HOST, PORT))
except socket.error as msg:
print 'Bind failed. Error Code : ' + str(msg[0]) + ' Message ' + msg[1]
sys.exit()
print 'Socket bind complete'
#Start listening on socket
s.listen(10)
print 'Socket now listening'
#Function for handling connections. This will be used to create threads
def clientthread(conn):
#Sending message to connected client
conn.send('Welcome to the server. Type something and hit enter\n') #send only takes string
#infinite loop so that function do not terminate and thread do not end.
while True:
#Receiving from client
data = conn.recv(1024).strip()
if data == 'exit':
conn.sendall('Bye!')
break
reply = 'OK...' + data
if not data:
break
conn.sendall(reply)
#came out of loop
conn.close()
#now keep talking with the client
while 1:
#wait to accept a connection - blocking call
conn, addr = s.accept()
print 'Connected with ' + addr[0] + ':' + str(addr[1])
#start new thread takes 1st argument as a function name to be run, second is the tuple of arguments to the function.
start_new_thread(clientthread ,(conn,))
s.close()

1728
src/sys

File diff suppressed because it is too large Load Diff

72
src/web4rail.client.py

@ -1,72 +0,0 @@
#!/usr/bin/python
import socket
from ConnectDialog import *
from FileDialog import *
from TrackPlan import *
from YesNoDialog import *
def readline(socket):
buff = socket.recv(4096)
buffering = True
while buffering:
if "\n" in buff:
(line, buff) = buff.split("\n", 1)
yield line
else:
more = socket.recv(4096)
if not more:
buffering = False
else:
buff += more
if buff:
yield buff
print ('starting')
conn_dlg = ConnectDialog()
conn_dlg.run()
if conn_dlg.port is not None:
client_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client_sock.connect((conn_dlg.host, conn_dlg.port))
client = readline(client_sock)
current_dir = ''
while True:
line = client.next()
if line.startswith('current dir'):
current_dir = line
continue
if line.startswith('select one'):
file_dialog = FileDialog(line, current_dir)
while True:
line = client.next()
if line.startswith('--'):
break
file_dialog.add_dir(line.strip())
file_dialog.run()
client_sock.send(file_dialog.dir + "\n")
continue
if line == 'PLAN:':
json = client.next()
plan = TrackPlan(json, client_sock)
plan.run()
client_sock.send('EXIT')
break
continue
if 'does not exist. Create' in line:
directory = line.split('does not exist')[0].strip()
dialog = YesNoDialog(line)
if dialog.answer:
client_sock.send("yes\n")
else:
client_sock.send("no\n")
continue
print(line)
print "Test"

107
src/web4rail.server.py

@ -1,107 +0,0 @@
#!/usr/bin/python
import socket
import sys
import os
from thread import *
class web4rail_server:
system = None
halt = False
def __init__(self, port):
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
print('Socket created.')
try:
self.socket.bind(('', port))
except socket.error as msg:
print('Bind failed. Error (' + str(msg[0]) + '): ' + str(msg[1]))
sys.exit(-1)
print('Bound to socket at port ' + str(port))
def client(self, conn):
if self.system is None:
self.system = self.select_system(conn)
self.load_system(conn)
while True:
response = conn.recv(1024).strip()
if response == 'UPDATE PLAN':
self.update_plan(conn)
elif response == 'EXIT':
break
else:
print(response)
os._exit(0)
# creates a new json file at the selected dir
def create_system(self, path):
print('creating new system at ' + path)
os.mkdir(path, 0o755)
json_file = open(path + '/plan.json', 'w+')
json_file.close()
def load_system(self, conn):
print('loading system from ' + self.system)
with open(self.system + '/plan.json', 'r') as plan_file:
plan = plan_file.read()
conn.send("PLAN:\n")
conn.send(plan + "\n")
def select_system(self, conn):
path = '/home/srichter/workspace/Web4Rail/'
conn.send("Welcome to the Web2Rail server. Please select a SYSTEM first:\n")
while True:
conn.send('current dir: ' + path + "\n")
contents = sorted(os.listdir(path))
conn.send("select one from\n")
for entry in contents:
conn.send(' ' + entry + "\n")
conn.send("--\n")
entry = conn.recv(1024).strip()
if entry in contents:
if os.path.isfile(path + entry):
break
path += entry + '/'
else:
conn.send(path + entry + ' does not exist. Create (yes/no/abort)?\n')
response = conn.recv(1024).strip()
if response == 'yes':
path += entry
self.create_system(path)
break
if response == 'abort':
path = None
break
path = '/'
if path is None:
return
return path
def start(self):
self.socket.listen(10)
print('Server started.')
while True:
conn, add = self.socket.accept()
start_new_thread(self.client, (conn,))
print('Closing server')
def update_plan(self,conn):
json = conn.recv(32768).strip()
json_file = open(self.system + '/plan.json', 'w')
json_file.write(json)
json_file.close()
if len(sys.argv) == 2:
port = int(sys.argv[1])
else:
port = 7668
server = web4rail_server(port)
server.start()

29
web4rail.nja

@ -0,0 +1,29 @@
{
"mainFile": "src/web4rail.client.py",
"use-tabs": false,
"venv": "",
"relatedProjects": [],
"name": "Web4Rail",
"license": "GNU General Public License v3",
"url": "",
"pythonPath": "python",
"preExecScript": "",
"additional_builtins": [],
"programParams": "",
"indentation": 4,
"PYTHONPATH": "",
"supported-extensions": [
".py",
".html",
".jpg",
".png",
".ui",
".css",
".json",
".js",
".ini"
],
"project-type": "Import from sources",
"postExecScript": "",
"description": "Model Rail Control Application"
}
Loading…
Cancel
Save