Welcome Guest ( Login | Register )



All times are UTC - 7 hours [ DST ]



Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: SOS, X2pro7 restart again and again
PostPosted: Thu Jun 14, 2018 1:58 am 

Joined: Sun May 27, 2018 9:11 pm
Posts: 5

Offline
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.


 Profile  
 
 Post subject: Re: SOS, X2pro7 restart again and again
PostPosted: Thu Jun 14, 2018 8:23 am 

Joined: Mon Jun 11, 2012 2:10 pm
Posts: 118

Offline
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);
}

_________________
Adam M.
Controls Engineer
FlexEnergy


 Profile  
 
 Post subject: Re: SOS, X2pro7 restart again and again
PostPosted: Thu Jun 14, 2018 7:15 pm 

Joined: Sun May 27, 2018 9:11 pm
Posts: 5

Offline
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.


 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 7 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: