Jun 8, 2012 at 1:35pm UTC
how do i add pass/fail counter based on below condition ?
if(_hsastat&&_spdlstat){
Synchronize(createMainAsmData);
_status=TMainFormB::DATA_OK;
_ErrMsg=" Data Transfer Comp "+_serial;
ShowMessage(" PASS ");
Synchronize(setStatus);
_Comp=true;
}
if meet condition , will add PASS counter 1 +++
if fail to meet condition will add FAIL counter 1 ++.. as goes on
Jun 8, 2012 at 4:09pm UTC
Initializations? What kind of project ? I'm guessing that _ErrMsg is a string ?
The counter depends on how u'r updating since u want it to stay in scope. A simplistic one is:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
int goodCounter = 0;
int badCounter = 0;
bool accessnext = TRUE;
bool result = FALSE;
while (accessnext != FALSE)
{
result = DoSomething();
if ( result == TRUE)
{
goodCounter += 1;
}
else
{
badCounter -= 1;
}
accessnext = RepeatTest();
}
Last edited on Jun 8, 2012 at 4:10pm UTC
Jun 9, 2012 at 11:11am UTC
hi thank u very much for the code. one more things;
i have a part with 3 component (3 bar codes) to be scanned : lets say A , B & C.
The program will trigger the scanner to scan A Serial no first, followed by B & C serial no simultaneously.
current Program will prompt error message if any of the 3 bar code cant be read or does not match with the database.
I have a problem here. if any 1 of the component is missing , the scanner will just keep on waiting and waiting to trigger.
how do i add time out after ~5secs if the scanner didnt detect any parts, prompt message " A SCANNER TIMEOUT " ??
------------------------------------------
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
bool okBaseSN = false ;
bool okSpindleSN = false ;
bool okHSASN = false ;
void TMainFormB::CheckBarcodeData(void )
{
if (_mainSn.Length() > 0)
{
eBaseSerial -> Text = _mainSn;
okBaseSN = true ;
}
if (_SpindleSn.Length() > 0)
{
eSpindleSerial -> Text = _SpindleSn;
okSpindleSN = true ;
if (_dchk)
_SpindleData=_SpindleSn;
else
{
ResetGreen();
_SpindleSn = "" ;
okSpindleSN = false ;
}
}
if (_HSASn.Length() > 0)
{
eHsaSerial -> Text = _HSASn;
okHSASN = true ;
if (_dchk)
_HsaData=_HSASn;
else
{
ResetGreen();
_HSASn = "" ;
okHSASN = false ;
}
}
if (okBaseSN) // && okSpindleSN && okHSASN)
{
ParseSerialData(_mainSn);
//ResetGreen();
_mainSn = "" ;
//_SpindleSn = "";
//_HSASn = "";
okBaseSN = false ;
okSpindleSN = false ;
okHSASN = false ;
}
//-------------------------
void TMainFormB::setBaseSerialStatus(int status,AnsiString data){
TColor bkclr,fntclr;
switch (status){
case TMainFormB::DATA_NG:
bkclr=clRed;
ShowMessage(" BASE SERIAL NOT FOUND " );
fntclr=clWhite;
break ;
case TMainFormB::DATA_OK:
bkclr=clLime;
fntclr=clBlack;
break ;
case TMainFormB::DATA_RESET:
bkclr=clWhite;
fntclr=clBlack;
eBaseSerial->Text="" ;
break ;
case TMainFormB::DATA_IDLE:
bkclr=clWhite;
fntclr=clBlack;
break ;
}
eBaseStatus->Color=bkclr;
eBaseStatus->Font->Color=fntclr;
eBaseSerial->Color=bkclr;
eBaseSerial->Font->Color=fntclr;
eBaseStatus->Text=data;
if (ErrorList){
ErrorList->logData(eBaseStatus->Text,TErrorList::HSA);
}
}
//-----
void __fastcall TMainFormB::setEditHsaClr(int status){
TColor bkclr,fntclr;
switch (status){
case TMainFormB::DATA_NG:
bkclr=clRed;
ShowMessage(" HSA DATA NOT FOUND " );
fntclr=clWhite;
break ;
case TMainFormB::DATA_OK:
bkclr=clLime;
fntclr=clBlack;
break ;
case TMainFormB::DATA_RESET:
bkclr=clWhite;
fntclr=clBlack;
eBaseSerial->Text="" ;
break ;
case TMainFormB::DATA_IDLE:
bkclr=clWhite;
fntclr=clBlack;
break ;
}
eHsaSerial->Color=bkclr;
eHsaSerial->Font->Color=fntclr;
}
void __fastcall TMainFormB::setEditSpdlClr(int status){
TColor bkclr,fntclr;
switch (status){
case TMainFormB::DATA_NG:
bkclr=clRed;
ShowMessage(" SPINDLE DATA NOT FOUND " );
fntclr=clWhite;
break ;
case TMainFormB::DATA_OK:
bkclr=clLime;
fntclr=clBlack;
break ;
case TMainFormB::DATA_RESET:
bkclr=clWhite;
fntclr=clBlack;
eBaseSerial->Text="" ;
break ;
case TMainFormB::DATA_IDLE:
bkclr=clWhite;
fntclr=clBlack;
break ;
}
eSpindleSerial->Color=bkclr;
eSpindleSerial->Font->Color=fntclr;
}
//------
Last edited on Jun 9, 2012 at 11:12am UTC
Jun 9, 2012 at 12:18pm UTC
__fastcall
Besides me not knowing what's this (I hope it's something like inline) you can create a Thread and Wait for its end within 5000ms (In Windows, _beginthreadex and WaitForSingleObject, include windows.h and process.h)
Jun 9, 2012 at 12:52pm UTC
hi Ess,
sorry, i dont get you. can you show a sample how to start ? thanks
Jun 9, 2012 at 3:19pm UTC
Last edited on Jun 9, 2012 at 3:19pm UTC