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.
SOS, X2pro7 restart again and again
-
- Posts: 137
- Joined: Mon Jun 11, 2012 2:10 pm
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: Select all
try
{
...
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
Adam M.
Controls Engineer
FlexEnergy
Controls Engineer
FlexEnergy
-
- Posts: 7
- Joined: Sun May 27, 2018 9:11 pm
Re: SOS, X2pro7 restart again and again
Thanks you very much.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: Select all
try { ... } catch (Exception ex) { MessageBox.Show(ex.Message); }
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.