@synapticon/motion-master-proto
v5.2.2
Published
Generated TypeScript source code files from Motion Master proto.
Downloads
56
Readme
motion-master-proto
Motion Master Proto contains statically generated code used to communicate with the Motion Master. This library is meant to be used by all applications that will interact with the Motion Master protobuf messages and it contains the code generated for TypeScript, Java, C++ and JavaScript. The protobuf.js is used to generate the TypeScript code and protoc is used for all other languages.
protobuf.js
Install
npm install motion-master-proto --save
Usage
Import:
import * as motionMasterProto from 'motion-master-proto';
export import motionmaster = motionMasterProto.motionmaster;
Create devices message example:
let devices = motionmaster.Devices.create();
See how this library is used in Motion Master Simulator.
Develop
Replace motion-master.proto file with the latest version and run $ npm run build
.
When developing consider symlinking a package folder with npm-link.
Generate
$ pbjs --target static-module --wrap commonjs --out motion-master.proto.js motion-master.proto
$ pbts --out motion-master.proto.d.ts motion-master.proto.js
C++
Usage
Include:
#include <motion-master.pb.h>
using namespace motionmaster;
Example - Create a status meesage with a single device:
Status status;
Devices *devices = status.mutable_devices();
Devices::Device *device = devices->add_device();
device->set_device_id(i);
device->set_device_type(Devices::CIA402_DRIVE);
device->mutable_firmware()->set_version("0.0.1");
Generate
protoc --cpp_out=$PWD -I=$PWD $PWD/motion-master.proto
or simply execute the following script:
$ generation_scripts/compile_protocol_buffer_C++_API.sh
Java
Usage
Build the Java library as a local Maven package (from the "Java" directory):
$ mvn clean install -DskipTests
and include it inside the "pom.xml" file of the Java project:
<dependencies>
<dependency>
<groupId>com.synapticon.motionmaster-api</groupId>
<artifactId>motionmaster-api</artifactId>
<version>0.0.34</version>
</dependency>
</dependencies>
Generate
protoc --java_out=$PWD -I=$PWD $PWD/motion-master.proto
or simply execute the following script:
$ generation_scripts/compile_protocol_buffer_Java_API.sh
JavaScript
The code generated for JavaScript is used only for the SOMANETdrive web application and can be considered as legacy code.
Generate
$ protoc --js_out=import_style=commonjs,binary:$PWD -I=$PWD $PWD/motion-master.proto
or simply execute the following script:
$ generation_scripts/compile_protocol_buffer_JavaScript_API.sh