Node('mupd.psi.ch',
     'uniax pressure stick with motor and transducer',
     interface='tcp://5000',
)

usb_displacement = 'serial:///dev/serial/by-path/platform-fd500000.pcie-pci-0000:01:00.0-usb-0:1.3.4:1.0-port0'
usb_pillars = 'serial:///dev/serial/by-path/platform-fd500000.pcie-pci-0000:01:00.0-usb-0:1.3.1:1.0-port0'
usb_load_cell = 'serial:///dev/serial/by-path/platform-fd500000.pcie-pci-0000:01:00.0-usb-0:1.3.2:1.0-port0'
usb_drv = 'serial:///dev/serial/by-path/platform-fd500000.pcie-pci-0000:01:00.0-usb-0:1.3.3:1.0-port0?baudrate=9600'


if 'drv':
  Mod('drv',
    'frappy_psi.trinamic.Motor',
    'trinamic motor test',
    uri=usb_drv,
    standby_current=0.1,
    maxcurrent=1,
    acceleration=150.0,
    move_limit=5,
    safe_current=1.1,
    speed=40.0,
    encoder_tolerance=3.6,
    free_wheeling=0.1,
    power_down_delay=0.1,
    has_limit_switches=True,
    has_home=True,
    fast_poll = 0.1,
)

if not 'pillars':
    Mod('pillars',
        'frappy_psi.dpm.DPM3',
        'DPM driver to read out the transducer value, write and read the offset and scale factor',
        drive='drv',
        value=Param(unit='N'),
        uri=usb_pillars,
        digits=1,
        scale_factor=100,
        offset=0,
        alarm_limit=2000,
    )

if not 'displacement':
    Mod('displacement',
        'frappy_psi.dpm.DPM3',
        'DPM driver to read out the transducer value, write and read the offset and scale factor',
        drive='drv',
        value=Param(unit='mV'),
        uri=usb_displacement,
        digits=3,
        scale_factor=100,
        offset=0,
        alarm_limit=2000,
    )

Mod('load_cell',
    'frappy_psi.dpm.DPM3',
    'DPM driver to read out the transducer value, write and read the offset and scale factor',
    drive='drv',
    value=Param(unit='N'),
    uri=usb_load_cell,
    digits=1,
    #scale_factor=25696, # value at=s on the device, but without dec.pnt.
    #scale_factor=25696*2*10,
    #scale_factor=10000,
    scale_factor=-105.775*1000,
    offset=65.66,
    #offset=0,
    alarm_limit=200,
)

Mod('force',
    'frappy_psi.uniax.Uniax',
    'force control',
    motor='drv',
    transducer='load_cell',
    limit=200,
    pollinterval = 0.1,
)
