set 3 last byte of clock

2 posts / 0 new
Last post
ali_bahal
set 3 last byte of clock

Hi, I want to set three last byte of meter clock as 00 80 00 , so that deviation and time zone does not apply when I read meter clock.
I use this code :
var tzi= TimeZoneInfo.FindSystemTimeZoneById(TimeZoneInfo.Local.Id);
var dtNow = DateTime.UtcNow.AddMinutes(tzi.BaseUtcOffset.TotalMinutes);
var clock = new GXDLMSClock("0.0.1.0.0.255")
{
Time = new GXDateTime(dtNow) {Skip = DateTimeSkips.Deviation ,Status = ClockStatus.DaylightSavingActive},
Status = ClockStatus.DaylightSavingActive | ClockStatus.Skip,
Deviation = 60,
TimeZone =0,// (int)tzi.BaseUtcOffset.TotalMinutes*(-1),
Enabled = false
};
clock.UpdateDirty(2,clock.Time);
clock.UpdateDirty(3, clock.TimeZone);
//clock.UpdateDirty(4, clock.Status);
clock.UpdateDirty(7, clock.Deviation);
clock.UpdateDirty(8, clock.Enabled);
WriteDevice(_device, clock, 0);

but I can't achieve what I want. do you have any Idea ?

Kurumi
Kurumi's picture

Hi,

You can use Skip value, but it's reset every time when you read the value from the meter.
In your example you are setting skip value before writing the value and deviation is ignored. If you want that last byte is zero you need to set it like this:
Skip = DateTimeSkips.Deviation;
Status = ClockStatus.None;

BR,
Mikko

________________________________________
Mikko Kurunsaari
Gurux Ltd
http://www.gurux.fi