iX Talk
http://beijerinc.com/support/ix/forum/

SOS, X2pro7 restart again and again
http://beijerinc.com/support/ix/forum/viewtopic.php?f=6&t=2295
Page 1 of 1

Author:  artistmonkey [ Thu Jun 14, 2018 1:58 am ]
Post subject:  SOS, X2pro7 restart again and again

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.

Author:  AMitchneck [ Thu Jun 14, 2018 8:23 am ]
Post subject:  Re: SOS, X2pro7 restart again and again

Rebooting usually means the program is crashing. In this case, what I usually do is place a try {} catch {} around the code and spit the exception to a message box. That way you can get some indication as to what is causing the crash. As the issue gets more complex, I might use multiple catches with an added marker to the message so I know where it was caught.

Code:
try
{
   ...
}
catch (Exception ex)
{
   MessageBox.Show(ex.Message);
}

Author:  artistmonkey [ Thu Jun 14, 2018 7:15 pm ]
Post subject:  Re: SOS, X2pro7 restart again and again

AMitchneck wrote:
Rebooting usually means the program is crashing. In this case, what I usually do is place a try {} catch {} around the code and spit the exception to a message box. That way you can get some indication as to what is causing the crash. As the issue gets more complex, I might use multiple catches with an added marker to the message so I know where it was caught.

Code:
try
{
   ...
}
catch (Exception ex)
{
   MessageBox.Show(ex.Message);
}


Thanks you very much.
I've tried your suggestion and found that Globals.Tags.StartGrant cause the problem. Now, I know how to handle this problem.
Again Thanks for your suggestion.

Page 1 of 1 All times are UTC - 7 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/