void printStatusMsg () { char szStatusMsg[256]; if (NULL != get_master()) { getStatusMsg (get_master()->StatusAdmin, szStatusMsg); kuDebug (kuMON, "[Master] %s\n", szStatusMsg); } ST_STD_device *pSTDdev = get_first_STDdev(); while (pSTDdev) { getStatusMsg (pSTDdev->StatusDev, szStatusMsg); kuDebug (kuMON, "[Device] name(%s) : %s\n", pSTDdev->taskName, szStatusMsg); pSTDdev = (ST_STD_device*) ellNext(&pSTDdev->node); } }
//! @brief Comprueba si se ha producido la convergencia. int XC::CTestRelativeNormUnbalance::test(void) { // check to ensure the SOE has been set - this should not happen if the // return from start() is checked if(!hasLinearSOE()) return -2; // check to ensure the algo does invoke start() - this is needed otherwise // may never get convergence later on in analysis! if(currentIter == 0) { std::cerr << getClassName() << "::" << __FUNCTION__ << "; WARNING: start() was never invoked.\n"; return -2; } // get the B vector & determine it's norm & save the value in norms vector calculatedNormX= getNormX(); calculatedNormB = getNormB(); lastRatio= calculatedNormB; if(currentIter <= maxNumIter) norms(currentIter)= calculatedNormB; // determine the ratio if(norm0 != 0.0) lastRatio/= norm0; // print the data if required if(printFlag) std::clog << getStatusMsg(printFlag); // // check if the algorithm converged // // if converged - print & return ok if(lastRatio <= tol) { // the algorithm converged // do some printing first if(printFlag != 0) { if(printFlag == 1 || printFlag == 4) std::cerr << std::endl; else if(printFlag == 2 || printFlag == 6) { std::cerr << getTestIterationMessage(); std::cerr << getRatioMessage("(|dR|/|dR0|)"); } } // return the number of times test has been called return currentIter; } // algo failed to converged after specified number of iterations - but RETURN OK else if((printFlag == 5 || printFlag == 6) && currentIter >= maxNumIter) { std::cerr << getClassName() << "::" << __FUNCTION__ << "; WARNING: failed to converge but going on -" << getRatioMessage("(dR/dR0)"); return currentIter; } // algo failed to converged after specified number of iterations - return FAILURE -2 else if(currentIter >= maxNumIter) { // the algorithm failed to converge std::cerr << getFailedToConvergeMessage(); currentIter++; // we increment in case analysis does not check for convergence return -2; } // algorithm not yet converged - increment counter and return -1 else { currentIter++; return -1; } }
uchar receiveByte(void) { static Rcv_State state = need0x7E; uchar readByte=0; static uchar dummy; static uchar ct=0; static uchar sum=0; static uchar length=0; char status=0; if(SCI1SR1 & _S12_RDRF) //we have data coming in { dummy = SCI1SR1; //clear flag - unsure if this is necessary readByte = SCI1DRL; //read that data } else { goodMsg=0; return 0; //default byte } switch(state) //got a byte { case need0x7E: if(readByte==0x7E) //only way to advance is to get 0x7E { state=needMSBLen; // printf("0x7E\r\n"); } break; case needMSBLen: if(readByte==0) //we need a zero MSB Length or its bogus { state=needLSBLen; // printf("to LSB\r\n"); } else { state=need0x7E; //got a bogus MSB, back to beginning // printf("Error:MSB is %x\r\n",(int) readByte); } break; case needLSBLen: if(readByte>MAX_MSG_LENGTH) { state=need0x7E; printf("bogus message length\r\n"); } else //good size message { // printf("to readMsg\r\n"); ct=0; sum=0; length=readByte; state=readingMessage; // printf("LSB: %x\r\n", (int)readByte); // printf("ln: %x\r\n",(int) length); } break; case readingMessage: if(ct!=length) { buffer[ct]=readByte; sum+=readByte; ct++; } else //ct = length so this is the chksum { //printf("OOOO %x\r\n",readByte); sum+=readByte; if(sum==0xFF) { goodMsg=1; //printf("good\r\n"); } else { goodMsg=0; printf("bad\r\n"); } state=need0x7E; status = getStatusMsg(); if(status>0) return status; //printBuffer(ct); } break; } printf("rd: %x\r\n",readByte); return 0; }