- IEC 61850 server: added support to set file service base path with server configuration object

pull/68/head
Michael Zillgith 7 years ago
parent 7cb5ff670a
commit c28d06f4d8

@ -3,6 +3,7 @@
*
* - How to use simple control models
* - How to serve analog measurement data
* - Using the IedServerConfig object to configure stack features
*/
#include "iec61850_server.h"
@ -89,16 +90,15 @@ main(int argc, char** argv)
/* Set buffer size for buffered report control blocks to 200000 bytes */
IedServerConfig_setReportBufferSize(config, 200000);
/* Set the base path for the MMS file services */
IedServerConfig_setFileServiceBasePath(config, "./vmd-filestore/");
/* Create a new IEC 61850 server instance */
iedServer = IedServer_createWithConfig(&iedModel, NULL, config);
/* configuration object is no longer required */
IedServerConfig_destroy(config);
/* Set the base path for the MMS file services */
MmsServer mmsServer = IedServer_getMmsServer(iedServer);
MmsServer_setFilestoreBasepath(mmsServer, "./vmd-filestore/");
/* Install handler for operate command */
IedServer_setControlHandler(iedServer, IEDMODEL_GenericIO_GGIO1_SPCSO1,
(ControlHandler) controlHandlerForBinaryOutput,

@ -50,6 +50,9 @@ struct sIedServerConfig
{
/** size of the report buffer associated with a buffered report control block */
int reportBufferSize;
/** Base path (directory where the file service serves files */
char* fileServiceBasepath;
};
/**
@ -82,6 +85,20 @@ IedServerConfig_setReportBufferSize(IedServerConfig self, int reportBufferSize);
int
IedServerConfig_getReportBufferSize(IedServerConfig self);
/**
* \brief Set the basepath of the file services
*
* \param basepath new file service base path
*/
void
IedServerConfig_setFileServiceBasePath(IedServerConfig self, const char* basepath);
/**
* \brief Get the basepath of the file services
*/
const char*
IedServerConfig_getFileServiceBasePath(IedServerConfig self);
/**

@ -421,6 +421,9 @@ IedServer_createWithConfig(IedModel* dataModel, TLSConfiguration tlsConfiguratio
self->mmsServer = MmsServer_create(self->mmsDevice, tlsConfiguration);
if (serverConfiguration)
MmsServer_setFilestoreBasepath(self->mmsServer, serverConfiguration->fileServiceBasepath);
MmsMapping_setMmsServer(self->mmsMapping, self->mmsServer);
MmsMapping_installHandlers(self->mmsMapping);

@ -31,6 +31,7 @@ IedServerConfig_create()
if (self) {
self->reportBufferSize = CONFIG_REPORTING_DEFAULT_REPORT_BUFFER_SIZE;
self->fileServiceBasepath = StringUtils_copyString(CONFIG_VIRTUAL_FILESTORE_BASEPATH);
}
return self;
@ -39,6 +40,7 @@ IedServerConfig_create()
void
IedServerConfig_destroy(IedServerConfig self)
{
GLOBAL_FREEMEM(self->fileServiceBasepath);
GLOBAL_FREEMEM(self);
}
@ -53,3 +55,21 @@ IedServerConfig_getReportBufferSize(IedServerConfig self)
{
return self->reportBufferSize;
}
void
IedServerConfig_setFileServiceBasePath(IedServerConfig self, const char* basepath)
{
#if (CONFIG_SET_FILESTORE_BASEPATH_AT_RUNTIME == 1)
GLOBAL_FREEMEM(self->fileServiceBasepath);
self->fileServiceBasepath = StringUtils_copyString(basepath);
#else
if (DEBUG_IED_SERVER)
printf("IED_SERVER_CONFIG: Cannot set file service basepath (enable CONFIG_SET_FILESTORE_BASEPATH_AT_RUNTIME)!\n");
#endif
}
const char*
IedServerConfig_getFileServiceBasePath(IedServerConfig self)
{
return self->fileServiceBasepath;
}

@ -586,3 +586,5 @@ EXPORTS
IedServerConfig_setReportBufferSize
IedServerConfig_getReportBufferSize
IedServer_createWithConfig
IedServerConfig_setFileServiceBasePath
IedServerConfig_getFileServiceBasePath

@ -713,3 +713,5 @@ EXPORTS
IedServerConfig_setReportBufferSize
IedServerConfig_getReportBufferSize
IedServer_createWithConfig
IedServerConfig_setFileServiceBasePath
IedServerConfig_getFileServiceBasePath

Loading…
Cancel
Save