From b86806ef13fb2086d15e398f8bc8814cfc59bd04 Mon Sep 17 00:00:00 2001 From: Michael Zillgith Date: Mon, 30 Sep 2024 16:57:25 +0100 Subject: [PATCH] - .NET API: added support for server side log service (LIB61850-461) --- CMakeLists.txt | 69 ++--- Makefile | 2 + dotnet/IEC61850forCSharp/IEC61850.NET.csproj | 6 +- dotnet/IEC61850forCSharp/IEC61850ServerAPI.cs | 108 +++++++- dotnet/authenticate/authenticate.csproj | 11 +- .../client_example_async.csproj | 5 +- .../client_example_setting_groups.csproj | 10 +- dotnet/control/control.csproj | 11 +- dotnet/datasets/datasets.csproj | 11 +- dotnet/dotnet.sln | 10 +- dotnet/example1/example1.csproj | 9 +- dotnet/example2/example2.csproj | 11 +- dotnet/example3/example3.csproj | 11 +- dotnet/files/files.csproj | 11 +- .../goose_subscriber/goose_subscriber.csproj | 10 +- dotnet/log_client/log_client.csproj | 14 +- dotnet/log_server/App.config | 6 + dotnet/log_server/Program.cs | 91 +++++++ dotnet/log_server/Properties/AssemblyInfo.cs | 36 +++ dotnet/log_server/log_server.csproj | 90 +++++++ dotnet/log_server/model.cfg | 237 ++++++++++++++++++ dotnet/model_browsing/model_browsing.csproj | 11 +- .../report_new_dataset.csproj | 11 +- dotnet/reporting/reporting.csproj | 11 +- dotnet/server1/server1.csproj | 6 +- dotnet/sv_subscriber/sv_subscriber.csproj | 11 +- dotnet/tests/tests.csproj | 6 +- .../tls_client_example.csproj | 8 +- .../tls_server_example.csproj | 8 +- .../client_example_log.c | 69 +++-- .../server_example_logging.c | 3 - hal/CMakeLists.txt | 3 +- mingw-w64-x86_64.cmake | 28 +++ src/CMakeLists.txt | 26 +- .../drivers/sqlite/log_storage_sqlite.c | 1 - src/logging/logging_api.h | 18 +- 36 files changed, 860 insertions(+), 129 deletions(-) create mode 100644 dotnet/log_server/App.config create mode 100644 dotnet/log_server/Program.cs create mode 100644 dotnet/log_server/Properties/AssemblyInfo.cs create mode 100644 dotnet/log_server/log_server.csproj create mode 100644 dotnet/log_server/model.cfg create mode 100644 mingw-w64-x86_64.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 831c0f8a..683c6ad2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -93,40 +93,6 @@ include_directories( ${CMAKE_CURRENT_LIST_DIR}/src/logging ) -set(API_HEADERS - hal/inc/hal_base.h - hal/inc/hal_time.h - hal/inc/hal_thread.h - hal/inc/hal_filesystem.h - hal/inc/hal_ethernet.h - hal/inc/hal_socket.h - hal/inc/tls_config.h - src/common/inc/libiec61850_common_api.h - src/common/inc/linked_list.h - src/common/inc/sntp_client.h - src/iec61850/inc/iec61850_client.h - src/iec61850/inc/iec61850_common.h - src/iec61850/inc/iec61850_server.h - src/iec61850/inc/iec61850_model.h - src/iec61850/inc/iec61850_cdc.h - src/iec61850/inc/iec61850_dynamic_model.h - src/iec61850/inc/iec61850_config_file_parser.h - src/mms/inc/mms_value.h - src/mms/inc/mms_common.h - src/mms/inc/mms_types.h - src/mms/inc/mms_type_spec.h - src/mms/inc/mms_client_connection.h - src/mms/inc/mms_server.h - src/mms/inc/iso_connection_parameters.h - src/goose/goose_subscriber.h - src/goose/goose_receiver.h - src/goose/goose_publisher.h - src/sampled_values/sv_subscriber.h - src/sampled_values/sv_publisher.h - src/r_session/r_session.h - src/logging/logging_api.h -) - if(MSVC AND MSVC_VERSION LESS 1800) include_directories( ${CMAKE_CURRENT_LIST_DIR}/src/vs @@ -158,6 +124,7 @@ endif(CONFIG_USE_EXTERNAL_MBEDTLS_DYNLIB) if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/third_party/sqlite/sqlite3.h) set(FOUND_SQLITE3_SOURCE 1) +set(SQLITE_INCLUDE_DIR"${CMAKE_CURRENT_LIST_DIR}/third_party/sqlite") message("Found sqlite3 source in third_party folder -> can compile with log service support") endif(EXISTS ${CMAKE_CURRENT_LIST_DIR}/third_party/sqlite/sqlite3.h) @@ -194,6 +161,40 @@ set(CONFIG_IEC61850_R_SMV 0) endif(WITH_MBEDTLS OR WITH_MBEDTLS3) +set(API_HEADERS + hal/inc/hal_base.h + hal/inc/hal_time.h + hal/inc/hal_thread.h + hal/inc/hal_filesystem.h + hal/inc/hal_ethernet.h + hal/inc/hal_socket.h + hal/inc/tls_config.h + src/common/inc/libiec61850_common_api.h + src/common/inc/linked_list.h + src/common/inc/sntp_client.h + src/iec61850/inc/iec61850_client.h + src/iec61850/inc/iec61850_common.h + src/iec61850/inc/iec61850_server.h + src/iec61850/inc/iec61850_model.h + src/iec61850/inc/iec61850_cdc.h + src/iec61850/inc/iec61850_dynamic_model.h + src/iec61850/inc/iec61850_config_file_parser.h + src/mms/inc/mms_value.h + src/mms/inc/mms_common.h + src/mms/inc/mms_types.h + src/mms/inc/mms_type_spec.h + src/mms/inc/mms_client_connection.h + src/mms/inc/mms_server.h + src/mms/inc/iso_connection_parameters.h + src/goose/goose_subscriber.h + src/goose/goose_receiver.h + src/goose/goose_publisher.h + src/sampled_values/sv_subscriber.h + src/sampled_values/sv_publisher.h + src/r_session/r_session.h + src/logging/logging_api.h +) + include(CheckCCompilerFlag) check_c_compiler_flag("-Wredundant-decls" SUPPORT_REDUNDANT_DECLS) diff --git a/Makefile b/Makefile index a7fef22a..070efc94 100644 --- a/Makefile +++ b/Makefile @@ -89,6 +89,8 @@ CFLAGS += -D'CONFIG_IEC61850_R_GOOSE=1' CFLAGS += -D'CONFIG_IEC61850_R_SMV=1' endif +LIB_INCLUDE_DIRS += src/logging/drivers/sqlite/log_storage_sqlite.c + LIB_INCLUDES = $(addprefix -I,$(LIB_INCLUDE_DIRS)) ifndef INSTALL_PREFIX diff --git a/dotnet/IEC61850forCSharp/IEC61850.NET.csproj b/dotnet/IEC61850forCSharp/IEC61850.NET.csproj index 4aa6af86..21da8024 100644 --- a/dotnet/IEC61850forCSharp/IEC61850.NET.csproj +++ b/dotnet/IEC61850forCSharp/IEC61850.NET.csproj @@ -1,5 +1,5 @@  - + Debug AnyCPU @@ -7,6 +7,8 @@ Library iec61850dotnet iec61850dotnet + v4.8 + true @@ -17,6 +19,7 @@ prompt 4 false + false none @@ -25,6 +28,7 @@ prompt 4 false + false diff --git a/dotnet/IEC61850forCSharp/IEC61850ServerAPI.cs b/dotnet/IEC61850forCSharp/IEC61850ServerAPI.cs index 8a0c5bf3..710131a3 100644 --- a/dotnet/IEC61850forCSharp/IEC61850ServerAPI.cs +++ b/dotnet/IEC61850forCSharp/IEC61850ServerAPI.cs @@ -1,7 +1,7 @@ /* * IEC61850ServerAPI.cs * - * Copyright 2016-2022 Michael Zillgith + * Copyright 2016-2024 Michael Zillgith * * This file is part of libIEC61850. * @@ -2154,6 +2154,97 @@ namespace IEC61850 public delegate CheckHandlerResult CheckHandler (ControlAction action, object parameter, MmsValue ctlVal, bool test, bool interlockCheck); + public static class SqliteLogStorage + { + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + static extern IntPtr SqliteLogStorage_createInstanceEx(string filename); + + public static LogStorage CreateLogStorage(string filename) + { + try + { + IntPtr nativeInstance = SqliteLogStorage_createInstanceEx(filename); + + if (nativeInstance != IntPtr.Zero) + return new LogStorage(nativeInstance); + else + return null; + } + catch (EntryPointNotFoundException ex) + { + Console.WriteLine(ex.Message + " Make sure that the libiec61850.dll was built with sqLite!"); + return null; + } + } + } + + public class LogStorage : IDisposable + { + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + static extern void LogStorage_setMaxLogEntries(IntPtr self, int maxEntries); + + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + static extern int LogStorage_getMaxLogEntries(IntPtr self); + + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + static extern void LogStorage_destroy(IntPtr self); + + private IntPtr self = IntPtr.Zero; + + internal IntPtr GetNativeInstance() + { + return self; + } + + internal LogStorage(IntPtr self) + { + this.self = self; + } + + private void SetMaxLogEntries(int maxEntries) + { + LogStorage_setMaxLogEntries(self, maxEntries); + } + + private int GetMaxLogEntries() + { + return LogStorage_getMaxLogEntries(self); + } + + /// + /// The maximum allowed number of log entries in the log storage + /// + public int MaxLogEntries + { + get + { + return GetMaxLogEntries(); + } + + set + { + SetMaxLogEntries(value); + } + } + + public void Dispose() + { + lock (this) + { + if (self != IntPtr.Zero) + { + LogStorage_destroy(self); + self = IntPtr.Zero; + } + } + } + + ~LogStorage() + { + Dispose(); + } + } + /// /// This class acts as the entry point for the IEC 61850 client API. It represents a single /// (MMS) connection to a server. @@ -2320,6 +2411,9 @@ namespace IEC61850 private InternalControlWaitForExecutionHandler internalControlWaitForExecutionHandlerRef = null; private InternalSelectStateChangedHandler internalSelectedStateChangedHandlerRef = null; + // hold references to managed LogStorage instances to avoid problems with GC + private Dictionary logStorages = new Dictionary(); + internal class ControlHandlerInfo { public DataObject controlObject = null; public GCHandle handle; @@ -3089,7 +3183,17 @@ namespace IEC61850 IedServer_setTimeQuality(self, leapSecondKnown, clockFailure, clockNotSynchronized, subsecondPrecision); } - } + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + static extern void IedServer_setLogStorage(IntPtr self, string logRef, IntPtr logStorage); + public void SetLogStorage(string logRef, LogStorage logStorage) + { + if (logStorage != null) + { + logStorages.Add(logRef, logStorage); + IedServer_setLogStorage(self, logRef, logStorage.GetNativeInstance()); + } + } + } } } diff --git a/dotnet/authenticate/authenticate.csproj b/dotnet/authenticate/authenticate.csproj index c05c41f8..4483ff96 100644 --- a/dotnet/authenticate/authenticate.csproj +++ b/dotnet/authenticate/authenticate.csproj @@ -1,5 +1,5 @@ - - + + Debug AnyCPU @@ -7,6 +7,8 @@ Exe authenticate authenticate + v4.8 + true @@ -17,6 +19,7 @@ prompt 4 true + false none @@ -25,6 +28,7 @@ prompt 4 true + false @@ -40,4 +44,7 @@ IEC61850.NET + + + \ No newline at end of file diff --git a/dotnet/client_example_async/client_example_async.csproj b/dotnet/client_example_async/client_example_async.csproj index 86340d04..5b0f9e5c 100644 --- a/dotnet/client_example_async/client_example_async.csproj +++ b/dotnet/client_example_async/client_example_async.csproj @@ -1,5 +1,5 @@  - + Debug AnyCPU @@ -7,7 +7,7 @@ Exe client_example_async client_example_async - v4.0 + v4.8 @@ -28,6 +28,7 @@ prompt 4 true + false diff --git a/dotnet/client_example_setting_groups/client_example_setting_groups.csproj b/dotnet/client_example_setting_groups/client_example_setting_groups.csproj index 9030d71b..c35fc669 100644 --- a/dotnet/client_example_setting_groups/client_example_setting_groups.csproj +++ b/dotnet/client_example_setting_groups/client_example_setting_groups.csproj @@ -1,5 +1,5 @@ - - + + Debug AnyCPU @@ -7,7 +7,8 @@ Exe clientexamplesettinggroup client-example-setting-group - v4.5 + v4.8 + true @@ -41,4 +42,7 @@ IEC61850.NET + + + \ No newline at end of file diff --git a/dotnet/control/control.csproj b/dotnet/control/control.csproj index efe7f4ca..baf5062a 100644 --- a/dotnet/control/control.csproj +++ b/dotnet/control/control.csproj @@ -1,5 +1,5 @@ - - + + Debug AnyCPU @@ -7,6 +7,8 @@ Exe control control + v4.8 + true @@ -17,6 +19,7 @@ prompt 4 true + false none @@ -25,6 +28,7 @@ prompt 4 true + false @@ -40,4 +44,7 @@ IEC61850.NET + + + \ No newline at end of file diff --git a/dotnet/datasets/datasets.csproj b/dotnet/datasets/datasets.csproj index 312ccbfd..94e90ba5 100644 --- a/dotnet/datasets/datasets.csproj +++ b/dotnet/datasets/datasets.csproj @@ -1,5 +1,5 @@ - - + + Debug AnyCPU @@ -7,6 +7,8 @@ Exe datasets datasets + v4.8 + true @@ -17,6 +19,7 @@ prompt 4 true + false none @@ -25,6 +28,7 @@ prompt 4 true + false @@ -40,4 +44,7 @@ IEC61850.NET + + + \ No newline at end of file diff --git a/dotnet/dotnet.sln b/dotnet/dotnet.sln index ba4aec17..359ede93 100644 --- a/dotnet/dotnet.sln +++ b/dotnet/dotnet.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.28307.779 +# Visual Studio Version 17 +VisualStudioVersion = 17.10.35004.147 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IEC61850.NET", "IEC61850forCSharp\IEC61850.NET.csproj", "{C35D624E-5506-4560-8074-1728F1FA1A4D}" EndProject @@ -50,6 +50,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "client_example_async", "cli EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "server_goose_publisher", "server_goose_publisher\server_goose_publisher.csproj", "{C14BB883-86B8-401C-B3D6-B655F55F3298}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "log_server", "log_server\log_server.csproj", "{96124F40-D38E-499B-9968-674E0D32F933}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -140,6 +142,10 @@ Global {C14BB883-86B8-401C-B3D6-B655F55F3298}.Debug|Any CPU.Build.0 = Debug|Any CPU {C14BB883-86B8-401C-B3D6-B655F55F3298}.Release|Any CPU.ActiveCfg = Release|Any CPU {C14BB883-86B8-401C-B3D6-B655F55F3298}.Release|Any CPU.Build.0 = Release|Any CPU + {96124F40-D38E-499B-9968-674E0D32F933}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {96124F40-D38E-499B-9968-674E0D32F933}.Debug|Any CPU.Build.0 = Debug|Any CPU + {96124F40-D38E-499B-9968-674E0D32F933}.Release|Any CPU.ActiveCfg = Release|Any CPU + {96124F40-D38E-499B-9968-674E0D32F933}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/dotnet/example1/example1.csproj b/dotnet/example1/example1.csproj index 592905b5..da7f380a 100644 --- a/dotnet/example1/example1.csproj +++ b/dotnet/example1/example1.csproj @@ -1,5 +1,5 @@  - + Debug AnyCPU @@ -7,6 +7,8 @@ Exe example1 example1 + v4.8 + true @@ -17,6 +19,7 @@ prompt 4 true + false none @@ -25,6 +28,7 @@ prompt 4 true + false @@ -40,4 +44,7 @@ IEC61850.NET + + + \ No newline at end of file diff --git a/dotnet/example2/example2.csproj b/dotnet/example2/example2.csproj index 612fcdb5..99d490e2 100644 --- a/dotnet/example2/example2.csproj +++ b/dotnet/example2/example2.csproj @@ -1,5 +1,5 @@ - - + + Debug AnyCPU @@ -7,6 +7,8 @@ Exe example2 example2 + v4.8 + true @@ -17,6 +19,7 @@ prompt 4 true + false none @@ -25,6 +28,7 @@ prompt 4 true + false @@ -40,4 +44,7 @@ IEC61850.NET + + + \ No newline at end of file diff --git a/dotnet/example3/example3.csproj b/dotnet/example3/example3.csproj index 4f60434a..189e432e 100644 --- a/dotnet/example3/example3.csproj +++ b/dotnet/example3/example3.csproj @@ -1,5 +1,5 @@ - - + + Debug AnyCPU @@ -7,6 +7,8 @@ Exe example3 example3 + v4.8 + true @@ -17,6 +19,7 @@ prompt 4 true + false none @@ -25,6 +28,7 @@ prompt 4 true + false @@ -40,4 +44,7 @@ IEC61850.NET + + + \ No newline at end of file diff --git a/dotnet/files/files.csproj b/dotnet/files/files.csproj index ba8c3186..6b943901 100644 --- a/dotnet/files/files.csproj +++ b/dotnet/files/files.csproj @@ -1,5 +1,5 @@ - - + + Debug AnyCPU @@ -7,6 +7,8 @@ Exe files files + v4.8 + true @@ -17,6 +19,7 @@ prompt 4 true + false none @@ -25,6 +28,7 @@ prompt 4 true + false @@ -40,4 +44,7 @@ IEC61850.NET + + + \ No newline at end of file diff --git a/dotnet/goose_subscriber/goose_subscriber.csproj b/dotnet/goose_subscriber/goose_subscriber.csproj index 077b65df..90b21bdb 100644 --- a/dotnet/goose_subscriber/goose_subscriber.csproj +++ b/dotnet/goose_subscriber/goose_subscriber.csproj @@ -1,5 +1,5 @@ - - + + Debug AnyCPU @@ -7,7 +7,8 @@ Exe goose_subscriber goose_subscriber - v4.5 + v4.8 + true @@ -41,4 +42,7 @@ IEC61850.NET + + + \ No newline at end of file diff --git a/dotnet/log_client/log_client.csproj b/dotnet/log_client/log_client.csproj index f9defe5c..8dc5eb5d 100644 --- a/dotnet/log_client/log_client.csproj +++ b/dotnet/log_client/log_client.csproj @@ -1,5 +1,5 @@ - - + + Debug AnyCPU @@ -7,7 +7,8 @@ Exe log_client log_client - v4.0 + v4.8 + true @@ -18,6 +19,7 @@ prompt 4 true + false full @@ -26,6 +28,7 @@ prompt 4 true + false @@ -41,4 +44,7 @@ IEC61850.NET - + + + + \ No newline at end of file diff --git a/dotnet/log_server/App.config b/dotnet/log_server/App.config new file mode 100644 index 00000000..aee9adf4 --- /dev/null +++ b/dotnet/log_server/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/dotnet/log_server/Program.cs b/dotnet/log_server/Program.cs new file mode 100644 index 00000000..26617d7e --- /dev/null +++ b/dotnet/log_server/Program.cs @@ -0,0 +1,91 @@ +using IEC61850.Common; +using IEC61850.Server; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; + +namespace log_server +{ + internal class Program + { + public static void Main(string[] args) + { + bool running = true; + + /* run until Ctrl-C is pressed */ + Console.CancelKeyPress += delegate (object sender, ConsoleCancelEventArgs e) + { + e.Cancel = true; + running = false; + }; + + IedModel iedModel = ConfigFileParser.CreateModelFromConfigFile("model.cfg"); + + if (iedModel == null) + { + Console.WriteLine("No valid data model found!"); + return; + } + + IedServerConfig config = new IedServerConfig(); + config.ReportBufferSize = 100000; + + IedServer iedServer = new IedServer(iedModel, config); + + LogStorage statusLog = SqliteLogStorage.CreateLogStorage("log_status.db"); + + statusLog.MaxLogEntries = 10; + + iedServer.SetLogStorage("GenericIO/LLN0$EventLog", statusLog); + + iedServer.Start(10002); + + if (iedServer.IsRunning()) + { + Console.WriteLine("Server started"); + + DataObject ggio1AnIn1 = (DataObject)iedModel.GetModelNodeByShortObjectReference("GenericIO/GGIO1.AnIn1"); + + DataAttribute ggio1AnIn1magF = (DataAttribute)ggio1AnIn1.GetChild("mag.f"); + DataAttribute ggio1AnIn1T = (DataAttribute)ggio1AnIn1.GetChild("t"); + + DataObject ggio1Spcso1 = (DataObject)iedModel.GetModelNodeByShortObjectReference("GenericIO/GGIO1.SPCSO1"); + + DataAttribute ggio1Spcso1stVal = (DataAttribute)ggio1Spcso1.GetChild("stVal"); + DataAttribute ggio1Spcso1T = (DataAttribute)ggio1Spcso1.GetChild("t"); + + float floatVal = 1.0f; + + bool stVal = true; + + while (running) + { + floatVal += 1f; + stVal = !stVal; + + iedServer.LockDataModel(); + var ts = new Timestamp(DateTime.Now); + iedServer.UpdateTimestampAttributeValue(ggio1AnIn1T, ts); + iedServer.UpdateFloatAttributeValue(ggio1AnIn1magF, floatVal); + iedServer.UpdateTimestampAttributeValue(ggio1Spcso1T, ts); + iedServer.UpdateBooleanAttributeValue(ggio1Spcso1stVal, stVal); + iedServer.UnlockDataModel(); + + Thread.Sleep(100); + } + + iedServer.Stop(); + Console.WriteLine("Server stopped"); + } + else + { + Console.WriteLine("Failed to start server"); + } + + iedServer.Destroy(); + } + } +} diff --git a/dotnet/log_server/Properties/AssemblyInfo.cs b/dotnet/log_server/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..c553a20a --- /dev/null +++ b/dotnet/log_server/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("log_server")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("log_server")] +[assembly: AssemblyCopyright("Copyright © 2024")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("96124f40-d38e-499b-9968-674e0d32f933")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/dotnet/log_server/log_server.csproj b/dotnet/log_server/log_server.csproj new file mode 100644 index 00000000..1e2bab4b --- /dev/null +++ b/dotnet/log_server/log_server.csproj @@ -0,0 +1,90 @@ + + + + + Debug + AnyCPU + {96124F40-D38E-499B-9968-674E0D32F933} + Exe + log_server + log_server + v4.8.1 + 512 + true + true + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG + prompt + 4 + false + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + PreserveNewest + + + + + {C35D624E-5506-4560-8074-1728F1FA1A4D} + IEC61850.NET + + + + + False + Microsoft .NET Framework 4.8.1 %28x86 and x64%29 + true + + + False + .NET Framework 3.5 SP1 + false + + + + \ No newline at end of file diff --git a/dotnet/log_server/model.cfg b/dotnet/log_server/model.cfg new file mode 100644 index 00000000..6f332425 --- /dev/null +++ b/dotnet/log_server/model.cfg @@ -0,0 +1,237 @@ +MODEL(simpleIO){ +LD(GenericIO){ +LN(LLN0){ +DO(Mod 0){ +DA(stVal 0 12 0 1 0); +DA(q 0 23 0 2 0); +DA(t 0 22 0 0 0); +DA(ctlModel 0 12 4 0 0)=0; +} +DO(Beh 0){ +DA(stVal 0 12 0 1 0); +DA(q 0 23 0 2 0); +DA(t 0 22 0 0 0); +} +DO(Health 0){ +DA(stVal 0 3 0 1 0); +DA(q 0 23 0 2 0); +DA(t 0 22 0 0 0); +} +DO(NamPlt 0){ +DA(vendor 0 20 5 0 0); +DA(swRev 0 20 5 0 0); +DA(d 0 20 5 0 0); +DA(configRev 0 20 5 0 0); +DA(ldNs 0 20 11 0 0); +} +DS(Events){ +DE(GGIO1$ST$SPCSO1$stVal); +DE(GGIO1$ST$SPCSO2$stVal); +DE(GGIO1$ST$SPCSO3$stVal); +DE(GGIO1$ST$SPCSO4$stVal); +} +DS(AnalogValues){ +DE(GGIO1$MX$AnIn1); +DE(GGIO1$MX$AnIn2); +DE(GGIO1$MX$AnIn3); +DE(GGIO1$MX$AnIn4); +} +RC(EventsRCB01 Events 0 Events 1 24 111 50 1000); +RC(AnalogValuesRCB01 AnalogValues 0 AnalogValues 1 24 111 50 1000); +LC(EventLog Events GenericIO/LLN0$EventLog 19 0 0 1); +LC(GeneralLog - - 19 0 0 1); +LOG(GeneralLog); +LOG(EventLog); +GC(gcbEvents events Events 2 0 -1 -1 ){ +PA(4 273 4096 010ccd010001); +} +GC(gcbAnalogValues analog AnalogValues 2 0 -1 -1 ){ +PA(4 273 4096 010ccd010001); +} +} +LN(LPHD1){ +DO(PhyNam 0){ +DA(vendor 0 20 5 0 0); +} +DO(PhyHealth 0){ +DA(stVal 0 3 0 1 0); +DA(q 0 23 0 2 0); +DA(t 0 22 0 0 0); +} +DO(Proxy 0){ +DA(stVal 0 0 0 1 0); +DA(q 0 23 0 2 0); +DA(t 0 22 0 0 0); +} +} +LN(GGIO1){ +DO(Mod 0){ +DA(stVal 0 12 0 1 0); +DA(q 0 23 0 2 0); +DA(t 0 22 0 0 0); +DA(ctlModel 0 12 4 0 0)=0; +} +DO(Beh 0){ +DA(stVal 0 12 0 1 0); +DA(q 0 23 0 2 0); +DA(t 0 22 0 0 0); +} +DO(Health 0){ +DA(stVal 0 3 0 1 0); +DA(q 0 23 0 2 0); +DA(t 0 22 0 0 0); +} +DO(NamPlt 0){ +DA(vendor 0 20 5 0 0); +DA(swRev 0 20 5 0 0); +DA(d 0 20 5 0 0); +} +DO(AnIn1 0){ +DA(mag 0 27 1 1 0){ +DA(f 0 10 1 1 0); +} +DA(q 0 23 1 2 0); +DA(t 0 22 1 0 0); +} +DO(AnIn2 0){ +DA(mag 0 27 1 1 101){ +DA(f 0 10 1 1 0); +} +DA(q 0 23 1 2 0); +DA(t 0 22 1 0 102); +} +DO(AnIn3 0){ +DA(mag 0 27 1 1 0){ +DA(f 0 10 1 1 0); +} +DA(q 0 23 1 2 0); +DA(t 0 22 1 0 0); +} +DO(AnIn4 0){ +DA(mag 0 27 1 1 0){ +DA(f 0 10 1 1 0); +} +DA(q 0 23 1 2 0); +DA(t 0 22 1 0 0); +} +DO(SPCSO1 0){ +DA(stVal 0 0 0 1 0); +DA(q 0 23 0 2 0); +DA(Oper 0 27 12 0 0){ +DA(ctlVal 0 0 12 0 0); +DA(origin 0 27 12 0 0){ +DA(orCat 0 12 12 0 0); +DA(orIdent 0 13 12 0 0); +} +DA(ctlNum 0 6 12 0 0); +DA(T 0 22 12 0 0); +DA(Test 0 0 12 0 0); +DA(Check 0 24 12 0 0); +} +DA(ctlModel 0 12 4 0 0)=1; +DA(t 0 22 0 0 0); +} +DO(SPCSO2 0){ +DA(stVal 0 0 0 1 0); +DA(q 0 23 0 2 0); +DA(Oper 0 27 12 0 0){ +DA(ctlVal 0 0 12 0 0); +DA(origin 0 27 12 0 0){ +DA(orCat 0 12 12 0 0); +DA(orIdent 0 13 12 0 0); +} +DA(ctlNum 0 6 12 0 0); +DA(T 0 22 12 0 0); +DA(Test 0 0 12 0 0); +DA(Check 0 24 12 0 0); +} +DA(ctlModel 0 12 4 0 0)=1; +DA(t 0 22 0 0 0); +} +DO(SPCSO3 0){ +DA(stVal 0 0 0 1 0); +DA(q 0 23 0 2 0); +DA(Oper 0 27 12 0 0){ +DA(ctlVal 0 0 12 0 0); +DA(origin 0 27 12 0 0){ +DA(orCat 0 12 12 0 0); +DA(orIdent 0 13 12 0 0); +} +DA(ctlNum 0 6 12 0 0); +DA(T 0 22 12 0 0); +DA(Test 0 0 12 0 0); +DA(Check 0 24 12 0 0); +} +DA(ctlModel 0 12 4 0 0)=1; +DA(t 0 22 0 0 0); +} +DO(SPCSO4 0){ +DA(stVal 0 0 0 1 0); +DA(q 0 23 0 2 0); +DA(Oper 0 27 12 0 0){ +DA(ctlVal 0 0 12 0 0); +DA(origin 0 27 12 0 0){ +DA(orCat 0 12 12 0 0); +DA(orIdent 0 13 12 0 0); +} +DA(ctlNum 0 6 12 0 0); +DA(T 0 22 12 0 0); +DA(Test 0 0 12 0 0); +DA(Check 0 24 12 0 0); +} +DA(ctlModel 0 12 4 0 0)=1; +DA(t 0 22 0 0 0); +} +DO(Ind1 0){ +DA(stVal 0 0 0 1 0); +DA(q 0 23 0 2 0); +DA(t 0 22 0 0 0); +} +DO(Ind2 0){ +DA(stVal 0 0 0 1 0); +DA(q 0 23 0 2 0); +DA(t 0 22 0 0 0); +} +DO(Ind3 0){ +DA(stVal 0 0 0 1 0); +DA(q 0 23 0 2 0); +DA(t 0 22 0 0 0); +} +DO(Ind4 0){ +DA(stVal 0 0 0 1 0); +DA(q 0 23 0 2 0); +DA(t 0 22 0 0 0); +} +} +LN(PDUP1){ +DO(Beh 0){ +DA(stVal 0 12 0 1 0); +DA(q 0 23 0 2 0); +DA(t 0 22 0 0 0); +} +DO(Mod 0){ +DA(stVal 0 12 0 1 0); +DA(q 0 23 0 2 0); +DA(t 0 22 0 0 0); +DA(ctlModel 0 12 4 0 0)=0; +} +DO(Str 0){ +DA(general 0 0 0 1 0); +DA(dirGeneral 0 12 0 1 0); +DA(q 0 23 0 2 0); +DA(t 0 22 0 0 0); +} +DO(Op 0){ +DA(general 0 0 0 1 0); +DA(q 0 23 0 2 0); +DA(t 0 22 0 0 0); +} +DO(OpDlTmms 0){ +DA(setVal 0 3 2 1 0); +} +DO(RsDlTmms 0){ +DA(setVal 0 3 2 1 0); +} +} +} +} diff --git a/dotnet/model_browsing/model_browsing.csproj b/dotnet/model_browsing/model_browsing.csproj index 8162b3f8..de4fc963 100644 --- a/dotnet/model_browsing/model_browsing.csproj +++ b/dotnet/model_browsing/model_browsing.csproj @@ -1,5 +1,5 @@ - - + + Debug AnyCPU @@ -7,6 +7,8 @@ Exe model_browsing model_browsing + v4.8 + true @@ -17,6 +19,7 @@ prompt 4 true + false none @@ -25,6 +28,7 @@ prompt 4 true + false @@ -40,4 +44,7 @@ IEC61850.NET + + + \ No newline at end of file diff --git a/dotnet/report_new_dataset/report_new_dataset.csproj b/dotnet/report_new_dataset/report_new_dataset.csproj index ccf2dc93..fb520387 100644 --- a/dotnet/report_new_dataset/report_new_dataset.csproj +++ b/dotnet/report_new_dataset/report_new_dataset.csproj @@ -1,5 +1,5 @@ - - + + Debug AnyCPU @@ -7,6 +7,8 @@ Exe report_new_dataset report_new_dataset + v4.8 + true @@ -17,6 +19,7 @@ prompt 4 true + false none @@ -25,6 +28,7 @@ prompt 4 true + false @@ -40,4 +44,7 @@ IEC61850.NET + + + \ No newline at end of file diff --git a/dotnet/reporting/reporting.csproj b/dotnet/reporting/reporting.csproj index 53a5829e..bed208a4 100644 --- a/dotnet/reporting/reporting.csproj +++ b/dotnet/reporting/reporting.csproj @@ -1,5 +1,5 @@  - + Debug AnyCPU @@ -22,6 +22,8 @@ false false true + v4.8 + true @@ -33,6 +35,7 @@ 4 true true + false none @@ -41,6 +44,7 @@ prompt 4 true + false @@ -78,4 +82,7 @@ true - + + + + \ No newline at end of file diff --git a/dotnet/server1/server1.csproj b/dotnet/server1/server1.csproj index ab6d9c85..c0cd3eb3 100644 --- a/dotnet/server1/server1.csproj +++ b/dotnet/server1/server1.csproj @@ -1,5 +1,5 @@  - + Debug AnyCPU @@ -7,7 +7,7 @@ Exe server1 server1 - v4.0 + v4.8 @@ -28,6 +28,7 @@ prompt 4 true + false @@ -44,6 +45,7 @@ + PreserveNewest diff --git a/dotnet/sv_subscriber/sv_subscriber.csproj b/dotnet/sv_subscriber/sv_subscriber.csproj index 4d0fa10d..400ab39a 100644 --- a/dotnet/sv_subscriber/sv_subscriber.csproj +++ b/dotnet/sv_subscriber/sv_subscriber.csproj @@ -1,5 +1,5 @@  - + Debug AnyCPU @@ -7,7 +7,7 @@ Exe sv_subscriber sv_subscriber - v4.0 + v4.8 @@ -19,6 +19,7 @@ prompt 4 true + false full @@ -27,6 +28,7 @@ prompt 4 true + false @@ -42,4 +44,7 @@ IEC61850.NET - + + + + \ No newline at end of file diff --git a/dotnet/tests/tests.csproj b/dotnet/tests/tests.csproj index ecaf4e89..e7c7349b 100644 --- a/dotnet/tests/tests.csproj +++ b/dotnet/tests/tests.csproj @@ -1,5 +1,5 @@  - + Debug AnyCPU @@ -7,6 +7,8 @@ Library tests tests + v4.8 + true @@ -17,6 +19,7 @@ prompt 4 false + false none @@ -25,6 +28,7 @@ prompt 4 false + false diff --git a/dotnet/tls_client_example/tls_client_example.csproj b/dotnet/tls_client_example/tls_client_example.csproj index 389abef9..44e6086e 100644 --- a/dotnet/tls_client_example/tls_client_example.csproj +++ b/dotnet/tls_client_example/tls_client_example.csproj @@ -1,5 +1,5 @@ - - + + Debug AnyCPU @@ -7,7 +7,8 @@ Exe tls_client_example tls_client_example - v4.5 + v4.8 + true @@ -42,6 +43,7 @@ + PreserveNewest diff --git a/dotnet/tls_server_example/tls_server_example.csproj b/dotnet/tls_server_example/tls_server_example.csproj index 012dd760..2015bd55 100644 --- a/dotnet/tls_server_example/tls_server_example.csproj +++ b/dotnet/tls_server_example/tls_server_example.csproj @@ -1,5 +1,5 @@ - - + + Debug AnyCPU @@ -7,7 +7,8 @@ Exe tls_server_example tls_server_example - v4.5 + v4.8 + true @@ -42,6 +43,7 @@ + PreserveNewest diff --git a/examples/iec61850_client_example_log/client_example_log.c b/examples/iec61850_client_example_log/client_example_log.c index 1c675955..17639c3b 100644 --- a/examples/iec61850_client_example_log/client_example_log.c +++ b/examples/iec61850_client_example_log/client_example_log.c @@ -5,13 +5,12 @@ */ #include "iec61850_client.h" +#include "hal_thread.h" #include #include #include -//#include "hal_thread.h" - static void printJournalEntries(LinkedList journalEntries) { @@ -19,8 +18,8 @@ printJournalEntries(LinkedList journalEntries) LinkedList journalEntriesElem = LinkedList_getNext(journalEntries); - while (journalEntriesElem != NULL) { - + while (journalEntriesElem != NULL) + { MmsJournalEntry journalEntry = (MmsJournalEntry) LinkedList_getData(journalEntriesElem); MmsValue_printToBuffer(MmsJournalEntry_getEntryID(journalEntry), buf, 1024); @@ -30,8 +29,8 @@ printJournalEntries(LinkedList journalEntries) LinkedList journalVariableElem = LinkedList_getNext(journalEntry->journalVariables); - while (journalVariableElem != NULL) { - + while (journalVariableElem != NULL) + { MmsJournalVariable journalVariable = (MmsJournalVariable) LinkedList_getData(journalVariableElem); printf(" variable-tag: %s\n", MmsJournalVariable_getTag(journalVariable)); @@ -45,8 +44,9 @@ printJournalEntries(LinkedList journalEntries) } } -int main(int argc, char** argv) { - +int +main(int argc, char** argv) +{ char* hostname; int tcpPort = 102; @@ -58,7 +58,7 @@ int main(int argc, char** argv) { if (argc > 2) tcpPort = atoi(argv[2]); - char* logRef = "simpleIOGenericIO/LLN0$EventLog"; + char* logRef = "TestIEDGenericIO/LLN0$EventLog"; IedClientError error; @@ -66,19 +66,21 @@ int main(int argc, char** argv) { IedConnection_connect(con, &error, hostname, tcpPort); - if (error == IED_ERROR_OK) { - + if (error == IED_ERROR_OK) + { /* read list of logs in LN (optional - if you don't know the existing logs) */ - LinkedList logs = IedConnection_getLogicalNodeDirectory(con, &error, "simpleIOGenericIO/LLN0", ACSI_CLASS_LOG); - - if (error == IED_ERROR_OK) { + LinkedList logs = IedConnection_getLogicalNodeDirectory(con, &error, "TestIEDGenericIO/LLN0", ACSI_CLASS_LOG); - if (LinkedList_size(logs) > 0) { + if (error == IED_ERROR_OK) + { + if (LinkedList_size(logs) > 0) + { printf("Found logs in LN simpleIOGenericIO/LLN0:\n"); LinkedList log = LinkedList_getNext(logs); - while (log != NULL) { + while (log != NULL) + { char* logName = (char*) LinkedList_getData(log); printf(" %s\n", logName); @@ -86,18 +88,31 @@ int main(int argc, char** argv) { log = LinkedList_getNext(log); } } - else { + else + { printf("No logs found\n"); } LinkedList_destroy(logs); } - /* read log control block (using the generic read function) */ - MmsValue* lcbValue = IedConnection_readObject(con, &error, "simpleIOGenericIO/LLN0.EventLog", IEC61850_FC_LG); + IedConnection_writeBooleanValue(con, &error, "TestIEDGenericIO/LLN0.EventLog.LogEna", IEC61850_FC_LG, true); + + if (error == IED_ERROR_OK) + { + printf("Enabled log. Waiting ...\n"); + Thread_sleep(1000); + } + else + { + printf("Failed to enable log (err=%i)\n", error); + } - if ((error == IED_ERROR_OK) && (MmsValue_getType(lcbValue) != MMS_DATA_ACCESS_ERROR)) { + /* read log control block (using the generic read function) */ + MmsValue* lcbValue = IedConnection_readObject(con, &error, "TestIEDGenericIO/LLN0.EventLog", IEC61850_FC_LG); + if ((error == IED_ERROR_OK) && (MmsValue_getType(lcbValue) != MMS_DATA_ACCESS_ERROR)) + { char printBuf[1024]; MmsValue_printToBuffer(lcbValue, printBuf, 1024); @@ -115,9 +130,12 @@ int main(int argc, char** argv) { * read the log contents. Be aware that the logRef uses the '$' sign as separator between the LN and * the log name! This is in contrast to the LCB object reference above. */ - LinkedList logEntries = IedConnection_queryLogAfter(con, &error, "simpleIOGenericIO/LLN0$EventLog", oldEntry, timestamp, &moreFollows); + LinkedList logEntries = IedConnection_queryLogAfter(con, &error, logRef, oldEntry, timestamp, &moreFollows); + + if (error == IED_ERROR_OK) + { + printf("Received %d log entries for %s\n", LinkedList_size(logEntries), logRef); - if (error == IED_ERROR_OK) { printJournalEntries(logEntries); LinkedList_destroyDeep(logEntries, (LinkedListValueDeleteFunction) MmsJournalEntry_destroy); @@ -132,15 +150,14 @@ int main(int argc, char** argv) { else printf("Read LCB failed!\n"); - IedConnection_abort(con, &error); } - else { + else + { printf("Failed to connect to %s:%i\n", hostname, tcpPort); } IedConnection_destroy(con); + return 0; } - - diff --git a/examples/server_example_logging/server_example_logging.c b/examples/server_example_logging/server_example_logging.c index e086d52a..e4230344 100644 --- a/examples/server_example_logging/server_example_logging.c +++ b/examples/server_example_logging/server_example_logging.c @@ -17,9 +17,6 @@ #include "logging_api.h" -LogStorage -SqliteLogStorage_createInstance(const char* filename); - static int running = 0; static IedServer iedServer = NULL; diff --git a/hal/CMakeLists.txt b/hal/CMakeLists.txt index 7b9f2db9..53bafdca 100644 --- a/hal/CMakeLists.txt +++ b/hal/CMakeLists.txt @@ -206,7 +206,8 @@ IF(CONFIG_USE_EXTERNAL_MBEDTLS_DYNLIB) ENDIF(CONFIG_USE_EXTERNAL_MBEDTLS_DYNLIB) IF(MINGW) - target_link_libraries(hal ws2_32 iphlpapi) + target_link_libraries(hal ws2_32 iphlpapi bcrypt) + message("Building with MinGW") ENDIF(MINGW) IF (MSVC) diff --git a/mingw-w64-x86_64.cmake b/mingw-w64-x86_64.cmake new file mode 100644 index 00000000..e86af924 --- /dev/null +++ b/mingw-w64-x86_64.cmake @@ -0,0 +1,28 @@ +# Sample toolchain file for building for Windows from an Ubuntu Linux system. +# +# Typical usage: +# *) install cross compiler: `sudo apt-get install mingw-w64` +# *) cd build +# *) cmake -DCMAKE_TOOLCHAIN_FILE=~/mingw-w64-x86_64.cmake .. +# This is free and unencumbered software released into the public domain. + +set(CMAKE_SYSTEM_NAME Windows) +set(TOOLCHAIN_PREFIX x86_64-w64-mingw32) + +# cross compilers to use for C, C++ and Fortran +set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc) +set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++) +set(CMAKE_Fortran_COMPILER ${TOOLCHAIN_PREFIX}-gfortran) +set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres) + +# target environment on the build host system +set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX}) + +# modify default behavior of FIND_XXX() commands +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + +# Add bcrypt to the linker flags +set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lbcrypt") +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -lbcrypt") \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 666a2baa..13cb9d9e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -92,6 +92,15 @@ set (lib_common_SRCS ./logging/log_storage.c ) +if(FOUND_SQLITE3_SOURCE) +message("sqlite3 source -> adding to lib source") +set (lib_common_SRCS + ${lib_common_SRCS} + ./logging/drivers/sqlite/log_storage_sqlite.c + ./../third_party/sqlite/sqlite3.c +) +endif(FOUND_SQLITE3_SOURCE) + set (lib_asn1c_SRCS ./mms/iso_mms/asn1c/DataAccessError.c ./mms/iso_mms/asn1c/DeleteNamedVariableListRequest.c @@ -234,17 +243,6 @@ endif() set_source_files_properties(${lib_asn1c_SRCS} PROPERTIES LANGUAGE C) -IF(MSVC) -set_source_files_properties(${lib_common_SRCS} ${lib_windows_SRCS} - PROPERTIES LANGUAGE CXX) -set_source_files_properties(${lib_rsession_SRCS} - PROPERTIES LANGUAGE CXX) -set_source_files_properties(${lib_goose_SRCS} - PROPERTIES LANGUAGE CXX) -set_source_files_properties(${lib_sv_SRCS} - PROPERTIES LANGUAGE CXX) -ENDIF() - IF(WITH_WPCAP) ELSE() add_definitions(-DEXCLUDE_ETHERNET_WINDOWS) @@ -254,6 +252,10 @@ include_directories( ../third_party/winpcap/include ) +include_directories( + ../third_party/sqlite +) + IF(WITH_WPCAP OR CONFIG_IEC61850_R_GOOSE OR CONFIG_IEC61850_R_SMV) set (library_SRCS ${lib_common_SRCS} @@ -371,7 +373,7 @@ IF(UNIX) ENDIF (CONFIG_SYSTEM_HAS_CLOCK_GETTIME) ENDIF(UNIX) IF(MINGW) - target_link_libraries(iec61850-shared ws2_32 iphlpapi) + target_link_libraries(iec61850-shared ws2_32 iphlpapi bcrypt) target_link_libraries(iec61850 ws2_32 iphlpapi) ENDIF(MINGW) diff --git a/src/logging/drivers/sqlite/log_storage_sqlite.c b/src/logging/drivers/sqlite/log_storage_sqlite.c index f7e88be4..68d945c8 100644 --- a/src/logging/drivers/sqlite/log_storage_sqlite.c +++ b/src/logging/drivers/sqlite/log_storage_sqlite.c @@ -99,7 +99,6 @@ copyStringInternal(const char* string) LogStorage SqliteLogStorage_createInstance(const char* filename) { - sqlite3* db = NULL; sqlite3_stmt* insertEntryStmt = NULL; sqlite3_stmt* insertEntryDataStmt = NULL; diff --git a/src/logging/logging_api.h b/src/logging/logging_api.h index 7f5327fc..1cef5b01 100644 --- a/src/logging/logging_api.h +++ b/src/logging/logging_api.h @@ -30,7 +30,6 @@ extern "C" { #include "libiec61850_common_api.h" - /** \addtogroup server_api_group * @{ */ @@ -75,8 +74,8 @@ typedef bool (*LogEntryCallback) (void* parameter, uint64_t timestamp, uint64_t */ typedef bool (*LogEntryDataCallback) (void* parameter, const char* dataRef, uint8_t* data, int dataSize, uint8_t reasonCode, bool moreFollow); -struct sLogStorage { - +struct sLogStorage +{ void* instanceData; int maxLogEntries; @@ -97,7 +96,6 @@ struct sLogStorage { void (*destroy) (LogStorage self); }; - /** * \brief Set the maximum number of log entries for this log * @@ -107,6 +105,18 @@ struct sLogStorage { LIB61850_API void LogStorage_setMaxLogEntries(LogStorage self, int maxEntries); +/** + * \brief Create a new LogStorage instance using embedded sqlite + * + * \note library has to be compiled with sqlite support + * + * \param filename name of the sqlite database file to be used + * + * \return new LogStorage instance + */ +LIB61850_API LogStorage +SqliteLogStorage_createInstance(const char* filename); + /** * \brief Get the maximum allowed number of log entries for this log *