mirror of
https://github.com/naruxde/revpipycontrol.git
synced 2025-11-08 15:43:52 +01:00
first checkin
This commit is contained in:
35
revpipycontrol.e4p
Normal file
35
revpipycontrol.e4p
Normal file
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE Project SYSTEM "Project-5.1.dtd">
|
||||
<!-- eric project file for project revpipycontrol -->
|
||||
<!-- Saved: 2017-02-15, 20:52:17 -->
|
||||
<!-- Copyright (C) 2017 Sven Sager, akira@narux.de -->
|
||||
<Project version="5.1">
|
||||
<Language>en_US</Language>
|
||||
<Hash>66103e2eaf8a762f14d1fd51d8b1c9dcaf35a275</Hash>
|
||||
<ProgLanguage mixed="0">Python3</ProgLanguage>
|
||||
<ProjectType>Console</ProjectType>
|
||||
<Description></Description>
|
||||
<Version>0.1.0</Version>
|
||||
<Author>Sven Sager</Author>
|
||||
<Email>akira@narux.de</Email>
|
||||
<Eol index="-1"/>
|
||||
<Sources>
|
||||
<Source>revpipycontrol/__init__.py</Source>
|
||||
<Source>revpipycontrol/revpipycontrol.py</Source>
|
||||
</Sources>
|
||||
<Forms/>
|
||||
<Translations/>
|
||||
<Resources/>
|
||||
<Interfaces/>
|
||||
<Others/>
|
||||
<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"/>
|
||||
</FiletypeAssociations>
|
||||
</Project>
|
||||
0
revpipycontrol/__init__.py
Normal file
0
revpipycontrol/__init__.py
Normal file
96
revpipycontrol/revpipycontrol.py
Normal file
96
revpipycontrol/revpipycontrol.py
Normal file
@@ -0,0 +1,96 @@
|
||||
#!/usr/bin/python3
|
||||
#
|
||||
# (c) Sven Sager, License: GPLv3
|
||||
#
|
||||
# -*- coding: utf-8 -*-
|
||||
import tkinter
|
||||
from argparse import ArgumentParser
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
from xmlrpc.client import ServerProxy, Binary
|
||||
|
||||
class RevPiPyControl(tkinter.Frame):
|
||||
|
||||
def __init__(self, master=None):
|
||||
super().__init__(master)
|
||||
self.pack(fill="both", expand=True)
|
||||
|
||||
# Command arguments
|
||||
parser = ArgumentParser(
|
||||
description="Revolution Pi IO-Client"
|
||||
)
|
||||
parser.add_argument(
|
||||
"-a", "--address", dest="address", default="127.0.0.1",
|
||||
help="Server address (Default: 127.0.0.1)"
|
||||
)
|
||||
parser.add_argument(
|
||||
"-p", "--port", dest="port", type=int, default=55123,
|
||||
help="Use port to connect to server (Default: 55074)"
|
||||
)
|
||||
self.pargs = parser.parse_args()
|
||||
|
||||
self.cli = ServerProxy(
|
||||
"http://{}:{}".format(self.pargs.address, self.pargs.port)
|
||||
)
|
||||
|
||||
# Fenster aufbauen
|
||||
self._createwidgets()
|
||||
|
||||
# Daten aktualisieren
|
||||
self.plcrunning()
|
||||
|
||||
def _createwidgets(self):
|
||||
"""Erstellt den Fensterinhalt."""
|
||||
# Hauptfenster
|
||||
self.master.wm_title("RevPi Python PLC Loader")
|
||||
|
||||
self.var_status = tkinter.StringVar()
|
||||
self.txt_status = tkinter.Entry()
|
||||
self.txt_status["textvariable"] = self.var_status
|
||||
self.txt_status.pack(fill="x")
|
||||
|
||||
self.btn_plcrunning = tkinter.Button(self)
|
||||
self.btn_plcrunning["text"] = "PLC Status"
|
||||
self.btn_plcrunning["command"] = self.plcrunning
|
||||
self.btn_plcrunning.pack(fill="x")
|
||||
|
||||
self.btn_plcstart = tkinter.Button(self)
|
||||
self.btn_plcstart["text"] = "PLC Start"
|
||||
self.btn_plcstart["command"] = self.plcstart
|
||||
self.btn_plcstart.pack(fill="x")
|
||||
|
||||
self.btn_plcstop = tkinter.Button(self)
|
||||
self.btn_plcstop["text"] = "PLC Stop"
|
||||
self.btn_plcstop["command"] = self.plcstop
|
||||
self.btn_plcstop.pack(fill="x")
|
||||
|
||||
self.btn_plcrestart = tkinter.Button(self)
|
||||
self.btn_plcrestart["text"] = "PLC Restart"
|
||||
self.btn_plcrestart["command"] = self.plcrestart
|
||||
self.btn_plcrestart.pack(fill="x")
|
||||
|
||||
def plcstart(self):
|
||||
self.cli.plcstart()
|
||||
self.plcrunning()
|
||||
|
||||
def plcstop(self):
|
||||
self.cli.plcstop()
|
||||
self.plcrunning()
|
||||
|
||||
def plcrestart(self):
|
||||
self.cli.plcrestart()
|
||||
self.plcrunning()
|
||||
|
||||
def plcrunning(self):
|
||||
if self.cli.plcrunning():
|
||||
self.btn_plcrunning["activebackground"] = "green"
|
||||
self.btn_plcrunning["bg"] = "green"
|
||||
else:
|
||||
self.btn_plcrunning["activebackground"] = "red"
|
||||
self.btn_plcrunning["bg"] = "red"
|
||||
self.var_status.set(self.cli.plcexitcode())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
root = tkinter.Tk()
|
||||
myapp = RevPiPyControl(root)
|
||||
myapp.mainloop()
|
||||
Reference in New Issue
Block a user