Beispiel #1
0
def main():

    interface = module('INTERFACE', config)
    count = 0
    response = "0"

    while True:
        try:
            sockets = dict(interface.poller.poll(10))
            if interface.socket in sockets:

                MESSAGE = interface.receive()
                CORE = interface.extract_core(MESSAGE)

                request = CORE["request"]

                RESPONSE = interface.create_message(TO=MESSAGE,
                                                    CORE={
                                                        "current position":
                                                        response,
                                                        "current loop": count
                                                    })
                interface.send(RESPONSE)

            count += 1
            response = "{}°".format(randint(0, 360))

        except KeyboardInterrupt:
            break
Beispiel #2
0
def main():

    system = module('SYSTEM', config)


    while True:
        try:

            MESSAGE = system.receive()
            CORE = system.extract_core(MESSAGE)


            request = CORE["request"]
            if request == 'A':
                sys_function_A.main()
            elif request == 'B':
                sys_function_B.main()
            elif request == 'C':
                sys_function_C.main()

            response = "function has been executed"


            RESPONSE = system.create_message(TO = MESSAGE, CORE = {request : response})
            system.send(RESPONSE)


        except KeyboardInterrupt:
            break
def main():

    remote_maintenance = module('API_MAINTENANCE', config)

    while True:
        try:

            MESSAGE = remote_maintenance.receive()
            CORE = remote_maintenance.extract_core(MESSAGE)

            request = CORE["request"]

            if request == "run maintenance protocol A1":

                response = "the maintenance protocol was successfully completed"

            elif request == "run maintenance protocol C3":

                REQUEST = remote_maintenance.create_message(
                    TO='DATABASE', CORE={"request": "school"})
                remote_maintenance.send(REQUEST)

                MESSAGE_2 = remote_maintenance.receive()

                response = remote_maintenance.extract_core(MESSAGE_2)

            RESPONSE = remote_maintenance.create_message(
                TO=MESSAGE, CORE={request: response})
            remote_maintenance.send(RESPONSE)

        except KeyboardInterrupt:
            break
Beispiel #4
0
def main():

    httpout = module('HTTPOUT', config)


    while True:
        try:

            MESSAGE = httpout.receive()
            CORE = httpout.extract_core(MESSAGE)


            request = CORE["request"]
            main_api = request['main_api']
            address = request["address"]
            url = main_api + urllib.parse.urlencode({'address':address})
            response = requests.get(url).json()
            


            RESPONSE = httpout.create_message(TO= MESSAGE, CORE = response)
            httpout.send(RESPONSE)


        except KeyboardInterrupt:
            break
Beispiel #5
0
    def server_starten(self):
        self.message_lenght = 1024
        self.server_con = module.module('ROBO_GUI_SHADOW',
                                        configuration.config)
        'Verbindungs Socket aktivieren'
        try:
            self.verb = socket(AF_INET, SOCK_STREAM)
            self.verb.bind(('localhost', 60112))
            self.verb.listen(5)
        except OSError:
            print('Already running, terminating')
            exit()

        'Information ausgeben'
        print('Ausgangsserver läuft und hört zu...')

        while True:
            try:
                '''Verbindungsanfrage akzeptieren. Es werden der 
                Kommunikationssocket und das Adressobjekt des
                Verbindungspartners zurückgegeben.'''
                self.komm, addr = self.verb.accept()

                #                request = CORE_pyobj["request"]
                #                response = data[request].to_dict()
                #                for key in response:
                #                    response = str(response)

                'Daten vom Client empfangen'
                #Datentyp von data: bytes
                data = self.recv_msg(self.komm)
                #                print(data)
                data_split = data.split(b'&')
                MESSAGE = data_split
                antwort = str(data_split[2])

                self.nachricht_kompl_e = MESSAGE[2].decode('ascii')

                MESSAGE = self.create_traitor(CORE_pyobj=antwort,
                                              MESSAGE_received=MESSAGE)
                self.server_con.send(MESSAGE)

                if not data:
                    self.komm.close()

            except ConnectionRefusedError:
                print("Keine Robotersteuerung aktiv")
            except ConnectionAbortedError:
                print('Connection aborted.')
            except ConnectionResetError:
                print('Connection to GUI lost')
