diff --git a/dotnet/IEC61850forCSharp/IEC61850CommonAPI.cs b/dotnet/IEC61850forCSharp/IEC61850CommonAPI.cs
index 19acd559..18f1aa8c 100644
--- a/dotnet/IEC61850forCSharp/IEC61850CommonAPI.cs
+++ b/dotnet/IEC61850forCSharp/IEC61850CommonAPI.cs
@@ -173,6 +173,87 @@ namespace IEC61850
QUESTIONABLE = 3
}
+ ///
+ /// MmsError values
+ ///
+ public enum MmsError
+ {
+ /* generic error codes */
+ MMS_ERROR_NONE = 0,
+ MMS_ERROR_CONNECTION_REJECTED = 1,
+ MMS_ERROR_CONNECTION_LOST = 2,
+ MMS_ERROR_SERVICE_TIMEOUT = 3,
+ MMS_ERROR_PARSING_RESPONSE = 4,
+ MMS_ERROR_HARDWARE_FAULT = 5,
+ MMS_ERROR_CONCLUDE_REJECTED = 6,
+ MMS_ERROR_INVALID_ARGUMENTS = 7,
+ MMS_ERROR_OUTSTANDING_CALL_LIMIT = 8,
+
+ MMS_ERROR_OTHER = 9,
+
+ /* confirmed error PDU codes */
+ MMS_ERROR_VMDSTATE_OTHER = 10,
+
+ MMS_ERROR_APPLICATION_REFERENCE_OTHER = 20,
+
+ MMS_ERROR_DEFINITION_OTHER = 30,
+ MMS_ERROR_DEFINITION_INVALID_ADDRESS = 31,
+ MMS_ERROR_DEFINITION_TYPE_UNSUPPORTED = 32,
+ MMS_ERROR_DEFINITION_TYPE_INCONSISTENT = 33,
+ MMS_ERROR_DEFINITION_OBJECT_UNDEFINED = 34,
+ MMS_ERROR_DEFINITION_OBJECT_EXISTS = 35,
+ MMS_ERROR_DEFINITION_OBJECT_ATTRIBUTE_INCONSISTENT = 36,
+
+ MMS_ERROR_RESOURCE_OTHER = 40,
+ MMS_ERROR_RESOURCE_CAPABILITY_UNAVAILABLE = 41,
+
+ MMS_ERROR_SERVICE_OTHER = 50,
+ MMS_ERROR_SERVICE_OBJECT_CONSTRAINT_CONFLICT = 55,
+
+ MMS_ERROR_SERVICE_PREEMPT_OTHER = 60,
+
+ MMS_ERROR_TIME_RESOLUTION_OTHER = 70,
+
+ MMS_ERROR_ACCESS_OTHER = 80,
+ MMS_ERROR_ACCESS_OBJECT_NON_EXISTENT = 81,
+ MMS_ERROR_ACCESS_OBJECT_ACCESS_UNSUPPORTED = 82,
+ MMS_ERROR_ACCESS_OBJECT_ACCESS_DENIED = 83,
+ MMS_ERROR_ACCESS_OBJECT_INVALIDATED = 84,
+ MMS_ERROR_ACCESS_OBJECT_VALUE_INVALID = 85, /* for DataAccessError 11 */
+ MMS_ERROR_ACCESS_TEMPORARILY_UNAVAILABLE = 86, /* for DataAccessError 2 */
+
+ MMS_ERROR_FILE_OTHER = 90,
+ MMS_ERROR_FILE_FILENAME_AMBIGUOUS = 91,
+ MMS_ERROR_FILE_FILE_BUSY = 92,
+ MMS_ERROR_FILE_FILENAME_SYNTAX_ERROR = 93,
+ MMS_ERROR_FILE_CONTENT_TYPE_INVALID = 94,
+ MMS_ERROR_FILE_POSITION_INVALID = 95,
+ MMS_ERROR_FILE_FILE_ACCESS_DENIED = 96,
+ MMS_ERROR_FILE_FILE_NON_EXISTENT = 97,
+ MMS_ERROR_FILE_DUPLICATE_FILENAME = 98,
+ MMS_ERROR_FILE_INSUFFICIENT_SPACE_IN_FILESTORE = 99,
+
+ /* reject codes */
+ MMS_ERROR_REJECT_OTHER = 100,
+ MMS_ERROR_REJECT_UNKNOWN_PDU_TYPE = 101,
+ MMS_ERROR_REJECT_INVALID_PDU = 102,
+ MMS_ERROR_REJECT_UNRECOGNIZED_SERVICE = 103,
+ MMS_ERROR_REJECT_UNRECOGNIZED_MODIFIER = 104,
+ MMS_ERROR_REJECT_REQUEST_INVALID_ARGUMENT = 105
+ }
+
+ ///
+ /// MmsFileServiceType values
+ ///
+ public enum MmsFileServiceType
+ {
+ MMS_FILE_ACCESS_TYPE_READ_DIRECTORY = 0,
+ MMS_FILE_ACCESS_TYPE_OPEN = 1,
+ MMS_FILE_ACCESS_TYPE_OBTAIN = 2,
+ MMS_FILE_ACCESS_TYPE_DELETE = 3,
+ MMS_FILE_ACCESS_TYPE_RENAME = 4
+ }
+
///
/// The quality of a data object.
///
diff --git a/dotnet/IEC61850forCSharp/IEC61850ServerAPI.cs b/dotnet/IEC61850forCSharp/IEC61850ServerAPI.cs
index efff22ef..f7059787 100644
--- a/dotnet/IEC61850forCSharp/IEC61850ServerAPI.cs
+++ b/dotnet/IEC61850forCSharp/IEC61850ServerAPI.cs
@@ -659,6 +659,23 @@ namespace IEC61850
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
static extern void IedServer_setConnectionIndicationHandler(IntPtr self, InternalConnectionHandler handler, IntPtr parameter);
+ [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
+ static extern IntPtr IedServer_getMmsServer(IntPtr self);
+
+ public delegate MmsError FileAccessHandler(object parameter, ClientConnection clientConnection, MmsFileServiceType service, string localFilename, string otherFilename);
+
+ private FileAccessHandler mmsFileAccessHandler = null;
+ private object mmsFileAccessHandlerParameter = null;
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ private delegate int InternalMmsFileAccessHandler (IntPtr parameter, IntPtr connection, int service, [MarshalAs(UnmanagedType.LPStr)] string localFilename, [MarshalAs(UnmanagedType.LPStr)] string otherFilename);
+
+ [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
+ static extern void MmsServer_installFileAccessHandler(IntPtr self, InternalMmsFileAccessHandler handler, IntPtr parameter);
+
+ [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
+ static extern void MmsServer_setFilestoreBasepath(IntPtr self, [MarshalAs(UnmanagedType.LPStr)] string basepath);
+
private IntPtr self = IntPtr.Zero;
private InternalControlHandler internalControlHandlerRef = null;
@@ -787,6 +804,15 @@ namespace IEC61850
private Dictionary clientConnections = new Dictionary ();
+ int fileAccessHandler (IntPtr parameter, IntPtr connection, int service, string localFilename, string otherFilename)
+ {
+ ClientConnection con = null;
+
+ clientConnections.TryGetValue(connection, out con);
+
+ return (int) mmsFileAccessHandler (mmsFileAccessHandlerParameter, con, (MmsFileServiceType) service, localFilename, otherFilename);
+ }
+
public IedServer(IedModel iedModel, IedServerConfig config = null)
@@ -823,6 +849,7 @@ namespace IEC61850
//}
private InternalConnectionHandler internalConnectionHandler = null;
+ private InternalMmsFileAccessHandler internalMmsFileAccessHandler = null;
///
/// Sets the local ip address for listening
@@ -940,7 +967,20 @@ namespace IEC61850
IedServer_setWaitForExecutionHandler(self, controlObject.self, internalControlWaitForExecutionHandlerRef, GCHandle.ToIntPtr(info.handle));
}
-
+
+ public void SetFileAccessHandler (FileAccessHandler handler, object parameter)
+ {
+ mmsFileAccessHandler = handler;
+ mmsFileAccessHandlerParameter = parameter;
+
+ if (internalMmsFileAccessHandler == null)
+ internalMmsFileAccessHandler = new InternalMmsFileAccessHandler (fileAccessHandler);
+
+ IntPtr mmsServer = IedServer_getMmsServer(self);
+
+ MmsServer_installFileAccessHandler(mmsServer, internalMmsFileAccessHandler, IntPtr.Zero);
+ }
+
public void HandleWriteAccess (DataAttribute dataAttr, WriteAccessHandler handler, object parameter)
{
writeAccessHandlers.Add (dataAttr.self, new WriteAccessHandlerInfo(handler, parameter, dataAttr));
@@ -953,6 +993,13 @@ namespace IEC61850
{
IedServer_setWriteAccessPolicy (self, fc, policy);
}
+
+ public void SetFilestoreBasepath(string basepath)
+ {
+ IntPtr mmsServer = IedServer_getMmsServer(self);
+
+ MmsServer_setFilestoreBasepath(mmsServer, basepath);
+ }
public void LockDataModel()