@kjgalr/node-red-plc-next-connector

1.0.7 • Public • Published

node-red-contrib-plc-next-connectorrr

Table of contents

  1. Description
  2. Plc-Connector Node
  3. Implemented Nodes
  4. Installation

Description

A NodeRED package that enables the user to communicate with the PLCnext controller via the REST api.
This package implements the core functions from the REST interface in a more user-friendly manner than manually creating http queries.

Plc-Connector Node

The Plc-Connector node is the node that not only authenticates and authorizes the connection with the controller but also keeps the connection alive and attempts to reconnect when the connection is lost.
All other nodes implement this node as a parameter that can be configured in the editor.
One connector node can be used by multiple other nodes but a node can only implement one connector node.

Configuration

img-connector

Parameters:

Parameter Description
Host IP IP of the controller that you want to connect to
Authentication Required Flag if the controller requires a username and password
Username Username (admin by default)
Password Password (on the back of the controller)
Station Name Determines the identifier of the session (can be freely chosen)
Session Timeout Time in milliseconds before the session needs to be renewed
Api Version Api version that you want to use

Implemented Nodes

img-all-nodes


Read Variables

Returns a list of variables and their values. Reads one or multiple variables from the controller.

img-read-variables

Parameters:

Parameter Description Required
Plc-Connector Instance of the Plc-Connector that you configured True
Search Searchbar with autocomplete feature for adding variables to the selector below False
Variables list of variables to be read False

Details
The variables defined in the input can be used in conjunction with the variables set in the editor. The list of variables will internally be converted to a set, as to prevent variables being read more than once.

Input

msg: {
    payload:{
        variables:[
            {path:<Variable 1>},
            {path:<Variable 2>},
            ...
            {path:<Variable N>}
        ]
    }
}

Output:

msg:{
    _msgid:<Id of the message>,
    payload:{
        variables:[
            {path:<Variable 1>, value:<Value of variable 1>},
            {path:<Variable 2>, value:<Value of variable 2>},
            ...
            {path:<Variable N>, value:<Value of variable N>}
            ]
        }
}

Browse Items

Returns the currently used public variables and their types from the controller.

img-browse-items

Parameters:

Parameter Description Required
Plc-Connector Instance of the Plc-Connector that you configured True
Get Variables Check for a list of publicly available variables False
Get Types Check for a list of all used types False

Details
The values set by the input message take priority over the values set in the editor of the node. So if get_dicts is set to false in the editor but the input messages supplies the value true, then it will send the dictionary because the input message is prioritized.

Input

msg:{
    payload:{
        get_dicts:<boolean>
        get_types:<boolean>
    }
}

Output:

msg:{
    _msgid:<Id of the message>,
    payload:{
        dict:{
            <Variable 1>:{Type:<Type of Variable 1>, InitValue:<...>, ReadOnly:<...>},
            <Variable 2>:{Type:<Type of Variable 2>, InitValue:<...>, ReadOnly:<...>},
            ...
            <Variable N>:{Type:<Type of Variable N>, InitValue:<...>, ReadOnly:<...>}
        },
        types:[
            {Name: <Variable Type 1>,...},
            {Name: <Variable Type 2>,...},
            ...
            {Name: <Variable Type N>,...}
        ]
    }
}

Report Sessions

Returns a list of all currently active sessions.

img-report-sessions

Parameters:

Parameter Description Required
Plc-Connector Instance of the Plc-Connector that you configured True

Details This node will trigger on any input, i.e. that regardless of what is supplied this node will list the active sessions from the connector that is selected in the editor.

Input
None

Output:

msg:{
    _msgid:<Id of the message>,
    payload:{
        sessions:[
            {id:<Id of session 1>, stationID:<Name of session 1>, ipAddress:<Ip of controller>, ...},
            {id:<Id of session 2>, stationID:<Name of session 2>, ipAddress:<Ip of controller>, ...},
            ...
            {id:<Id of session N>, stationID:<Name of session N>, ipAddress:<Ip of controller>, ...}
        ]
    }
}

Report Groups

Returns a list of all currently active groups.

img-report-groups

Parameters:

Parameter Description Required
Plc-Connector Instance of the Plc-Connector that you configured True

Details This node will trigger on any input, i.e. that regardless of what is supplied this node will list the active groups from the connector that is selected in the editor.

Input
None

Output:

msg:{
    _msgid:<Id of the message>,
    payload:{
        groups:[
            {id:<Id of group 1>, variableCount:<Amount of vars in group 1>, ...},
            {id:<Id of group 2>, variableCount:<Amount of vars in group 2>, ...},
            ...
            {id:<Id of group N>, variableCount:<Amount of vars in group N>, ...}
        ]
    }
}

Create Groups

Returns a groupID
Groups variables together so that they can be read from or written to by only using a groupID.
Simplifies requests because only the groupID is needed to request all variables within a group.\

img-create-groups

