src/communication/commHmiNodeServer.ts
Class that implements the communication abstract class with the specifications related to CNC 8070.
Connection is made against the main HMI NODE Server via Websocket && HTTP.
This object will be emiting the following events:
emits online when connection chain has been resolved succesfully, libfagorclient is ready to operate
emits offline when any link has been disconnected, so libfagorclient is unusable.
emits model-received A full copy of the model has been received. (model will be pass as an argument)
emits model-updated Array of JSON-patches containing changes to be applied in current model
emits plcmodel-received A full copy of the plc model has been received. (model will be pass as an argument)
emits plcmodel-updated Array of JSON-patches containing changes to be applied in current plc model
emits new-authetication-token whenever a new token is fetched (token update is managed internally)
const comm = new CommHmiNodeServer();
// We must listen to online event, before making the connection.
comm.on("online", () => {
console.log("Connection success!");
console.log(
`${comm.getToken()} this is the authorization token which can be used on other HMI connections.`
);
});
// Trying to connect ot localhost using usernamee & password
comm.connect({
host: "localhost",
port: "3000",
username: "anonymous",
password: "anonymous"
});
// also a valid token could be used
comm.connect({
host: "localhost",
port: "3000",
token: "valid_remote_token"
});
// Or even a valid refresh token can be issued to get a connection setup
comm.connect({
host: "localhost",
port: "3000",
username: "anonymous",
refreshToken: "valid_refresh_token"
});
Properties |
|
Methods |
|
Public clientId |
Type : string
|
unique UUID for current WS connection |
Public cncId |
Type : CncIdentification
|
Default value : {idHW: ""}
|
Current cnc idenftificaion |
Public cncSwOptions |
Type : SwOptions[]
|
Default value : []
|
Sotfware options exported by cnc for each session |
Public cncVersion |
Type : CncVersion[]
|
Default value : []
|
Current cnc version |
Public connected |
Type : boolean
|
Default value : false
|
current connection status |
Public connectedCncNodes |
Type : number
|
Default value : 0
|
Connected cnc nodes |
Public connecting |
Type : boolean
|
Default value : false
|
is connection on progress? |
httpClient |
Type : any
|
Public online |
Type : boolean
|
Default value : false
|
Flag that indicates whether cnc system is accesible and fully operative |
Public canCloseCnc | ||||||||
canCloseCnc(cncNodeIndex: number)
|
||||||||
Implements the canCloseCnc service call. It calls to CommHmiNodeServer to call appropiate REST API route. Returns a promise. This promise is fulfilled with reply object if everything is ok or is rejected with CncServiceOperationException when something goes wrong.
Parameters :
|
Public connect | ||||||||
connect(connectionData: ConnectionData)
|
||||||||
Implements the connection process with the main HMI Node Server. Assigns an unique guid number, established tjhe websocket connection and check the HTTP Endpoint. Returns Promise resolved to true if connection success, or with custom error.
Parameters :
Returns :
Promise<ServiceResponse | errors.ConnectionTimeoutException | errors.ConnectionFailedException>
|
Public Async getCncId |
getCncId()
|
Returns :
Promise<boolean>
|
Public getCNCLanguage | ||||||
getCNCLanguage(lang: string)
|
||||||
Returns the CNC language associated with the HMI elite language Return CNC language
Parameters :
Returns :
string
|
Public getCncProcessInfo | ||||||||
getCncProcessInfo(cncNodeIndex: number)
|
||||||||
Implements the isCncRunning service call. It calls to CommHmiNodeServer to call appropiate REST API route. Returns a promise. This promise is fulfilled with reply object if everything is ok or is rejected with CncServiceOperationException when something goes wrong.
Parameters :
|
Public Async getCncVersion |
getCncVersion()
|
Returns :
Promise<boolean>
|
Public getGlobalsParInfo | ||||||||
getGlobalsParInfo(cncNodeIndex: number)
|
||||||||
Gets the CNC global parameter info data and fills CommHmiNodeServer.globalsParInfo member. This service is referenced on runtime when {CommHmiNodeServer} creates Model-s. It calls to CommHmiNodeServer to call appropiate REST API route. Returns a promise. This promise is fulfilled with reply object if everything is ok or is rejected with CncServiceOperationException when something goes wrong.
Parameters :
|
Public Async getSwOptions |
getSwOptions()
|
Returns :
Promise<boolean>
|
Public Async pressJogKeysToCnc | |||||||||||||||
pressJogKeysToCnc(jogkey: string, cncNodeIndex: number)
|
|||||||||||||||
Parameters :
|
Public reboot | |||||
reboot(undefined: literal type)
|
|||||
Implements the reboot service call. It calls to CommHmiNodeServer to call appropiate REST API route. Returns a promise. This promise is fulfilled with reply object if everything is ok or is rejected with CncServiceOperationException when something goes wrong.
Parameters :
|
Public sendJogKeysToCnc | ||||||||||||||||
sendJogKeysToCnc(jogkey: string, value: number, cncNodeIndex: number)
|
||||||||||||||||
Parameters :
|
Public sendKeysToCnc | |||||||||||||||
sendKeysToCnc(keys: string[], cncNodeIndex: number)
|
|||||||||||||||
Implements the sendKeysToCNC private service call. Returns a promise. This promise is fulfilled with reply object if everything is ok or is rejected with CncServiceOperationException when something goes wrong.
Parameters :
|
Public setMachineParameter | |||||||||||||||||||||||||
setMachineParameter(route: string, name: string, value: string, cncNodeIndex: number)
|
|||||||||||||||||||||||||
Implements the setMachineParameter service call. writes and validates a machine parameter by its variable name. This service is referenced on runtime when {CommHmiNodeServer} creates Model-s. It calls to CommHmiNodeServer to call appropiate REST API route. Returns a promise. This promise is fulfilled with reply object if everything is ok or is rejected with CncServiceOperationException when something goes wrong.
Parameters :
|
Public setTimeout | ||||||
setTimeout(timeout: number)
|
||||||
Sets http request timeout
Parameters :
Returns :
void
|
Public shutdown | |||||
shutdown(undefined: literal type)
|
|||||
Implements the shutdown service call. It calls to CommHmiNodeServer to call appropiate REST API route. Returns a promise. This promise is fulfilled with reply object if everything is ok or is rejected with CncServiceOperationException when something goes wrong.
Parameters :
|
Public shutdownServer |
shutdownServer()
|
Sends a shutdown message to remote endpoing
Returns :
boolean
|
Public start | ||||||||
start(cncNodeIndex: number)
|
||||||||
Implements the start service call. It calls to CommHmiNodeServer to call appropiate REST API route. Returns a promise. This promise is fulfilled with reply object if everything is ok or is rejected with CncServiceOperationException when something goes wrong.
Parameters :
|