18 #include "serverconfigxml.h" 20 ServerConfigXml* OpcServer::m_pServerConfig = 0;
27 ServerConfigBasicXml(
const UaString& sXmlFileName,
const UaString& sApplicationPath, OpcServerCallback* pOpcServerCallback);
30 UaStatus
startUp(ServerManager*){
return OpcUa_Good;}
32 Session*
createSession(OpcUa_Int32 sessionID,
const UaNodeId &authenticationToken);
33 UaStatus
logonSessionUser(Session* pSession, UaUserIdentityToken* pUserIdentityToken);
42 if ( m_isStarted != OpcUa_False )
44 UaLocalizedText reason(
"en",
"Application shut down");
61 list<NodeManager*>::iterator it;
62 for ( it = m_listNodeManagers.begin(); it != m_listNodeManagers.end(); it++ )
67 m_listNodeManagers.clear();
69 if ( m_pServerConfig )
71 delete m_pServerConfig;
72 m_pServerConfig = NULL;
87 int OpcServer::setServerConfig(
const UaString& configurationFile,
const UaString& applicationPath)
89 UaMutexLocker lock(&m_mutex);
90 if ( m_isStarted != OpcUa_False )
96 m_configurationFile = configurationFile;
97 m_applicationPath = applicationPath;
100 if ( m_pServerConfig == NULL )
102 UaUniString sConfigFile(m_configurationFile.toUtf8());
103 sConfigFile = sConfigFile.toLower();
104 if ( sConfigFile.lastIndexOf(
".xml") > (sConfigFile.length() - 5) )
106 m_pServerConfig =
new ServerConfigBasicXml(m_configurationFile, m_applicationPath, m_pOpcServerCallback);
110 if ( m_pServerConfig->loadConfiguration().isGood() )
115 OpcUa_Boolean bTraceEnabled = OpcUa_False;
116 OpcUa_UInt32 uTraceLevel = 0;
117 OpcUa_Boolean bSdkTraceEnabled = OpcUa_False;
118 OpcUa_UInt32 uSdkTraceLevel = 0;
119 OpcUa_UInt32 uMaxTraceEntries = 0;
120 OpcUa_UInt32 uMaxBackupFiles = 0;
122 OpcUa_Boolean bDisableFlush;
124 m_pServerConfig->getStackTraceSettings(bTraceEnabled, uTraceLevel);
126 m_pServerConfig->getServerTraceSettings(
131 sTraceFile, bDisableFlush);
133 if (bSdkTraceEnabled != OpcUa_False)
135 SrvT::initTrace((UaTrace::TraceLevel)uSdkTraceLevel, uMaxTraceEntries, uMaxBackupFiles, sTraceFile,
"OpcUaCanOpenServer");
136 SrvT::setLocalTimeOutput(
true);
137 SrvT::setTraceActive(
true);
138 if (bTraceEnabled != OpcUa_False)
140 SrvT::setStackTraceActive(OpcUa_True, uTraceLevel);
148 cout <<
"Load Configuration" << endl;
163 int OpcServer::setServerConfig(ServerConfig* pServerConfig)
165 UaMutexLocker lock(&m_mutex);
166 if ( m_isStarted != OpcUa_False )
172 m_pServerConfig = (ServerConfigXml*)pServerConfig;
183 int OpcServer::addNodeManager(NodeManager* pNodeManager)
185 UaMutexLocker lock(&m_mutex);
187 m_listNodeManagers.push_back(pNodeManager);
189 if ( m_isStarted != OpcUa_False )
192 UaStatus ret = pNodeManager->startUp(m_pServerManager);
193 if ( ret.isNotGood() )
195 TRACE1_ERROR(SERVER_UI,
"Error: OpcServer::addNodeManager - can not start up node manager [ret=0x%lx]", ret.statusCode());