byte[] IGXDLMSBase.Invoke(GXDLMSSettings settings, ValueEventArgs e)
{
DateTimeOffset tm = this.Time.Value;
// Resets the value to the default value.
// The default value is an instance specific constant.
if (e.Index == 1)
{
int minutes = tm.Minute;
if (minutes < 8)
{
minutes = 0;
}
else if (minutes < 23)
{
minutes = 15;
}
else if (minutes < 38)
{
minutes = 30;
}
else if (minutes < 53)
{
minutes = 45;
}
else
{
minutes = 0;
tm = tm.AddHours(1);
}
tm = tm.AddMinutes(-tm.Minute + minutes);
tm = tm.AddSeconds(-tm.Second);
tm = tm.AddMilliseconds(-tm.Millisecond);
this.Time.Value = tm;
}
// Sets the meter's time to the nearest minute.
else if (e.Index == 3)
{
tm = this.Time.Value;
int s = tm.Second;
if (s > 30)
{
tm = tm.AddMinutes(1);
}
tm = tm.AddSeconds(-tm.Second);
tm = tm.AddMilliseconds(-tm.Millisecond);
this.Time.Value = tm;
}
// Presets the time to a new value (preset_time) and defines
// avalidity_interval within which the new time can be activated.
else if (e.Index == 5)
{
GXDateTime presetTime = (GXDateTime)GXDLMSClient.ChangeType((byte[])((Object[])e.Parameters)[0], DataType.DateTime);
GXDateTime validityIntervalStart = (GXDateTime)GXDLMSClient.ChangeType((byte[])((Object[])e.Parameters)[1], DataType.DateTime);
GXDateTime validityIntervalEnd = (GXDateTime)GXDLMSClient.ChangeType((byte[])((Object[])e.Parameters)[2], DataType.DateTime);
this.Time.Value = presetTime.Value;
}
// Shifts the time.
else if (e.Index == 6)
{
int shift = Convert.ToInt32(e.Parameters);
tm = tm.AddSeconds(shift);
this.Time.Value = tm;
}
else
{
e.Error = ErrorCode.ReadWriteDenied;
}
return null;
}