« Back to Product

Documentation

ForceParent

Require: IP-Symcon >= 4.0

 void ForceParent (string $ModuleID) 

Parameters

ModuleID

GUID

Returns

No Return

Description

A connection with a compatible parent instance with the GUID ModuleID is forced. If the previous connection does not match the desired ModuleID, it will be disconnected. Following, a new instance with the parent ModuleID is created and linked.
A list of the available module IDs is available HERE .

Warning

The normal case for the function is a splitter module, which, depending on the configuration in the interface, requires a different I/O module.

Warning

Normally, this function is called only in the Create() or ApplyChanges() method.

Example

public function ApplyChanges() {

    // Never remove the line!
    parent::ApplyChanges();

    // Create different I/O instances depending on the configuration
    switch($this->ReadPropertyInteger("GatewayMode")) {
        case 0: //Create ClientSocket in mode 0
            $this->ForceParent("{3CFF0FD9-E306-41DB-9B5A-9D06D38576C3}");
            break;
        case 1: //Create SerialPort in mode 1
            $this->ForceParent("{6DC3D946-0D31-450F-A8C6-C42DB8D7D4F1}");
            break;
    }
                
}
Any questions?