- IED server: added function ConfigFileParser_createModelFromConfigFileEx with filename as argument to avoid dependency on FileSystem_... functions

- .NET projects: changed target framework of some project files to v4.0
pull/202/head
Michael Zillgith 6 years ago
parent cee97f7676
commit 5bd03b0611

@ -36,33 +36,20 @@ namespace IEC61850
/// Config file parser.
/// </summary>
public class ConfigFileParser
{
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr FileSystem_openFile(string filePath, [MarshalAs(UnmanagedType.I1)] bool readWrite);
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr ConfigFileParser_createModelFromConfigFile(IntPtr fileHandle);
public static IedModel CreateModelFromConfigFile(string filePath)
{
IntPtr fileHandle = FileSystem_openFile (filePath, false);
if (fileHandle != IntPtr.Zero) {
IntPtr retVal = ConfigFileParser_createModelFromConfigFile (fileHandle);
if (retVal == IntPtr.Zero) {
return null;
}
{
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr ConfigFileParser_createModelFromConfigFileEx(string filename);
return new IedModel (retVal);
public static IedModel CreateModelFromConfigFile(string filePath)
{
IntPtr retVal = ConfigFileParser_createModelFromConfigFileEx (filePath);
if (retVal == IntPtr.Zero) {
return null;
}
} else
return null;
//TODO else throw exception
}
}
return new IedModel (retVal);
}
}
/// <summary>
/// Representation of the IED server data model

@ -7,7 +7,7 @@
<OutputType>Exe</OutputType>
<RootNamespace>log_client</RootNamespace>
<AssemblyName>log_client</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>

@ -7,7 +7,8 @@
<OutputType>Exe</OutputType>
<RootNamespace>server1</RootNamespace>
<AssemblyName>server1</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@ -18,6 +19,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Externalconsole>true</Externalconsole>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>full</DebugType>

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@ -7,7 +7,8 @@
<OutputType>Exe</OutputType>
<RootNamespace>sv_subscriber</RootNamespace>
<AssemblyName>sv_subscriber</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>

@ -20,7 +20,6 @@
#include <stdlib.h>
#include <stdio.h>
#include "hal_filesystem.h"
#include "iec61850_config_file_parser.h"
static int running = 0;
@ -39,18 +38,8 @@ main(int argc, char** argv)
tcpPort = atoi(argv[1]);
}
/* open configuration file */
FileHandle configFile = FileSystem_openFile("model.cfg", false);
if (configFile == NULL) {
printf("Error opening config file!\n");
return 1;
}
/* parse the configuration file and create the data model */
IedModel* model = ConfigFileParser_createModelFromConfigFile(configFile);
FileSystem_closeFile(configFile);
IedModel* model = ConfigFileParser_createModelFromConfigFileEx("model.cfg");
if (model == NULL) {
printf("Error parsing config file!\n");

@ -40,6 +40,16 @@ extern "C" {
* @{
*/
/**
* \brief Create a data model from simple text configuration file
*
* \param filename name or path of the configuraton file
*
* \return the data model to be used by \ref IedServer
*/
LIB61850_API IedModel*
ConfigFileParser_createModelFromConfigFileEx(const char* filename);
LIB61850_API IedModel*
ConfigFileParser_createModelFromConfigFile(FileHandle fileHandle);

@ -90,6 +90,24 @@ terminateString(char* string, char ch)
}
}
IedModel*
ConfigFileParser_createModelFromConfigFileEx(const char* filename)
{
FileHandle configFile = FileSystem_openFile((char*)filename, false);
if (configFile == NULL) {
if (DEBUG_IED_SERVER)
printf("IED_SERVER: Error opening config file!\n");
return NULL;
}
IedModel* model = ConfigFileParser_createModelFromConfigFile(configFile);
FileSystem_closeFile(configFile);
return model;
}
IedModel*
ConfigFileParser_createModelFromConfigFile(FileHandle fileHandle)
{
@ -268,7 +286,7 @@ ConfigFileParser_createModelFromConfigFile(FileHandle fileHandle)
if (strcmp(currentLN->name, "LLN0") != 0) {
if (DEBUG_IED_SERVER)
printf("Setting group control is not defined in LLN0\n");
printf("IED_SERVER: Setting group control is not defined in LLN0\n");
goto exit_error;
}

Loading…
Cancel
Save