Commit ca4b7725 authored by Bastian's avatar Bastian

initial commit

parent 12ea178e
#!/bin/bash
chose="d"
while [[ $chose != "" ]]
do
chose=$(zenity --list --height 500 --width 350 --text="Treffen Sie eine Auswahl:" --title="IOTA - Aktionen" --column="Aktion" --column="Erklärung" balance "Wallet anzeigen" request-funds "Nach Demo-Tokens fragen" list-sc "Smart Contracts auflisten" run-sc1 "RaaS-1 ausführen" run-sc2 "RaaS-2 ausführen" deploy-chain "Chain anlegen" )
case $chose in
"balance")
rm .last_balance_output
echo "run wasp-cli balance"
wasp-cli balance > .last_balance_output
gxmessage --file .last_balance_output -geometry 470x240 --font "monospace 9" -buttons Ok -default Ok
;;
"list-sc")
rm .last_list_contracts
echo "run wasp-cli chain list-contracts"
wasp-cli chain list-contracts > .last_list_contracts
gxmessage --file .last_list_contracts -geometry 1220x300 --font "monospace 9" -buttons Ok -default Ok
;;
"run-sc1")
echo "run wasp-cli chain post-request raas1"
wasp-cli chain post-request raas1 start
;;
"run-sc2")
echo "run wasp-cli chain post-request raas2"
wasp-cli chain post-request raas2 start
;;
"request-funds")
rm .last_request_funds
gxmessage -noescape -borderless "Anfrage läuft nach Klick auf 'Ok'. Die Verarbeitung kann anschließend einige Sekunden in Anspruch nehmen."
wasp-cli request-funds > .last_request_funds
gxmessage --file .last_request_funds -geometry 790x100 --font "monospace 9" -buttons Ok -default Ok
;;
"deploy-chain")
rm .last_chain_deploy
gxmessage -noescape -borderless "Anfrage läuft nach Klick auf 'Ok'. Die Verarbeitung kann anschließend einige Sekunden in Anspruch nehmen."
wasp-cli chain deploy --chain=mychain --committee='0,1,2,3' --quorum=3 > .last_chain_deploy
gxmessage --file .last_chain_deploy -geometry 790x300 --font "monospace 9" -buttons Ok -default Ok
;;
esac
done
import urx
import time
import pynng
from pynng import Pub0, Sub0, Timeout
#from paho.mqtt import client as mqtt_client
acc_val=1.0
vel_val=1.0
while (1):
add1 = "tcp://127.0.0.1:5550"
add2 = "tcp://127.0.0.1:5551"
add3 = "tcp://127.0.0.1:5552"
add4 = "tcp://127.0.0.1:5553"
sub1 = Sub0(dial=add1,recv_timeout=0, topics=b'')
sub2 = Sub0(dial=add2,recv_timeout=0, topics=b'')
sub3 = Sub0(dial=add3,recv_timeout=0, topics=b'')
sub4 = Sub0(dial=add4,recv_timeout=0, topics=b'')
msg = ""
z = 0
while(1):
try:
msg1 = sub1.recv().decode("utf-8")
print("msg1: ",msg1)
s1 = msg1.split(" ")
# if s1[0] == "vmmsg" and z == 0:
if s1[0] == "vmmsg":
msg = s1[3]+" "+s1[4]+" "+s1[5]
z = 1
else:
msg2 = sub2.recv().decode("utf-8")
s2 = msg2.split(" ")
# print("msg2: ",msg2)
# if s2[0] == "vmmsg" and z == 0:
if s2[0] == "vmmsg":
msg = s2[3]+" "+s2[4]+" "+s2[5]
z = 1
else:
msg3 = sub3.recv().decode("utf-8")
s3 = msg3.split(" ")
# print("msg3: ",msg3)
# if s3[0] == "vmmsg" and z == 0:
if s3[0] == "vmmsg":
msg = s3[3]+" "+s3[4]+" "+s3[5]
z = 1
else:
msg4 = sub4.recv().decode("utf-8")
s4 = msg4.split(" ")
# print("msg4: ",msg4)
# if s4[0] == "vmmsg" and z == 0:
if s4[0] == "vmmsg":
msg = s4[3]+" "+s4[4]+" "+s4[5]
z = 1
else:
continue
if msg == "Starte Programm 1!":
print("Starte Programm 1!")
z = 0
msg = ""
rob = urx.Robot("192.168.10.2")
print("> Starte Roboter!")
pos1="0.25647916695806733, -0.20950930812090002, 0.2677891809125979, -1.078320878770772, 2.9458934852066916, -0.04432158131383405"
pos2="0.21174765831722364, -0.19391969768850317, 0.4188726911778911, -1.0694328036418663, 2.9260678123423496, -0.06329800022699414"
pos3="0.2597040098375415, 0.18247736706212508, 0.36226551521624323, -2.5707579604656408, 1.6533369277293541, 0.040216871710598845"
pos4="0.27137083263344997, 0.18982963782665077, 0.26788113528302404, -2.623258227599133, 1.6901800383957135, -0.029954015985554184"
print("Fahre pos1 an")
rob.send_program( "movej(p["+str(pos1)+"], a=1, v=1)" )
time.sleep(4)
print("Fahre pos2 an")
rob.send_program( "movej(p["+str(pos2)+"], a=1, v=1)" )
time.sleep(4)
print("Fahre pos3 an")
rob.send_program( "movej(p["+str(pos3)+"], a=1, v=1)" )
time.sleep(4)
print("Fahre pos4 an")
rob.send_program( "movej(p["+str(pos4)+"], a=1, v=1)" )
time.sleep(4)
print("Fahre pos3 an")
rob.send_program( "movej(p["+str(pos3)+"], a=1, v=1)" )
time.sleep(4)
print("Fahre pos2 an")
rob.send_program( "movej(p["+str(pos2)+"], a=1, v=1)" )
time.sleep(4)
print("Fahre pos1 an")
rob.send_program( "movej(p["+str(pos1)+"], a=1, v=1)" )
rob.close()
print("> Ende Roboter")
break
if msg == "Starte Programm 2!":
print("Starte Programm 2!")
z = 0
msg = ""
rob = urx.Robot("192.168.10.2")
time.sleep(0.2)
# Roboter bewegung
print("> Starte Roboter!")
pos1="0.25647916695806733, -0.20950930812090002, 0.2677891809125979, -1.078320878770772, 2.9458934852066916, -0.04432158131383405"
pos2="0.27137083263344997, 0.18982963782665077, 0.26788113528302404, -2.623258227599133, 1.6901800383957135, -0.029954015985554184"
print("Fahre pos1 an")
rob.send_program( "movej(p["+str(pos1)+"], a=1, v=1)" )
time.sleep(4)
print("Fahre pos2 an")
rob.send_program( "movej(p["+str(pos2)+"], a=1, v=1)" )
time.sleep(4)
print("Fahre pos1 an")
rob.send_program( "movej(p["+str(pos1)+"], a=1, v=1)" )
rob.close()
print("> Ende Roboter")
break
except pynng.exceptions.Timeout as e:
img = ""
# print('Timed out, retrying...')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment