# Type help("robodk.robolink") or help("robodk.robomath") for more information
# Press F5 to run the script
# Documentation: https://robodk.com/doc/en/RoboDK-API.html
# Reference:     https://robodk.com/doc/en/PythonAPI/robodk.html
# Note: It is not required to keep a copy of this file, your Python script is saved with your RDK project

# You can also use the new version of the API:
from robodk import robolink    # RoboDK API
from robodk import robomath    # Robot toolbox
RDK = robolink.Robolink()

# Forward and backwards compatible use of the RoboDK API:
# Remove these 2 lines to follow python programming guidelines
from robodk import *      # RoboDK API
from robolink import *    # Robot toolbox
# Link to RoboDK
# RDK = Robolink()



f_value = None
from robolink import * #nur fuer Nutzung in RoboDK
RDK = Robolink()
# Check if we are running this program inside another program and passing arguments
import sys
if len(sys.argv) > 1:
   e_value = float(sys.argv[1])
   f_transform=f_value * 60  # mm/s in mm/min und adaptation for line crossection Q to fed filament Q/pi*(2.85/2)²
   code = 'G1 F' + str(f_transform)
   #print(message) #for test purposes
   RDK.ShowMessage(code, popup=False)  # for test purpose set to True for popup, set to false or comment out for use to avoid blocking
   if RDK.RunMode() == RUNMODE_SIMULATE:
       quit()

   import requests
   params = {"gcode": code }
   r = requests.get("http://172.31.1.151/rr_status?type=1")
 
   #print(r.json()) # for test purpose
   r = requests.get("http://172.31.1.151/rr_gcode", params=params)  # this works!
   # r = requests.get("http://192.168.0.100/rr_gcode?gcode=G1 Z100")  # this also works!
   #print(r.json())