Beispiel #6
0
    def server_starten(self):

        self.message_lenght = 1024
        server_con = module.module('ROBO_GUI', configuration.config)

        'Verbindungssocket instanziieren'
        #IPv4-Protokoll und TCP
        #        self.verb = socket(AF_INET, SOCK_STREAM)
        #        verbinde = True
        #        while verbinde == True:
        #            try:
        #                self.verb.connect(('localhost', 60111))
        #                verbinde = False
        #            except ConnectionRefusedError:
        #                sleep(1/10)
        #            except OSError:
        #                print("OSERROR")

        'Verbindungssocket an eine IP-Adresse und einen Port binden'
        #lokale IP-Adresse und Port 60000

        'Information ausgeben'
        print('Eingangsserver läuft und hört zu...')

        while True:
            try:
                '''Verbindungsanfrage akzeptieren. Es werden der 
                Kommunikationssocket und das Adressobjekt des
                Verbindungspartners zurückgegeben.'''

                #                request = CORE_pyobj["request"]
                #                response = data[request].to_dict()
                #                for key in response:
                #                    response = str(response)

                'Daten vom Client empfangen'
                #Datentyp von data: bytes

                MESSAGE_list = server_con.receive()
                #            print(MESSAGE)
                #                print(type(MESSAGE_list[0]))
                #                print(type(MESSAGE_list[1]))
                #                print(type(MESSAGE_list[2]))
                MESSAGE_str = MESSAGE_list[0] + str('&').encode(
                    'ascii') + MESSAGE_list[1] + str('&').encode(
                        'ascii') + MESSAGE_list[2][1:-1]
                #                print("Inhalt der Nachricht: ", MESSAGE_str)
                self.verb = socket(AF_INET, SOCK_STREAM)
                self.verb.connect(('localhost', 60111))
                self.send_msg(self.verb, MESSAGE_str)
                print("Nachricht weitergeleitet: ", MESSAGE_str)
                self.verb.close()

            except ConnectionRefusedError:
                print("Keine Robotersteuerung aktiv")
            except ConnectionAbortedError:
                print('Connection aborted.')
            except ConnectionResetError:
                print('Connection to GUI lost')
            except OSError:
                print("OSERROR Type 2")
                self.verb = socket(AF_INET, SOCK_STREAM)
                self.verb.connect(('localhost', 60111))
Beispiel #7
0
try:
    to_unicode = unicode
except NameError:
    to_unicode = str

#######################################################################################################
"""""" """""" """""" " 3) WEBPAGE BUILD " """""" """""" """""" """""" """""" """""" ""
#######################################################################################################
from robot_control import robot_control
from structure.configuration import config
from structure.module import module

# use flask module

app = Flask(__name__)
robotserver = module('ROBOTER_SERVER', config)
""" Login homepage """


@app.route('/')
@crossdomain(origin='*')
def login_robot():
    return render_template('Login.html')


#### important for robot remote control: get requests are processed here
@app.route('/bosch2.html/query', methods=['GET'])
@crossdomain(origin='*')
def bosch2_query():
    with open(os.getcwd() + '/data/data.json') as data_file:
        json_data = json.load(data_file)
Beispiel #8
0
from flask import Flask, jsonify, request, render_template
import json

from structure.configuration import config
from structure.module import module


app = Flask(__name__)
httpin = module('HTTPIN', config)



@app.route('/')
def index():
    return render_template("index.html")


@app.route('/apis', methods=['GET','POST'])
def apis():
    if request.method == 'POST':
        if request.form:
            postjson = request.form['JSON']
            postjson = json.loads(postjson)
            api_name = postjson['api_name']
            api_data = postjson['api_data']

            if config.get(api_name, False):
                try:
                    REQUEST = httpin.create_message(TO = api_name, CORE = api_data)
                    httpin.send(REQUEST)
                    MESSAGE = httpin.receive()
