[r815]: / branches / FeatureBranches / refactorpayload / SparkplugB / Function Blocks / FB_Edge / FB_Edge / Initialise / svnobj  Maximize  Restore  History

Download this file

66 lines (65 with data), 10.2 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
Initialise := FALSE;
// Only use the corrected names throughout EoN!
_cGroupId       := ReplaceIllegalCharsWithUnderscore( GroupId );
_TopicProvider.SETSTATETopic( PrimaryHostID := _cPrimaryHostID );
_TopicProvider.SETLASTWILLTopic( NodeName := _cNodeName,
                                 GroupId := _cGroupId );
_TopicProvider.SETNBIRTHTopic( NodeName := _cNodeName,
                               GroupId := _cGroupId );
_TopicProvider.SETNCMDTopic( NodeName := _cNodeName,
                             GroupId := _cGroupId );
_TopicProvider.SETNDATATopic( NodeName := _cNodeName,
                              GroupId := _cGroupId );
// Convert corrected GroupId From WSTRING TO STRING
sPrimaryHostID := WSTRING_TO_STRING( _cPrimaryHostID );
sGroupId       := WSTRING_TO_STRING( _cGroupId );
sNodeName      := WSTRING_TO_STRING( _cNodeName );
//  create clientid
sClientID := Concat( sGroupId,
                     sNodeName );
MakeValidClientID( sClientID );
WriteDeviceLog( UDINT_TO_DWORD( CmpLog.LogClass.LOG_INFO ),
                'EoN ClientId: %s',
                sClientID );
                'EoN GroupId: %s',
                sGroupId );
                'EoN NodeName: %s',
                sNodeName );
                'EoN Connecting with Primary Host: %s',
                sPrimaryHostID );
                'EoN Connecting to: %s',
                ServerUrl );
                'EoN Connecting on port: %s',
                UINT_TO_STRING( ServerPort ) );
                'EoN Session KeepAlive: %s sec',
                UINT_TO_STRING( KeepAlive ) );
// Setup the MQTT client connection
_MQTT.SetBroker( sUrl := ServerUrl,
                 uiPort := ServerPort,
                 uiKeepAlive := KeepAlive );
                'EoN CleanSession: %s',
                BOOL_TO_STRING( CleanSession ) );
                'EoN User: %s',
                WSTRING_TO_STRING( Username ) );
                'EoN Pass: %s',
                '****************' );
// Setup Credentials
_MQTT.SetSessionCredentials( xCleanSession := CleanSession,
                             sClientID := sClientID,
                             wsUser := Username,
                             wsPass := Password );
// Setup TLS
_MQTT.SetSessionTLS( xUseTLS := UseTLS,
                     hCert := hCert );
                'EoN TLS Certificate Handle: %s',
                SEL( UseTLS,
                     'None',
                     TO_STRING( hCert ) ) );
                'EoN TLS : %s',
                     'Disabled',
                     'Enabled' ) );
(* Create the AllMetricsList by adding all metrics which we 
   ever will send, after setting the lastWill we cannot alter 
   (add/remove metrics) AllMetricsList *)
 _NodeControl( AllMetricsList := THIS^._Metrics );
// set Lastwill, the _AllMetricsList is now set in concrete