bool CARCONTROLMAP_LOCAL::CONTROL::operator==(const CONTROL & other) const { CONTROL me = *this; CONTROL them = other; //don't care about certain flags me.onetime = 1; me.pushdown = 1; me.deadzone = 0; me.exponent = 1; me.gain = 1; them.onetime = 1; them.pushdown = 1; them.deadzone = 0; them.exponent = 1; them.gain = 1; std::stringstream mestr; std::stringstream themstr; me.DebugPrint(mestr); them.DebugPrint(themstr); return (mestr.str() == themstr.str()); /*std::cout << "Checking:" << std::endl; me.DebugPrint(std::cout); me.MemDump(std::cout); them.DebugPrint(std::cout); them.MemDump(std::cout); std::cout << "Equality check: " << (std::memcmp(&me,&them,sizeof(CONTROL)) == 0) << std::endl; return (std::memcmp(&me,&them,sizeof(CONTROL)) == 0);*/ //bool equality = (type == other.type) && (type == other.type) && }
VOID Handler(CONTROL_EVENT ev, VOID * v, CONTEXT * ctxt, VOID * ip, THREADID tid) { std::cerr << "tid: " << dec << tid << " ip: 0x" << hex << ip; // get line info on current instruction INT32 linenum = 0; string filename; PIN_LockClient(); PIN_GetSourceLocation((ADDRINT)ip, NULL, &linenum, &filename); PIN_UnlockClient(); if(filename != "") { std::cerr << " ( " << filename << ":" << dec << linenum << " )"; } std::cerr << dec << " Inst. Count " << icount.Count(tid) << " "; #if defined(TARGET_IA32) || defined(TARGET_IA32E) std::cerr << " [ with REP iterations " << icount.CountWithREP() << "] "; #endif switch(ev) { case CONTROL_START: std::cerr << "Start" << endl; if(control.PinPointsActive()) { std::cerr << "PinPoint: " << control.CurrentPp(tid) << " PhaseNo: " << control.CurrentPhase(tid) << endl; } break; case CONTROL_STOP: std::cerr << "Stop" << endl; if(control.PinPointsActive()) { std::cerr << "PinPoint: " << control.CurrentPp(tid) << endl; } break; default: ASSERTX(false); break; } }
int main(int argc, char **argv) { if (PIN_Init(argc, argv)) return 1; PIN_AddThreadStartFunction(OnNewThread, 0); Control.CheckKnobs(Handler, 0); PIN_StartProgram(); }
// argc, argv are the entire command line, including pin -t <toolname> -- ... int main(int argc, char * argv[]) { if( PIN_Init(argc,argv) ) { return Usage(); } PIN_InitLock(&output_lock); icount.Activate(); // Activate alarm, must be done before PIN_StartProgram control.RegisterHandler(Handler, 0, FALSE); control.Activate(); // Start the program, never returns PIN_StartProgram(); return 0; }
LOCALFUN VOID Fini(int n, void *v) { *outfile << endl; double whole_MPKI = 1000.0 * (double)bimodal.Mispredicts()/icount.Count(); *outfile << "Whole-program MPKI = " << whole_MPKI << dec << endl; if (control.PinPointsActive()) { UINT32 NumPp = control.NumPp(); double predicted_MPKI = 0.0; *outfile << "PP #," << " %Weight," << " MPKI" << endl; for (UINT32 p = 1; p <= NumPp ; p++) { double weight = (double) ppinfo.ppstats[p].ppWeightTimesThousand/1000.0; double mpki = (double)ppinfo.ppstats[p].ppMispredicts*1000/ppinfo.ppstats[p].ppInstructions; *outfile << dec << p << ", " << weight << ", " << mpki << endl; predicted_MPKI += (double) weight*mpki/100.0; } *outfile << "Predicted MPKI = " << predicted_MPKI << dec << endl; } }
bool CARCONTROLMAP_LOCAL::CONTROL::operator<(const CONTROL & other) const { CONTROL me = *this; CONTROL them = other; me.onetime = 1; me.pushdown = 1; me.deadzone = 0; me.exponent = 1; me.gain = 1; them.onetime = 1; them.pushdown = 1; them.deadzone = 0; them.exponent = 1; them.gain = 1; std::stringstream mestr; std::stringstream themstr; me.DebugPrint(mestr); them.DebugPrint(themstr); return (mestr.str() < themstr.str()); }
// argc, argv are the entire command line, including pin -t <toolname> -- ... int main(int argc, char * argv[]) { if( PIN_Init(argc,argv) ) { return Usage(); } icount.Activate(); // Activate alarm, must be done before PIN_StartProgram control.CheckKnobs(Handler, 0); // Start the program, never returns PIN_StartProgram(); return 0; }
void CreateBody() { //convert array to vectors TransArrToVec(); //create an interface to control body and legs CONTROL obj; //set right leg position relative to body obj.set_iniTrans_R_leg(-0.5,-3,0); obj.set_iniTrans_L_leg(0.5,-3,0); //set leg move speed obj.setlegSpeed(3.0); //compute matrix obj.iniProcess(Power_T, B_splines,vec_PosInfo); //get body's matrix Mat_body = obj.getBodyMatrix(); //get right leg's matrix Mat_R_Leg = obj.getRLegMatrix(); //get left leg's matrix Mat_L_Leg = obj.getLLegMatrix(); }
int main(int argc, char *argv[]) { if( PIN_Init(argc,argv) ) { return Usage(); } icount.Activate(); bimodal.Activate(); // Activate alarm, must be done before PIN_StartProgram control.CheckKnobs(Handler, 0); outfile = new ofstream("bimodal.out"); PIN_AddFiniFunction(Fini, 0); PIN_StartProgram(); }
int main(int argc, char * argv[]) { if( PIN_Init(argc,argv) ) { return Usage(); } icount.Activate(); // Activate alarm, must be done before PIN_StartProgram control.CheckKnobs(Handler, 0); // Callback function "byeWorld" is invoked // right before Pin releases control of the application // to allow it to return to normal execution PIN_AddDetachFunction(helloWorld, 0); PIN_AddDetachFunction(byeWorld, 0); // Never returns PIN_StartProgram(); return 0; }
VOID Handler(CONTROL_EVENT ev, VOID * v, CONTEXT * ctxt, VOID * ip, THREADID tid) { std::cout << "ip: " << ip << " Instructions: " << icount.Count() << " "; switch(ev) { case CONTROL_START: std::cout << "Start" << endl; ppinfo.startMispredicts = bimodal.Mispredicts(); ppinfo.startIcount = icount.Count(); if(control.PinPointsActive()) { std::cout << "PinPoint: " << control.CurrentPp() << endl; UINT32 pp = control.CurrentPp(); ASSERTX( pp <= MAXPP); ppinfo.ppstats[pp].ppWeightTimesThousand = control.CurrentPpWeightTimesThousand(); ppinfo.currentpp = pp; } break; case CONTROL_STOP: std::cout << "Stop" << endl; if(control.PinPointsActive()) { std::cout << "PinPoint: " << control.CurrentPp() << endl; UINT64 mispredicts = bimodal.Mispredicts() - ppinfo.startMispredicts; UINT64 instructions = icount.Count() - ppinfo.startIcount; UINT32 pp = ppinfo.currentpp; ppinfo.ppstats[pp].ppMispredicts = mispredicts; ppinfo.ppstats[pp].ppInstructions = instructions; } break; default: ASSERTX(false); break; } }
STATUS runPreset() { UINT64 endTick = 0; UINT64 eStartTick = 0; if(GV::isStopAll) { DISPLAY_FAULT("系统已清除状态,停止接收启动指令,启动失败!"); file.writeLogFile("系统已清除状态,停止接收启动指令!"); return ERROR; } for(UINT nodeNum = 0;nodeNum < AXIS_NUM;nodeNum++){ if(!GV::isPowerOutput[nodeNum] || !GV::isZeroPosSet[nodeNum] || (GV::opMode[nodeNum] != 0x1) || GV::isBoltOn[nodeNum] || GV::isLimit[nodeNum]){ printf("%d %d %d %x\n",GV::isPowerOutput[nodeNum],GV::isZeroPosSet[nodeNum],GV::isBoltOn[nodeNum],GV::opMode[nodeNum]); DISPLAY_FAULT("启动失败,请检查驱动器是否上电,转台是否处在插销和限位状态!"); return ERROR;}} CAN_PACKET sendPack,recvPack; stringstream ss; memset(&sendPack,0,CP_SIZE); memset(&recvPack,0,CP_SIZE); UCHAR buf[WCTLMSG_SIZE]; memset(buf, 0, WCTLMSG_SIZE); memcpy(buf, &GV::ctrlParamMsg, WCTLMSG_SIZE); int validBit = 0; for(validBit = 0;validBit < 5;validBit++){ if(buf[2 + validBit] ^ 0xff){ break;}} if(buf[2 + validBit] == 0xa0){ control.findZeroPos(); return OK;} else{ ss << buf[2 + validBit] - 0xa0; for(int seg = 0; seg < file.jsonDoc[ss.str().c_str()]["seg"].GetInt(); seg++) { if(OK != semTake(GV::isCANOccupy,SEM_TIME_OUT*SYS_FREQ)) { DISPLAY_FAULT("启动操作:获取CAN总线资源失败!"); file.writeLogFile("启动操作:获取CAN锁信号量超时!"); return ERROR; } can.writeCopleyCMD(sendPack, DRIVER_CMD_POS_SET, file.jsonDoc[ss.str().c_str()]["angle"][seg].GetDouble(), validBit + 1); if(ERROR == can.uCMDSend(sendPack,recvPack,USING_CAN_CHANNEL)){ semGive(GV::isCANOccupy); return ERROR;} can.writeCopleyCMD(sendPack, DRIVER_CMD_VEL_SET, fabs(file.jsonDoc[ss.str().c_str()]["angle"][seg].GetDouble() / file.jsonDoc[ss.str().c_str()]["time"][seg].GetDouble()) * 1.2, validBit + 1); if(ERROR == can.uCMDSend(sendPack,recvPack,USING_CAN_CHANNEL)){ semGive(GV::isCANOccupy); return ERROR;} can.writeCopleyCMD(sendPack, DRIVER_CMD_ACC_SET, MAX_ACC[validBit], validBit + 1); if(ERROR == can.uCMDSend(sendPack,recvPack,USING_CAN_CHANNEL)){ semGive(GV::isCANOccupy); return ERROR;} can.writeCopleyCMD(sendPack, DRIVER_CMD_DEACC_SET, MAX_ACC[validBit], validBit + 1); if(ERROR == can.uCMDSend(sendPack,recvPack,USING_CAN_CHANNEL)){ semGive(GV::isCANOccupy); return ERROR;} can.writeCopleyCMD(sendPack, DRIVER_CLEAR_MOVE, 0, validBit + 1); if(ERROR == can.uCMDSend(sendPack,recvPack,USING_CAN_CHANNEL)){ semGive(GV::isCANOccupy); return ERROR;} can.writeCopleyCMD(sendPack, DRIVER_REL_START, 0, validBit + 1); if(ERROR == can.uCMDSend(sendPack,recvPack,USING_CAN_CHANNEL)){ semGive(GV::isCANOccupy); return ERROR;} semGive(GV::isCANOccupy); endTick = tick64Get(); taskDelay(static_cast<int>((file.jsonDoc[ss.str().c_str()]["time"][seg].GetDouble() * SYS_FREQ)) - (seg == 0 ? 0 : (endTick - eStartTick))); eStartTick = tick64Get(); }} return OK; }