Beispiel #9
0
def main():

    VerwaltungsschaleDatenbank = module('VerwaltungsschaleDatenbank', config)

    #==============================================================================
    'Input Paket als Dictonary'
    # für den Beispielmodus

    AufrufDict = {
        'Suchoption': 'SucheDurchName',
        'ArtAusgabe': 'ElementName',
        'MengeAusgabe': 'alle',
        'Element_Name': 'omm:element',
        'Attribut_Name': '',
        'Pfad':
        '<PlayerCharacter>/<EquippedItems>/<Slot[1]>/<ItemPropertyList>/<ItemProperty>',
        'SucheDurchNameMenge': 'alle'
    }

    OMMAufrufDict = {'SuchText': 'Memory_App', 'SuchArt': 'direkt'}

    IDDict = {'BlockID': '00000'}

    newDict = {
        'New': 'block',
        'Filename': 'Testlauf_Erstellen_main.xml',
        'PrimaryID_URL': 'http://ichbineinbeispiel/1/',
        'Title english': '#######T#######',
        'Titel deutsch': '#######T#######',
        'Namespace': '',
        'Description english': '#######D#######',
        'Beschreibung deutsch': '#######D#######',
        'Creator': '123456789',
        'Subject': '',
        'ID_URL_Subject': '',
        'Payload': ''
    }

    BlockBearbDict = {
        'BlockID': '00000',
        'Metadaten': 'namespace',
        'String': '---NEW---'
    }

    #==============================================================================
    'DatenbankDaten'

    # Dateipfad bis VerwaltungsschaleDatenbank
    basispfad = getcwd()
    # Dateipfad der DatenbankDaten
    Datenordner = path.join(basispfad, "DatenbankDaten")

    # Header-Dokument in der XML-Dokumenten-Hierarchie
    HauptSpeicher = (Datenordner + '\OMM_Memory_VS_main.xml')

    # für den Beispielmodus
    Speicher = (Datenordner + '\Testlauf_Erstellen_main.xml')  # zum Testen
    Speicher2 = (Datenordner + '\Testlauf_Erstellen_123456789.xml'
                 )  # zum Testen

    #==============================================================================

    while True:
        try:

            erg = 'Fehler!'

            'Input Paket'
            #HIER SOLL ER IMMER BEI LAUFENDEM PROGRAMM AUF EIN PAKET WARTEN
            MESSAGE = VerwaltungsschaleDatenbank.receive()
            CORE = VerwaltungsschaleDatenbank.extract_core(MESSAGE)
            Paket = CORE["request"]
            print(Paket)

            'Verarbeitung Paket'
            Link = HauptSpeicher
            Aktion = None
            Dict = {}

            Link = Paket['Link']
            Aktion = Paket['Aktion']
            Dict = Paket['Dict']

            'Aktion durchführen'  # DAS IST IM MOMENT EGAL; DA KÜMMER ICH MICH SELBST DRUM
            if Aktion == '8':
                erg = {'Ergebnis': DatenListe()}
            if Aktion == '9':
                erg = XMLClass(Link).XMLBaum()
            if Aktion == '10':
                erg = XMLClass(Link).XMLStruktur()
            if Aktion == '11':
                erg = XMLClass(Link).XMLWurzel()
            if Aktion == '12':
                erg = XMLClass(Link).XMLAuslesen(Dict)

            if Aktion == '1':
                erg = XMLClass(Link).XMLOMMDurchsuchen(Dict)
            if Aktion == '2':
                erg = XMLClass(Link).XMLOMMPayload(Dict)
            if Aktion == '3':
                erg = XMLClass(Link).XMLOMMTitel(Dict)
            if Aktion == '4':
                erg = XMLClass(Link).XMLOMMBeschreibung(Dict)
            if Aktion == '5':
                erg = OMMVorlagen(Link).XMLOMMErstellung()
            if Aktion == '6':
                erg = XMLClass(Link).XMLOMMHierarchie(Dict)
            if Aktion == '7':
                erg = XMLClass(Link).XMLOMMBearbeiten(Dict)

            #print(OutputDict(erg))
            'Output Paket'
            #...                                    #HIER SOLL ER EIN PAKET MIT DEM ERGEBNIS ZUSAMMENSTELLEN UND ZURÜCKSENDEN
            #
            #

            RESPONSE = VerwaltungsschaleDatenbank.create_message(
                TO=MESSAGE, CORE={'ERG': erg})
            VerwaltungsschaleDatenbank.send(RESPONSE)

        except KeyboardInterrupt:
            break
Beispiel #10
0
    def __init__(self):
        super(self.__class__, self).__init__()
        
        self.setupUi(self)        
        
        self.nutz_socket = False
        self.nutz_zeromq = True
        'kommunikationssocket instanziieren'
        'IPv4-Protokoll und TCP'
        if self.nutz_socket:
            self.komm = socket(AF_INET, SOCK_STREAM)
            'Verbindung herstellen'
            #lokale IP-Adresse und Port 60000
            self.komm.connect(('localhost', 60100))
