pull/162/head
Michael Zillgith 6 years ago
commit e09d46ffff

@ -173,6 +173,9 @@ namespace IEC61850
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
static extern ulong MmsValue_getBinaryTimeAsUtcMs (IntPtr self); static extern ulong MmsValue_getBinaryTimeAsUtcMs (IntPtr self);
[DllImport ("iec61850", CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr MmsValue_newUtcTimeByMsTime (UInt64 timestamp);
[DllImport("iec61850", CallingConvention=CallingConvention.Cdecl)] [DllImport("iec61850", CallingConvention=CallingConvention.Cdecl)]
static extern int MmsValue_getDataAccessError(IntPtr self); static extern int MmsValue_getDataAccessError(IntPtr self);
@ -389,6 +392,18 @@ namespace IEC61850
throw new MmsValueException ("Value is not a time type"); throw new MmsValueException ("Value is not a time type");
} }
/// <summary>
/// Create a new MmsValue instance of type MMS_UTC_TIME
/// </summary>
/// <returns>the new MmsValue instance.</returns>
/// <param name="timestamp">the time value as milliseconds since epoch (1.1.1970 UTC).</param>
public static MmsValue NewUtcTime (UInt64 timestamp)
{
IntPtr newValue = MmsValue_newUtcTimeByMsTime (timestamp);
return new MmsValue (newValue, true);
}
/// <summary> /// <summary>
/// Gets the type of the value /// Gets the type of the value
/// </summary> /// </summary>

@ -49,6 +49,15 @@ namespace tests
Assert.AreEqual(7, val.BitStringToUInt32()); Assert.AreEqual(7, val.BitStringToUInt32());
} }
[Test ()]
public void MmsValueUtcTime ()
{
var val = MmsValue.NewUtcTime (100000);
val.GetUtcTimeInMs ();
Assert.AreEqual (val.GetUtcTimeInMs (), 100000);
}
[Test()] [Test()]
public void MmsValueOctetString () public void MmsValueOctetString ()
{ {
@ -416,6 +425,7 @@ namespace tests
} }
[Test()] [Test()]
[Ignore()]
public void ControlHandler() public void ControlHandler()
{ {
IedModel iedModel = ConfigFileParser.CreateModelFromConfigFile ("../../model.cfg"); IedModel iedModel = ConfigFileParser.CreateModelFromConfigFile ("../../model.cfg");

@ -65,9 +65,13 @@ directChildStrLen(const char* childId)
MmsValue* MmsValue*
MmsVariableSpecification_getChildValue(MmsVariableSpecification* typeSpec, MmsValue* value, const char* childId) MmsVariableSpecification_getChildValue(MmsVariableSpecification* typeSpec, MmsValue* value, const char* childId)
{ {
if (typeSpec->type == MMS_STRUCTURE) { if ((typeSpec->type == MMS_STRUCTURE) && (value->type == MMS_STRUCTURE)) {
size_t childLen = directChildStrLen(childId); size_t childLen = directChildStrLen(childId);
int i; int i;
if (typeSpec->typeSpec.structure.elementCount != value->value.structure.size)
return NULL;
for (i = 0; i < typeSpec->typeSpec.structure.elementCount; i++) { for (i = 0; i < typeSpec->typeSpec.structure.elementCount; i++) {
if (strlen(typeSpec->typeSpec.structure.elements[i]->name) == childLen) { if (strlen(typeSpec->typeSpec.structure.elements[i]->name) == childLen) {

Loading…
Cancel
Save