# Motion Master Client

Library and CLI tool for interacting with [Motion Master](https://github.com/synapticon/motion-master).

## Install

    sudo npm --unsafe-perm=true install -g @synapticon/motion-master-client

## Command line usage

See the examples in [test.sh](test.sh).

Usage: cli [options] [command]

    Options:
      -V, --version                                                                                                   output the version number
      -c, --config <path>                                                                                             path to JSON config file to read and replace     the default values with
      -d, --device-address <address>                                                                                  device address (uint32) generated by Motion     Master - takes precedence over
                                                                                                                      device position
      -f, --output-format <json|yaml>                                                                                 if left unspecified the output format is the     default colored message
                                                                                                                      inspect
      -p, --device-position <position>                                                                                used when device address is not specified     (default: 0)
      -h, --help                                                                                                      display help for command
    
    Commands:
      request [options] <type> [args...]
      upload [options] [params...]
      download [paramValues...]
      getDeviceFileContent <filename>
      getDeviceLogContent
      getCoggingTorqueDataContent
      startCoggingTorqueRecording [options]
      startOffsetDetection
      startPlantIdentification <durationSeconds> <torqueAmplitude> <startFrequency> <endFrequency> <cutoffFrequency>
      startSystemIdentification <durationSeconds> <torqueAmplitude> <startFrequency> <endFrequency>
      startCirculoEncoderNarrowAngleCalibrationProcedure <encoderOrdinal>
      monitor [options] <topic> [params...]
      help [command]                                                                                                  display help for command


### request

    Usage: cli request [options] <type> [args...]

    Options:
      -i, --interval <value>  sending interval in microseconds (default:     1000000)
      -h, --help              display help for command

    Request <type>s:
      pingSystem
      getSystemVersion
      getDeviceInfo
      getDeviceParameterInfo
      getDeviceParameterValues
      getMultiDeviceParameterValues
      setDeviceParameterValues
      setMultiDeviceParameterValues
      getDeviceFileList
      getDeviceFile
      setDeviceFile
      deleteDeviceFile
      resetDeviceFault
      stopDevice
      startDeviceFirmwareInstallation
      getDeviceLog
      startCoggingTorqueRecording
      getCoggingTorqueData
      startOffsetDetection
      startPlantIdentification
      startSystemIdentification
      computeAutoTuningGains
      setMotionControllerParameters
      enableMotionController
      disableMotionController
      setSignalGeneratorParameters
      startSignalGenerator
      stopSignalGenerator
      startMonitoringDeviceParameterValues
      stopMonitoringDeviceParameterValues
      getEthercatNetworkState
      setEthercatNetworkState
      startNarrowAngleCalibration
      setSystemClientTimeout
      getCirculoEncoderMagnetDistance
      startCirculoEncoderNarrowAngleCalibrationProcedure
      getDeviceCiA402State
      setDeviceCiA402State
      getSystemLog
      startDeviceSiiRestore
      startOpenLoopFieldControl
      computeFullAutoTuningGains
      startFullAutoTuning
      stopFullAutoTuning
      startCirculoEncoderConfiguration
      stopCirculoEncoderNarrowAngleCalibrationProcedure
      startOsCommand

### monitor

    Usage: monitor [options] <topic> [params...]

    Options:
      -i, --interval <value>  sending interval in microseconds (default: 1000000)
      -h, --help              output usage information

## Library usage

    const input = new rxjs.Subject<Buffer>();
    const output = new rxjs.Subject<Buffer>();
    const motionMasterClient = new MotionMasterClient(input, output);
    const messageId = v4(); // '4e4d938e-1021-4b68-ad01-38c7ed2c5ee4'
    const getSystemVersion: motionmaster.MotionMasterMessage.Request.IGetSystemVersion = {};
    motionMasterClient.sendRequest({ getSystemVersion }, messageId);
    motionMasterClient.systemVersion$.subscribe(console.log);

## Publish

    npm publish --access=public
