Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add parsing for MID0900 #47

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
## Changelog

#### v1.1.1
#### v1.1.2
- Switches to GPL v3 licensing model


#### v1.1.1
- Implemented parsing of MID 0900


#### v1.1.0
Expand Down
141 changes: 71 additions & 70 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,71 +1,72 @@
//@ts-check
/*
Copyright: (c) 2018-2020, Smart-Tech Controle e Automação
GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
*/

const OpenProtocolParser = require("./src/openProtocolParser.js");
const OpenProtocalSerializer = require("./src/openProtocolSerializer.js");
const MIDParser = require("./src/MIDParser.js");
const MIDSerializer = require("./src/MIDSerializer.js");
const helpers = require("./src/helpers.js");
const SessionControlClient = require("./src/sessionControlClient.js");

const midGroups = require("./src/midGroups.json");
const midCommand = require("./src/midCommand.json");
const midrequest = require("./src/midRequest.json");

const net = require("net");

function createClient(port, host, opts, connectionListener) {

if (connectionListener === undefined) {
if (typeof opts === "function") {
connectionListener = opts;
opts = {};
} else {
connectionListener = () => {
};
}
}

opts = opts || {};

let socket = net.createConnection(port, host, () => {
socket.setTimeout(0);
client.connect(connectionListener);
});

socket.setTimeout(20000);

socket.once("timeout", () => onTimeout());

function onTimeout() {
let e = new Error("Socket Timeout");
e.code = "SOCKET_TIMEOUT";
e.address = host;
e.port = port;
client.emit("error", e);
}

opts.stream = socket;

let client = new SessionControlClient(opts);

return client;
}

module.exports = {
constants: {
subscribes: midGroups,
commands: midCommand,
requests: midrequest
},
OpenProtocolParser,
OpenProtocalSerializer,
SessionControlClient,
MIDParser,
MIDSerializer,
helpers,
createClient
//@ts-check
/*
Copyright: (c) 2023, Alejandro de la Mata Chico
Copyright: (c) 2018-2020, Smart-Tech Controle e Automação
GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
*/

const OpenProtocolParser = require("./src/openProtocolParser.js");
const OpenProtocalSerializer = require("./src/openProtocolSerializer.js");
const MIDParser = require("./src/MIDParser.js");
const MIDSerializer = require("./src/MIDSerializer.js");
const helpers = require("./src/helpers.js");
const SessionControlClient = require("./src/sessionControlClient.js");

const midGroups = require("./src/midGroups.json");
const midCommand = require("./src/midCommand.json");
const midrequest = require("./src/midRequest.json");

const net = require("net");

function createClient(port, host, opts, connectionListener) {

if (connectionListener === undefined) {
if (typeof opts === "function") {
connectionListener = opts;
opts = {};
} else {
connectionListener = () => {
};
}
}

opts = opts || {};

let socket = net.createConnection(port, host, () => {
socket.setTimeout(0);
client.connect(connectionListener);
});

socket.setTimeout(20000);

socket.once("timeout", () => onTimeout());

function onTimeout() {
let e = new Error("Socket Timeout");
e.code = "SOCKET_TIMEOUT";
e.address = host;
e.port = port;
client.emit("error", e);
}

opts.stream = socket;

let client = new SessionControlClient(opts);

return client;
}

module.exports = {
constants: {
subscribes: midGroups,
commands: midCommand,
requests: midrequest
},
OpenProtocolParser,
OpenProtocalSerializer,
SessionControlClient,
MIDParser,
MIDSerializer,
helpers,
createClient
};
78 changes: 39 additions & 39 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
{
"name": "node-open-protocol",
"version": "1.1.1",
"description": "A library to interface with Power Tools using the Atlas Copco Open Protocol",
"main": "index.js",
"directories": {
"doc": "doc"
},
"scripts": {
"test": "nyc --reporter=html --reporter=text --reporter=text-summary mocha --timeout=3000 test/**/**.spec.js",
"doc": "jsdoc -d docs/jsdoc/ -r -R README.md src/"
},
"repository": {
"type": "git",
"url": "https://github.com/netsmarttech/node-open-protocol"
},
"keywords": [
"hardware",
"ethernet",
"industrial",
"communication",
"controller",
"atlas-copco",
"power-focus",
"power-macs",
"stanley",
"desoutter",
"cleco",
"estic"
],
"author": "SmartTech",
"license": "GPL-3.0-or-later",
"devDependencies": {
"chai": "^4.2.0",
"jsdoc": "^3.6.6",
"mocha": "^8.2.0",
"nyc": "^15.1.0"
}
}
{
"name": "node-open-protocol-extended",
"version": "1.1.2",
"description": "A library to interface with Power Tools using the Atlas Copco Open Protocol",
"main": "index.js",
"directories": {
"doc": "doc"
},
"scripts": {
"test": "nyc --reporter=html --reporter=text --reporter=text-summary mocha --timeout=3000 test/**/**.spec.js",
"doc": "jsdoc -d docs/jsdoc/ -r -R README.md src/"
},
"repository": {
"type": "git",
"url": "https://github.com/alexmc1510/node-open-protocol-extended.git"
},
"keywords": [
"hardware",
"ethernet",
"industrial",
"communication",
"controller",
"atlas-copco",
"power-focus",
"power-macs",
"stanley",
"desoutter",
"cleco",
"estic"
],
"author": "SmartTech & Alejandro de la Mata",
"license": "GPL-3.0-or-later",
"devDependencies": {
"chai": "^4.2.0",
"jsdoc": "^3.6.6",
"mocha": "^8.2.0",
"nyc": "^15.1.0"
}
}
Loading