#        if self.nutz_zeromq:
#            self.COM_module = module.entity('X_BOX', configuration.config)
            
        if self.nutz_zeromq:
            self.COM_module = module.module('X_BOX', configuration.config)
        
        self.aktiv = True
        self.mode3_init = False
        self.mode3 = 0
                


        
        '''Knoepfe verbinden'''
        
        self.programm_senden_1.clicked.connect(self.programm_senden_1_f)
        self.programm_senden_2.clicked.connect(self.programm_senden_2_f)
        
        self.drop_befehle_senden.clicked.connect(self.drop_befehle_senden_f)
        self.manuelle_befehle_senden.clicked.connect(self.manuelle_befehle_senden_f)
        
        self.modus_3_senden.clicked.connect(self.modus_3_senden_f)
        
        self.modus_1_start.clicked.connect(self.modus_1_start_f)
        self.modus_1_stop.clicked.connect(self.modus_1_stop_f)
        self.modus_2_start.clicked.connect(self.modus_2_start_f)
        self.modus_2_stop.clicked.connect(self.modus_2_stop_f)
        self.modus_3_start.clicked.connect(self.modus_3_start_f)
        self.modus_3_stop.clicked.connect(self.modus_3_stop_f)
        self.close.triggered.connect(self.schliessen_f)
        self.empfange_button.clicked.connect(self.empfangen)
        
        
        self.test_button.clicked.connect(self.test_button_f)
        
        '''Moegliche Befehle fuer die Schnellauswahl'''
        self.beispiel_befehle = [\
        '12 01 000 000 000 000 000 000',\
        '12 02 120 120 120 120 120 120',\
        '12 02 000 000 004 000 000 000',\
        '18 01 000 000 000 000 000 000',\
        '18 02 120 120 120 120 120 120',\
        '18 02 0 170 90 50 120 120',\
        '18 02 120 120 120 120 120 120',\
        '19',\
        'N00 G00 X0 Y312 Z100',\
        'N00 G00 X0 Y412 Z300',\
        'N01 G01 X120 Y300 Z100',\
        'N01 G01 X0 Y400 Z300',\
        'N01 G01 X120 Y300 Z100',\
        'N66 ',\
        'N01 G01 X120 Y300 Z100',\
        'N01 G01 X120 Y300 Z100',\
        'N01 G01 X120 Y300 Z100',\
        'N01 G01 X120 Y300 Z100']        
        
        self.drop_befehle.addItems(self.beispiel_befehle)
        
        
        '''Ausgabefenster initial fuellen'''        
        self.ausgabe.append('---- Willkommen beim externen Hilfprogramm ----')
        self.ausgabe.append('Wählen Sie zunächst den rechts einen Modus aus.')
        self.ausgabe.append('')      
        self.ausgabe.append('')
        
        self.apps_laden()
    def server_starten(self):
        self.socket = False
        self.message_lenght = 1024
        server_con = module.module('ROBOTER_GUI', configuration.config)
        if self.socket == True:

            'Verbindungssocket instanziieren'
            #IPv4-Protokoll und TCP
            self.verb = socket(AF_INET, SOCK_STREAM)

            'Verbindungssocket an eine IP-Adresse und einen Port binden'
            #lokale IP-Adresse und Port 60000
            self.verb.bind(('localhost', 60100))

            'Verbindungssocket auf Anfragen horchen lassen'
            #maximale Anzahl: 5
            self.verb.listen(5)

        'Information ausgeben'
        print('Server läuft und hört zu...')

        while True:
            '''Verbindungsanfrage akzeptieren. Es werden der
            Kommunikationssocket und das Adressobjekt des
            Verbindungspartners zurückgegeben.'''
            if self.socket == True:
                self.komm, addr = self.verb.accept()

#                request = CORE_pyobj["request"]
#                response = data[request].to_dict()
#                for key in response:
#                    response = str(response)

            'Daten vom Client empfangen'
            #Datentyp von data: bytes
            if self.socket == True:
                data = self.komm.recv(self.message_lenght)

            MESSAGE = server_con.receive()
            #            print(MESSAGE)

            CORE_pyobj = server_con.extract_core(MESSAGE)

            sender_cod = MESSAGE[1]

            self.sender_e = str(sender_cod.decode('ascii'))

            if self.socket == True:
                self.sender_e = "Socket-Server"
                '''Wenn keine Daten ankommen, wird der
                Kommunikationssocket geschlossen.'''
                if not data:
                    self.komm.close()
                    break

            'Nachricht vom Client'

            self.nachricht_kompl_e = CORE_pyobj

            self.nachricht_empfangen.emit(self.sender_e,
                                          self.nachricht_kompl_e, MESSAGE)