#Script imported from: test1.xml

#Variables
var1 = 0.0

#TODO: Set the diplay names of positioners and detectors
scan = ManualScan(['id278043'], ['id348623', 'id367393'] , [0.0], [31.0], [31])
scan.start()

#Creating channels: dimension 1
#LinearPositioner id278043
id278043 = Channel('TESTIOC:TESTCALCOUT:Input', type = 'd')
#ScalarDetector id348623
id348623 = Channel('TESTIOC:TESTCALCOUT:Output', type = 'd')
#ScalarDetector id367393
id367393 = Channel('TESTIOC:TESTSINUS:SinCalc', type = 'd')

#Dimension 1
#LinearPositioner id278043
for setpoint1 in frange(0.0, 31.0, 1.0, True):
    if setpoint1 > 31.0 or  setpoint1 < 0.0:
        break
    id278043.put(setpoint1, timeout=None) # TODO: Set appropriate timeout
    readback1 = id278043.get()
    if abs(readback1 - setpoint1) > 0.5 : # TODO: Check accuracy
        raise Exception('Actor id278043 could not be set to the value ' + str(setpoint1))
    #Dimension Actions
    #Script action
    #TODO: Move, if needed, this import to the file header: import time
    time.sleep(0.1)
    #Detector id348623
    detector1 = id348623.get()
    #Detector id367393
    detector2 = id367393.get()
    scan.append ([setpoint1], [readback1], [detector1, detector2])

#Closing channels
id278043.close()
id348623.close()
id367393.close()

scan.end()