Parameters:

Parameter Description Required
Plc-Connector Instance of the Plc-Connector that you configured True
Search Searchbar with autocomplete feature for adding variables to the selector below False
Variables list of variables to be read False

Details
The variables defined in the input can be used in conjunction with the variables set in the editor. The list of variables will internally be converted to a set, as to prevent variables being read more than once.

Input

msg: {
    payload:{
        variables:[
            {path:<Variable 1>},
            {path:<Variable 2>},
            ...
            {path:<Variable N>}
        ]
    }
}

Output:

msg:{
    _msgid:<Id of the message>,
    payload:{
        group_id":<Id of the group>
    }
}

Read Group Variables

Reads all variables that have been assigned to a particular group using the groupID.

img-read-group-variables

Parameters:

Parameter Description Required
Plc-Connector Instance of the Plc-Connector that you configured True
Group ID ID of the group False

Details
The value set by the input message takes priority over the value set in the editor of the node. That means that even if a group_id is set in the editor, as long as the input contains a group_id, it will be used.

Input

msg:{
    payload:{
        group_id:<Id of the group>
    }
}

Output:

msg:{
    _msgid:<Id of the message>,
    payload:{
        variables:[
            {path:<Variable 1>, value:<Value of variable 1>},
            {path:<Variable 2>, value:<Value of variable 2>},
            ...
            {path:<Variable N>, value:<Value of variable N>}
        ]
    }
}

Write Variables

Returns a list of variables and their new values.
Changes the values of the selected variables.
The variables are a comma-separated-list where whitespace is ignored.

img-write-variables

Parameters:

Parameter Description Required
Plc-Connector Instance of the Plc-Connector that you configured True
Path Prefix Prefix that will be appended to the vaiable name if the prefix field is being left empty in the table True
Editable list list that contains the prefix, variable-name, new value and valueType of the variable that will be changed True

Editable list

Parameter Description Required
Prefix The prefix of this particular variable (Will use the value from the [Path Prefix] field if left empty) False
Variable The variable to be changed True
Value The new value of the variable or the name of another variable True
ValueType The type of the value ('Constant' refers to a constant value like 'true' or 'false' while 'Variable' assignes the value of another variable to this variable) True

Details
The variables defined in the input can be used in conjunction with the variables set in the editor. The list of variables will internally be converted to a set, so that only one value will be written to a variable. The values set in the input take priority over the values set in the editor.

Input

msg: {
    payload:{
        variables:[
            {path:<Variable 1>, value:<Value of the variable 1>, valueType<Constant or Variable>},
            {path:<Variable 2>, value:<Value of the variable 2>, valueType<Constant or Variable>},
            ...
            {path:<Variable N>, value:<Value of the variable N>, valueType<Constant or Variable>},
        ]
    }
}

Output:

msg:{
    _msgid:<Id of the message>,
    payload: {
        variables:[
            {path:<Variable 1>, value:<New value of variable 1>, ...},
            {path:<Variable 2>, value:<New value of variable 2>, ...},
            ...
            {path:<Variable N>, value:<New value of variable N>, ...}
        ]
    }
}

Change Connection Parameters Dynamically

Changes the connection parameters based on the configuration of the incomming message.

Parameters:

Parameter Description Required
Plc-Connector Instance of the Plc-Connector that you configured True
Parameters JSON encoded parameters for the PLC-Connector False

Details
Only host (ip address), username and password can be configured in the configuration node. Please fill the reamining parameters in the PLC-Connector configuration area.

Input

msg:{
    _msgid:<Id of the message>,
    config: {
        host: 192.168.0.10
        username: admin
        password: 2350c83d
    }
}

Installation

Via the node-red palette manager

Navigate to the node-red instance running on the controller by visiting [https://<controller ip>/cockpit] and selecting NODE-RED.
Then open the palette manager and search for @kjgalr/node-red-plc-next-connector and install it.

Via the terminal on a desktop pc

!!The NodeRED package is required for this installation to work!!

    npm install -g --unsafe-perm node-red

Manual installation

  1. Clone the repository
    git clone https://gitlab.phoenixcontact.com/kjgalr/node-red-contrib-plc-next-connector
    
  2. Navigate into the folder
    cd node-red-contrib-plc-next-connector
    
  3. Install the needed packages
    npm install axios https
    
  4. Navigate to the .node-red folder (using one of the following commands):
    cd ~/.node-red
    cd $HOME/.node-red
    cd %HOME%/.node-red
    
  5. Install the node-red-contrib-plc-connector package
    npm install <Path were you cloned the repository to>
    
  6. Start NodeRED
    node-red
    

Readme

Keywords

Package Sidebar

Install

npm i @kjgalr/node-red-plc-next-connector

Weekly Downloads

7

Version

1.0.7

License

ISC

Unpacked Size

303 kB

Total Files

36

Last publish

Collaborators

  • kjgalr