SOS, X2pro7 restart again and again
Posted: Thu Jun 14, 2018 1:58 am
Hi everybody, I've faced a little strange problem. Below script are fine in my testing x2pro7 and t7a. But my customer install in their x2pro7, it was auto restart again and again till com2 rs485 was unplugged.
void rs40_ValueChange(System.Object sender, Core.Api.DataSource.ValueChangedEventArgs e)
{
TimeSpan t = TimeSpan.FromSeconds((Globals.Tags.rs41.Value * 65565) + Globals.Tags.rs40.Value);
string buf = string.Format("{0}:{1:D2}:{2:D2}:{3:D2}", t.Days, t.Hours, t.Minutes, t.Seconds);
Globals.Tags.RunningETime.Value = buf;
TimeSpan t2 = TimeSpan.FromSeconds((Globals.Tags.rs3B.Value * 65565) + Globals.Tags.rs3A.Value);
TimeSpan t3 = TimeSpan.FromSeconds(Globals.Tags.rs3C.Value * 3600);
t3 = t3 - t2;
buf = string.Format("{0}:{1:D2}:{2:D2}:{3:D2}", t3.Days , t3.Hours, t3.Minutes, t3.Seconds);
Globals.Tags.GrantHourLeft.Value = buf;
try
{
TimeSpan diffDay = DateTime.Now - DateTime.Parse(Globals.Tags.StartGrant.Value);
Globals.Tags.GrantDayLeft.Value = Globals.Tags.GrantDay.Value - diffDay.Days;
}
catch(Exception ex) {}
if(Globals.Tags.rs39.Value == 1)
{
if(Globals.Tags.GrantDayLeft.Value <= Globals.Tags.RemindDay.Value)
{
Globals.Tags.AlertGrant.Value = 1;
}
else
{
Globals.Tags.AlertGrant.Value = 0;
}
}
else
{
Globals.Tags.AlertGrant.Value = 0;
}
if (Globals.Tags.GrantDayLeft.Value < 0)
{
int dd = t2.Days * 24;
int hh = t2.Hours + dd;
Globals.Tags.rs3C.Value = hh;
}
}
rs40 is uint16 counting secound.
void rs40_ValueChange(System.Object sender, Core.Api.DataSource.ValueChangedEventArgs e)
{
TimeSpan t = TimeSpan.FromSeconds((Globals.Tags.rs41.Value * 65565) + Globals.Tags.rs40.Value);
string buf = string.Format("{0}:{1:D2}:{2:D2}:{3:D2}", t.Days, t.Hours, t.Minutes, t.Seconds);
Globals.Tags.RunningETime.Value = buf;
TimeSpan t2 = TimeSpan.FromSeconds((Globals.Tags.rs3B.Value * 65565) + Globals.Tags.rs3A.Value);
TimeSpan t3 = TimeSpan.FromSeconds(Globals.Tags.rs3C.Value * 3600);
t3 = t3 - t2;
buf = string.Format("{0}:{1:D2}:{2:D2}:{3:D2}", t3.Days , t3.Hours, t3.Minutes, t3.Seconds);
Globals.Tags.GrantHourLeft.Value = buf;
try
{
TimeSpan diffDay = DateTime.Now - DateTime.Parse(Globals.Tags.StartGrant.Value);
Globals.Tags.GrantDayLeft.Value = Globals.Tags.GrantDay.Value - diffDay.Days;
}
catch(Exception ex) {}
if(Globals.Tags.rs39.Value == 1)
{
if(Globals.Tags.GrantDayLeft.Value <= Globals.Tags.RemindDay.Value)
{
Globals.Tags.AlertGrant.Value = 1;
}
else
{
Globals.Tags.AlertGrant.Value = 0;
}
}
else
{
Globals.Tags.AlertGrant.Value = 0;
}
if (Globals.Tags.GrantDayLeft.Value < 0)
{
int dd = t2.Days * 24;
int hh = t2.Hours + dd;
Globals.Tags.rs3C.Value = hh;
}
}
rs40 is uint16 counting secound.