@ -431,6 +431,10 @@ namespace IEC61850
}
}
/// <summary>
/// Gets the connection parameters
/// </summary>
/// <returns>The connection parameters</returns>
public IsoConnectionParameters GetConnectionParameters ( )
{
IntPtr mmsConnection = IedConnection_getMmsConnection ( connection ) ;
@ -448,6 +452,10 @@ namespace IEC61850
private UInt32 connectTimeout = 10000 ;
/// <summary>
/// Gets or sets the timeout used for connection attempts.
/// </summary>
/// <value>The connect timeout in milliseconds</value>
public UInt32 ConnectTimeout {
get {
return connectTimeout ;
@ -494,6 +502,14 @@ namespace IEC61850
return controlObject ;
}
/// <summary>
/// Updates the device model by quering the server.
/// </summary>
public void UpdateDeviceModel ( )
{
int error ;
@ -504,6 +520,12 @@ namespace IEC61850
throw new IedConnectionException ( "UpdateDeviceModel failed" , error ) ;
}
/// <summary>
/// Gets the server directory (Logical devices or file objects)
/// </summary>
/// <returns>List of logical devices or files</returns>
/// <param name="fileDirectory">If set to <c>true</c> the file directory is returned, otherwise the LD names</param>
/// <exception cref="IedConnectionException">This exception is thrown if there is a connection or service error</exception>
public List < string > GetServerDirectory ( bool fileDirectory = false )
{
@ -731,6 +753,7 @@ namespace IEC61850
/// <param name="entryID">EntryID of the last received MmsJournalEntry</param>
/// <param name="timestamp">Timestamp of the last received MmsJournalEntry</param>
/// <param name="moreFollows">Indicates that more log entries are available</param>
/// <exception cref="IedConnectionException">This exception is thrown if there is a connection or service error</exception>
public List < MmsJournalEntry > QueryLogAfter ( string logRef , byte [ ] entryID , ulong timestamp , out bool moreFollows )
{
int error ;
@ -756,6 +779,7 @@ namespace IEC61850
/// <param name="startTime">Start time of the time range</param>
/// <param name="stopTime">End time of the time range</param>
/// <param name="moreFollows">Indicates that more log entries are available</param>
/// <exception cref="IedConnectionException">This exception is thrown if there is a connection or service error</exception>
public List < MmsJournalEntry > QueryLogByTime ( string logRef , ulong startTime , ulong stopTime , out bool moreFollows )
{
int error ;
@ -772,24 +796,6 @@ namespace IEC61850
}
private static DateTime DateTimeFromMsTimestamp ( ulong msTime )
{
DateTime dateTime = new DateTime ( 1970 , 1 , 1 , 0 , 0 , 0 , 0 , DateTimeKind . Utc ) ;
ulong seconds = msTime / 1000 ;
ulong millies = msTime % 1000 ;
dateTime . AddSeconds ( ( double ) seconds ) ;
dateTime . AddMilliseconds ( ( double ) millies ) ;
return dateTime ;
}
private static ulong DateTimeToMsTimestamp ( DateTime dateTime )
{
return ( ulong ) ( dateTime . ToUniversalTime ( ) . Subtract ( new DateTime ( 1970 , 1 , 1 , 0 , 0 , 0 , DateTimeKind . Utc ) ) . TotalMilliseconds ) ;
}
/// <summary>
/// Queries all log entries of the given time range
/// </summary>
@ -798,10 +804,11 @@ namespace IEC61850
/// <param name="startTime">Start time of the time range</param>
/// <param name="stopTime">End time of the time range</param>
/// <param name="moreFollows">Indicates that more log entries are available</param>
/// <exception cref="IedConnectionException">This exception is thrown if there is a connection or service error</exception>
public List < MmsJournalEntry > QueryLogByTime ( string logRef , DateTime startTime , DateTime stopTime , out bool moreFollows )
{
ulong startTimeMs = DateTimeToMsTimestamp ( startTime ) ;
ulong stopTimeMs = DateTimeToMsTimestamp ( stopTime ) ;
ulong startTimeMs = LibIEC61850. DateTimeToMsTimestamp ( startTime ) ;
ulong stopTimeMs = LibIEC61850. DateTimeToMsTimestamp ( stopTime ) ;
return QueryLogByTime ( logRef , startTimeMs , stopTimeMs , out moreFollows ) ;
}
@ -1445,233 +1452,4 @@ namespace IEC61850
IED_ERROR_UNKNOWN = 99
}
}
namespace Common
{
[Flags]
public enum TriggerOptions {
NONE = 0 ,
/** send report when value of data changed */
DATA_CHANGED = 1 ,
/** send report when quality of data changed */
QUALITY_CHANGED = 2 ,
/** send report when data or quality is updated */
DATA_UPDATE = 4 ,
/** periodic transmission of all data set values */
INTEGRITY = 8 ,
/** general interrogation (on client request) */
GI = 16
}
[Flags]
public enum ReportOptions {
NONE = 0 ,
SEQ_NUM = 1 ,
TIME_STAMP = 2 ,
REASON_FOR_INCLUSION = 4 ,
DATA_SET = 8 ,
DATA_REFERENCE = 16 ,
BUFFER_OVERFLOW = 32 ,
ENTRY_ID = 64 ,
CONF_REV = 128 ,
ALL = 255
}
public enum Validity
{
GOOD = 0 ,
RESERVED = 1 ,
INVALID = 2 ,
QUESTIONABLE = 3
}
/// <summary>
/// The quality of a data object.
/// </summary>
public class Quality
{
private UInt16 value ;
public Quality ( int bitStringValue )
{
value = ( UInt16 ) bitStringValue ;
}
public Quality ( )
{
value = 0 ;
}
public Validity GetValidity ( )
{
int qualityVal = value & 0x3 ;
return ( Validity ) qualityVal ;
}
public void SetValidity ( Validity validity )
{
value = ( UInt16 ) ( value & 0xfffc ) ;
value + = ( ushort ) validity ;
}
}
public enum ACSIClass
{
/** data objects */
ACSI_CLASS_DATA_OBJECT ,
/** data sets (container for multiple data objects) */
ACSI_CLASS_DATA_SET ,
/** buffered report control blocks */
ACSI_CLASS_BRCB ,
/** unbuffered report control blocks */
ACSI_CLASS_URCB ,
/** log control blocks */
ACSI_CLASS_LCB ,
/** logs (journals) */
ACSI_CLASS_LOG ,
/** setting group control blocks */
ACSI_CLASS_SGCB ,
/** GOOSE control blocks */
ACSI_CLASS_GoCB ,
/** GSE control blocks */
ACSI_CLASS_GsCB ,
/** multicast sampled values control blocks */
ACSI_CLASS_MSVCB ,
/** unicast sampled values control blocks */
ACSI_CLASS_USVCB
}
public enum FunctionalConstraint
{
/** Status information */
ST = 0 ,
/** Measurands - analog values */
MX = 1 ,
/** Setpoint */
SP = 2 ,
/** Substitution */
SV = 3 ,
/** Configuration */
CF = 4 ,
/** Description */
DC = 5 ,
/** Setting group */
SG = 6 ,
/** Setting group editable */
SE = 7 ,
/** Service response / Service tracking */
SR = 8 ,
/** Operate received */
OR = 9 ,
/** Blocking */
BL = 10 ,
/** Extended definition */
EX = 11 ,
/** Control */
CO = 12 ,
/** Unicast SV */
US = 13 ,
/** Multicast SV */
MS = 14 ,
/** Unbuffered report */
RP = 15 ,
/** Buffered report */
BR = 16 ,
/** Log control blocks */
LG = 17 ,
/** All FCs - wildcard value */
ALL = 99 ,
NONE = - 1
}
public enum ControlAddCause {
ADD_CAUSE_UNKNOWN = 0 ,
ADD_CAUSE_NOT_SUPPORTED = 1 ,
ADD_CAUSE_BLOCKED_BY_SWITCHING_HIERARCHY = 2 ,
ADD_CAUSE_SELECT_FAILED = 3 ,
ADD_CAUSE_INVALID_POSITION = 4 ,
ADD_CAUSE_POSITION_REACHED = 5 ,
ADD_CAUSE_PARAMETER_CHANGE_IN_EXECUTION = 6 ,
ADD_CAUSE_STEP_LIMIT = 7 ,
ADD_CAUSE_BLOCKED_BY_MODE = 8 ,
ADD_CAUSE_BLOCKED_BY_PROCESS = 9 ,
ADD_CAUSE_BLOCKED_BY_INTERLOCKING = 10 ,
ADD_CAUSE_BLOCKED_BY_SYNCHROCHECK = 11 ,
ADD_CAUSE_COMMAND_ALREADY_IN_EXECUTION = 12 ,
ADD_CAUSE_BLOCKED_BY_HEALTH = 13 ,
ADD_CAUSE_1_OF_N_CONTROL = 14 ,
ADD_CAUSE_ABORTION_BY_CANCEL = 15 ,
ADD_CAUSE_TIME_LIMIT_OVER = 16 ,
ADD_CAUSE_ABORTION_BY_TRIP = 17 ,
ADD_CAUSE_OBJECT_NOT_SELECTED = 18 ,
ADD_CAUSE_OBJECT_ALREADY_SELECTED = 19 ,
ADD_CAUSE_NO_ACCESS_AUTHORITY = 20 ,
ADD_CAUSE_ENDED_WITH_OVERSHOOT = 21 ,
ADD_CAUSE_ABORTION_DUE_TO_DEVIATION = 22 ,
ADD_CAUSE_ABORTION_BY_COMMUNICATION_LOSS = 23 ,
ADD_CAUSE_ABORTION_BY_COMMAND = 24 ,
ADD_CAUSE_NONE = 25 ,
ADD_CAUSE_INCONSISTENT_PARAMETERS = 26 ,
ADD_CAUSE_LOCKED_BY_OTHER_CLIENT = 27
}
/// <summary>
/// Object reference. Helper function to handle object reference strings.
/// </summary>
public static class ObjectReference {
/// <summary>
/// Get the name part of an object reference with appended FC
/// </summary>
/// <returns>
/// The element name.
/// </returns>
/// <param name='objectReferenceWithFc'>
/// Object reference with appended fc.
/// </param>
public static string getElementName ( string objectReferenceWithFc )
{
int fcPartStartIndex = objectReferenceWithFc . IndexOf ( '[' ) ;
if ( fcPartStartIndex = = - 1 )
return objectReferenceWithFc ;
return objectReferenceWithFc . Substring ( 0 , fcPartStartIndex ) ;
}
/// <summary>
/// Get the FC of an object reference with appended FC.
/// </summary>
/// <returns>
/// The FC
/// </returns>
/// <param name='objectReferenceWithFc'>
/// Object reference with FC.
/// </param>
public static FunctionalConstraint getFC ( string objectReferenceWithFc )
{
int fcPartStartIndex = objectReferenceWithFc . IndexOf ( '[' ) ;
if ( fcPartStartIndex = = - 1 )
return FunctionalConstraint . NONE ;
string fcString = objectReferenceWithFc . Substring ( fcPartStartIndex + 1 , 2 ) ;
try
{
return ( FunctionalConstraint ) Enum . Parse ( typeof ( FunctionalConstraint ) , fcString ) ;
}
catch ( ArgumentException )
{
return FunctionalConstraint . NONE ;
}
}
}
}
}