INNER CODE UNIT · Python

updating_writer

Fortiphyd/GRFICSv2 · simulation_vm/simulation/remote_io/modbus/feed1.py:40

def updating_writer(a):
    global last_command
    print 'updating'
    context  = a[0]
    
    slave_id = 0x01 # slave address
    count = 50
    s = a[1]
    
    current_command = context[slave_id].getValues(16, 1, 1)[0] / 65535.0*100.0

    s.send('{"request":"write","data":{"inputs":{"f1_valve_sp":'+repr(current_command)+'}}}\n')

    # import pdb; pdb.set_trace()
    #s.send('{"request":"read"}')
    data = json.loads(s.recv(1500))
    valve_pos = int(data["state"]["f1_valve_pos"]/100.0*65535)
    flow = int(data["outputs"]["f1_flow"]/500.0*65535)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…