Update cookies preferences
Promotic

OpenPort - method of the PmaComm object

Description:
Open the ethernet port or serial port of this object.
Syntax:
Boolean OpenPort(String sParam)
Parameters:
sParam(String) Parameters for opening:
 
- for Ethernet-client:
Entries are in the KeyVal format, for example "ipaddress:192.168.0.126;port:61682;connect:1;".
- ipaddress: The value can be the IPv4 address, IPv6 address or computer name. See the "Network address" configurator
- port: Port. See the "TCP/UDP remote port number" configurator
- connect: The way to open the port.
0 (default) - The method only adds new connection parameters into the object. The following transmission will close existing connection and open new connection.
1 - The method adds new parameters into the object, close existing connection and open new connection.
The method will just give the command to open, i.e. the connection may not yet be open after this method is completed.
 
If the ipaddress or port are not entered, then the previously entered value remains.
If the empty string ("") is entered, then the parameters are not changed, it just opens a connection with existing parameters.
This method cannot be used for the PmaComm object that contains PmaCommMsg object of the Slave type.

- for Ethernet-server:
Entries are in the KeyVal format, for example "port:61682;".
- port: Port. See the "TCP/UDP port number" configurator.
The port can be changed only if it was previously set to 0 (i.e. if in the "TCP/UDP port number" configurator it was set to 0).
Change the port (i.e. initializing it with a script) can be e.g. in the onStart event.

- for serial link:
Only the serial port name is entered here. For example "COM1".
 
Note: The default setting of the communication serial port is defined in the "Serial port" configurator in parameters of the serial link. If it is necessary to change dynamically the serial link port, then it is possible to enter Not set in its parameters and than by methods OpenPort and ClosePort change the port.
For serial link each PmaComm object must have defined another communication port. For example, if one PmaComm object communicates through COM1, then next PmaComm object can communicate for example through COM2 (COM3, …) but it mustn't communicate through COM1.
This method cannot be used for the PmaComm object that contains PmaCommMsg object of the Slave type.
Return value:
true -
- for serial link: Port has been successfully opened.
- for Ethernet-client: The parameters has been set and connection will be opened during the next transfer.
false -
- for serial link: Port hasn't been opened. Possible error: Such port is not present on this computer or it is already used.
- for Ethernet-client: Because this method doesn't create a connection, false is return only if for bad parameters of the method.
Note:
This method can be called even in the INFO system by clicking the "Actions" button. See "PmaRoot > Permissions > InfoEdit" permission.
See also:
Example1:
for Ethernet-client: Sets the IP address and port. The next transmission of the message will close previous connection and open new connection.
JavaScriptVBScriptSelect and copy to clipboard

oComm.OpenPort("ipaddress:192.168.0.2;port:88;");
oCommMsg.Run();
Example2:
for serial link: Algorithm called after the request for sending 1 message (by the PmaCommMsg object) through COM1 port.
JavaScriptVBScriptSelect and copy to clipboard

if (oComm.OpenPort("COM1"))
{
oCommMsg.Run();
}

History:
Pm9.00.29:
- The method is now also enabled for Ethernet-server.
- This method can be called even in the INFO system by clicking the "Actions" button. See "PmaRoot > Permissions > InfoEdit" permission.
Pm9.00.25: Fixed bug: Repeated calling of this method, at the moment when the previous connection has not yet ended, caused the communication to stop.
PROMOTIC 9.0.31 SCADA system documentation MICROSYS, spol. s r.o.

Send page remarkContact responsible person
© MICROSYS, spol. s r.o.