Need to time stamp the last time a file was considered good.
I was trying to use something like: last_Time = DateTime.Now;. This is used inside a decision block. The problem even if the condition to enter the particular block isn't met, it still updates.
So does DateTime.Now execute no matter what?
Now for what I really need. I need to timestamp a infopacket/file/situation as to the last time it passed inspection. In other words when was the last good infopacket/file/situation.
The following code is what I thought would work:
public static DateTime last_Time;
public void Packet_Check(int decision)
{ /* checks for last good info packet. checks from lightest to most sever.
* if decision = 0, add 1 to pass_counter
* if decision = 1, pass_counter = 0, good packet and timestamps
*/
/*
int pass_marker = 0;// make global
int pass_counter = 0;// make global
int first_check = 0; // make global bool used if first pass made
pass_counter++;
if (decision == 1)
{
stateIndicatorComponent2.StateIndex = 4;
pass_counter = 0;
last_Time = DateTime.Now; // <<<<<<<< EXECUTES EVERY PASS, aargh!!!!!!!!!
TRUCK_ID_DISPLAY.BackColor = Color.White;
Performance_Log_File(this.Name, Convert.ToString(last_Time)+ " last good packet " + port_in );
}
else
if (pass_counter > 3) //change to yellow
stateIndicatorComponent2.StateIndex = 3;
//pass_counter++;
if (pass_counter > 7) // red
stateIndicatorComponent2.StateIndex = 2; //red
//Diag_Box.Text = " Last Entry -- " + last_Time + "\r\n " + File_Write_Hold;
if (pass_counter > 12) // red with warning message
//mess sent to operator
Diag_Box.Text = "lastime is " + last_Time;
//Diag_Box.Text = pass_counter + " " +this.Name + " has failed to recv good info/packetsince " + last_Time + " check all input!!!!";
if (light == true)
TRUCK_ID_DISPLAY.BackColor = Color.Red;
light = false;
stateIndicatorComponent2.StateIndex = 2;
TRUCK_ID_DISPLAY.BackColor = Color.Yellow;
light = true;
Thanks