void Display_Controll() { switch(GlobalStruct.OS_Status) { case 0: SetTask(ScreenSaver_Display); SetTimerTask(Display_Controll, 1000); break; case 1: SetTask(Main_Display_Print); SetTimerTask(Display_Controll, 250); } }
/*------------------------------------------------------*/ void CheckScreen(void) { int i,j; char r[128]; j=0; for(i=0;i<80;++i) j = Crc(j,LcdBuffer[i]); for(i=0;i<32;++i) j = Crc(j,LcdExt[i]); j = Crc(j,GetLCDaddr()); if(CheckScr != j) { CheckScr = j; sprintf(r,"=s %d,%d,%c\r\n",(int)LcdBuffer[80]%20,(int)LcdBuffer[80]/20,(int)LcdBuffer[81]); puts_pc(r); for(i=0;i<4;++i) { strncpy(r,&LcdBuffer[20*i],20); r[20]=0; puts_pc(r); puts_pc("\r\n"); } for(i=0;i<4;++i) { strncpy(r,&LcdExt[8*i],8); r[8]=0; puts_pc(r); puts_pc("\r\n"); } puts_pc(">"); } SetTask(CheckScreen,2,RTC_task); }
void espParse(void){ u08 Len = FIFO_FRONT(espRxBuf); u08* ptrData = malloc(Len); if (ptrData == NULL) //Не хватило памяти для обработки команды, подождем может появится SetTask(espParse); else{ u08* Data = ptrData; FIFO_POP(espRxBuf); for(u08 i=Len;i;i--){ //Извлекаем данные из буфера *Data = FIFO_FRONT(espRxBuf); Data++; FIFO_POP(espRxBuf); } u08 Cmd = FIFO_FRONT(espRxBuf); FIFO_POP(espRxBuf); for (u08 i=0; i < UART_CMD_NUM_MAX; i++) { if (espCmdCode(i) == ClkCmdCode(Cmd)){ //Команда найдена ((VOID_CLK_UART_CMD)&espCmdExec(i))(Cmd, ptrData, Len);//Отрабатываем break; } } free(ptrData); } }
void TaskAlarm (void) { if (PM_PinIsClear(ALARM_STATUS) && PM_PinIsClear(ALARM_PAGER))//fprintf(stdout, "Alarm in GuardMode"); { } else if (PM_PinIsClear(ALARM_STATUS) && PM_PinIsSet(ALARM_PAGER)) { //fprintf(stdout, "Alarm is CALLING"); if (BitIsClear(status, ST_ALARM)) { SetTask(TaskCall); } } else { /*if (PM_PinIsSet(ALARM_STATUS)) { fprintf(stdout, "STATUS is High\t"); } else { fprintf(stdout, "STATUS is low\t"); } if (PM_PinIsSet(ALARM_PAGER)) { fprintf(stdout, "PAGER is High\n"); } else { fprintf(stdout, "PAGER is low\n"); }*/ } SetTimerTask(TaskAlarm, 1000); }
void Pilot::init() { functioning = 1; new_damage = 0.0; time_to_target = 0.0; if (params->log) OpenLog(NULL); Init(); pitchPid = flight->specs->pitchPid; rollPid = flight->specs->rollPid; yawPid = flight->specs->yawPid; gPid = flight->specs->gPid; airSpeedPid = flight->specs->airSpeedPid; targetClosurePid = flight->specs->targetClosurePid; SetTask(NOTHING); SetManeuver(sManeuver::STRAIGHT_AND_LEVEL,IMNVR_LOOPBIT); grndColSecs = 5.0; posGLimit = params->posG; negGLimit = params->negG; immelmanGs = posGLimit; splitSGs = posGLimit; tactics.altThreshold = 2000.0; formationWingLen = flight->specs->formationWingLen; formationOffset = flight->specs->formationOffset; }
CRef<CBlastOptionsHandle> CBlastnAppArgs::x_CreateOptionsHandle(CBlastOptions::EAPILocality locality, const CArgs& args) { CRef<CBlastOptionsHandle> retval; SetTask(args[kTask].AsString()); retval.Reset(CBlastOptionsFactory::CreateTask(GetTask(), locality)); _ASSERT(retval.NotEmpty()); return retval; }
void Initial() { CyGlobalIntEnable; //Check_Boot(); Timer_RTOS_Start(); PWM_Start(); I2C_Start(); UART_Start(); RTC_Start(); RTC_SetPeriod(1,1000); RTOS_Start(); SetTask(Brightles_PID_Controll); LCD_WS0010Start(); SetTask(WaitPowerStab); SetTimerTask(OPT_Get_Result, 1300); //BLE_Status(); GlobalStruct.OS_Status = 0; SetTimerTask(Display_Controll, 2000); }
Pilot::Pilot(Flight *flt, Pilot_Params *params, Weapon_Instance *weapons, int n_weaps, char *hndl, Target *target_obj) : aiPilot(&sbrFlight), sbrFlight(flt) { this->params = params; this->weapons = weapons; this->n_weaps = n_weaps; this->target_obj = target_obj; SetAffiliation(params->affiliation); SetHandle(hndl); SetTask(NOTHING); AddaiPilot(this); target_flight = NULL; target_pilot = NULL; target = NULL; flight = flt; sel_wpn = 0; sel_weapon = &weapons[0]; message.time_limit = 3.0; new_damage = 0.0; if (!flight->controls.autopilot) { if (!IsPlayer()) ClearManeuverStack(); SetAsPlayer(1); } else SetAsPlayer(0); /* * See if we are carrying * stores which we can later * drop dramatically when engaged */ nstores = 0; for (int i=0;i<n_weaps;i++) { if (weapons[i].getType() == fueltank_t) { if (nstores < sbrPIL_MAX_STORES) { stores[nstores] = i; nstores++; } else break; } } }
void EeprmStartWrite(void){ if (epWriteIsBusy()) //Запись еще идет SetTask(EeprmStartWrite); //Ожидаем завершения else{ //Можно запускать запись в EEPROM epWriteBusy(); //Занять автомат epAdrWrite = epAdrNextPacket(); epStepWr = 0; epCountWr = 0; epEndEvent = epAlarmWrite; //Сначала записывается состояние будильников epAdrWrite++; //Оставляем один байт для метки актуальности пакета epWriteStart(); //Старт записи } }
void CIVPedTaskManager::RemoveTask(int iType) { // Do we have a valid ped task manager pointer? if(m_pPedTaskManager) { // Ensure the task type is valid if(iType < TASK_PRIORITY_MAX) { // Make sure its not the default task if(iType != TASK_PRIORITY_DEFAULT) SetTask(NULL, iType); } } }
/*......................................................................*/ void JwSend(void) { static int n; int i,j; if(!CheckTask(JwSend,PIT_task)) { n=0; SetTask(JwSend,100,PIT_task); } for(i=j=0; i<=JwTx[0]; ++i) j += Putch(JwTx[i],CHAUX); Putch(j,CHAUX); if(++n >= 5) DeleteTask(JwSend,PIT_task); }
/*------------------------------------------------------*/ void Submit(void) { static int i; if(!shutdown_load(NULL)) if(readRTC(0) || readRTC(1) || readRTC(2)) { if(!CheckTask(Submit,RTC_task)) { SetTask(Submit,1,RTC_task); i=3; } else{ Ungetch(readRTC(i),10); if(++i > 7) DeleteTask(Submit,RTC_task); } } }
void CGame::Init(HWND hwnd) { m_hwnd = hwnd; HMODULE processModule = GetModuleHandle(NULL); TCHAR szModuleFilePath[MAX_PATH]; GetModuleFileName(processModule, szModuleFilePath, MAX_PATH); m_strWorkRootPath = CFilePathTool::GetInstance()->ParentPath(szModuleFilePath); m_strWorkRootPath.append(_T("/")); SetTask(eTT_Title); BEATS_PERFORMDETECT_INIT(NBDT::perfromanceStr, NBDT::ePT_Count); #ifdef _DEBUG CDebugTool::GetInstance()->SwitchDebugMsgPrinting(true); #endif }
/*......................................................................*/ void JwRec(void) { static ack_flag; int j; if(Kbhit(CHAUX)) if(CheckTask(JwSend,PIT_task)) switch(j=Getch(CHAUX)) { case ACK_COM: ack_flag = ACK_COM; break; case NACK_COM: JwSend(); break; default: if((ack_flag == ACK_COM) && (j == JwTx[0])) DeleteTask(JwSend,PIT_task); ack_flag = 0; break; } else switch(JwCount) { case 0: JwCount=JwCheck=Getch(CHAUX); if(JwCount > 16) JwCount=0; else{ JwCount++; Jw=JwRx; SetTask(JwDrop,50,PIT_task); } break; case 1: if(JwExe()) { Putch(ACK_COM,CHAUX); Putch(JwRx[0],CHAUX); } else Putch(NACK_COM,CHAUX); JwCount--; DeleteTask(JwDrop,PIT_task); break; default: *Jw = Getch(CHAUX); JwCheck += *Jw++; JwCount--; break; } }
void stGateUser::DisConnect(defTempId _id, QWORD _time) { stGateTask * p_task = GetTask(); if(!p_task) { Global::logger->debug("why not find this task <%llu>", taskid); return; } m_stLock.wrlock(); Global::logger->debug("->>>>>>>>>>>>>>>>>>disconnect %llu,%llu", _id, p_task->GetTaskId()); if(_id == p_task->GetTaskId()) { m_qdDisTime = _time + 60 * 1000; SetTask(NULL); m_blIsConnect = false; } m_stLock.unlock(); }
//============================================================================== int main(void) { pinMode(led, OUTPUT); InitAll(); // Инициализируем периферию InitRTOS(); // Инициализируем ядро RunRTOS(); // Старт ядра. // Запуск фоновых задач. SetTask(Task1); while(1) // Главный цикл диспетчера { wdt_reset(); // Сброс собачьего таймера TaskManager(); // Вызов диспетчера } return 0; }
CRef<CBlastOptionsHandle> CIgBlastnAppArgs::x_CreateOptionsHandle(CBlastOptions::EAPILocality locality, const CArgs& args) { CRef<CBlastOptionsHandle> retval; SetTask("blastn"); retval.Reset(CBlastOptionsFactory::CreateTask(GetTask(), locality)); _ASSERT(retval.NotEmpty()); retval->SetFilterString("F"); //retval->SetEvalueThreshold(1e-15); <- this will be overwritten anyway CBlastOptions &opts = retval->SetOptions(); opts.SetMatchReward(1); opts.SetMismatchPenalty(-1); opts.SetWordSize(11); opts.SetGapOpeningCost(4); opts.SetGapExtensionCost(1); return retval; }
//============================================================================== int main(void) { InitAll(); // Инициализируем периферию /*for (short i = 0 ; i < 10 ; i++) { PM_OnPin(LED_RED);//зажигаем светодиод //LED_PORT ^=1<<LED1; _delay_ms(100); PM_OffPin(LED_RED);//зажигаем светодиод //LED_PORT ^=1<<LED1; _delay_ms(400); }*/ pressedTime = 0; InitRTOS(); // Инициализируем ядро RunRTOS(); // Старт ядра. SetTask(TaskScanButtons); wdt_enable(WDTO_1S); while(1) // Главный цикл диспетчера { wdt_reset(); // Сброс собачьего таймера TaskManager(); // Вызов диспетчера } return 0; }
/*......................................................................*/ void AdsData(void) { uint i; if(aux_mode != AUX_JW) return; if(JwCount || CheckTask(JwSend,PIT_task)) SetTask(AdsData,1,RTC_task); else{ DeleteTask(AdsData,RTC_task); Jw = JwTx; *Jw++=7; *Jw++=ADS_DATA; i=JwAZ; *Jw++=i / 256; *Jw++=i % 256; i=JwR; *Jw++=i / 256; *Jw++=i % 256; i=JwEL; *Jw++=i / 256; *Jw++=i % 256; JwSend(); } }
/*------------------------------------------------------*/ void ListToPc (char *s) { int i; lib *l; command *c; #ifndef WIN32 void heap_start(void); static long *p; char cc[32]; #endif uchar r[LINK_LEN],rr[16]; switch(*s) { case 'l': l=Ln; do { l->check=null; l=l->next; } while(l != Ln); c=CP; if(c) do { c->chk=null; c=c->next; } while(c != CP); SetTask(CheckScreen,0,RTC_task); SetTask(CheckLib,0,RTC_task); break; case 's': CheckScr=null; if(!CheckTask(CheckScreen,RTC_task)) CheckScreen(); else SetTask(CheckScreen,0,RTC_task); break; case 'o': sprintf(r,"=o %s,%d\r\n>",LinkAddrText(LinkAddr(OBP),rr),targets_xn(OBP)); puts_pc(r); break; case 'p': puts_pc("=p "); putsLLA(OBP); puts_pc("\r\n"); break; case 'm': for(i=0; _MenuCode[i]; ++i) { sprintf(r,"=m[%d] ",i); for(s=_MenuCode[i]; *s; ++s) if(*s == ' ') sprintf(strchr(r,0)," "); else { /* if(*s < ENTER) sprintf(strchr(r,0),"%c",*s); else */ sprintf(strchr(r,0),"%02X",*s); } sprintf(strchr(r,0),"\r\n"); puts_pc(r); } break; case 't': for(i=0; _TextCode[i]; ++i) { sprintf(r,"=t[%d] ",i); for(s=_TextCode[i]; *s; ++s) sprintf(strchr(r,0),"%02X",*s); sprintf(strchr(r,0),"\r\n"); puts_pc(r); } break; case 'h': for(i=0; _MenuHead[i]; ++i) { sprintf(r,"=h[%d] ",i); for(s=_MenuHead[i]; *s; ++s) sprintf(strchr(r,0),"%02X",*s); sprintf(strchr(r,0),"\r\n"); puts_pc(r); } break; #ifndef WIN32 case 'H': for(p=(long *)heap_start; *p; p=(long *)labs(*p)) { if(*p>0) sprintf(cc,"=H %08lX,%08lX,!\r\n",p,*p); else sprintf(cc,"=H %08lX,%08lX,-\r\n",p,-(*p)); puts_pc(cc); } break; #endif case 'f': ListPar(); break; case 'z': ListZone(NULL); break; case 'v': puts_pc(">=v"); SysMessage(CHPC); break; case 'G': WriteGunData(Guns,NULL); break; case 'D': ListDatum(); break; case 'e': shaft_enable(); break; default: ReadLib(s); break; } }
// Respond to radio commands from HUMAN players void CCSBot::RespondToRadioCommands() { // bots use the chatter system to respond to each other if (m_radioSubject.IsValid() && m_radioSubject->IsPlayer()) { if (m_radioSubject->IsBot()) { m_lastRadioCommand = EVENT_INVALID; return; } } if (m_lastRadioCommand == EVENT_INVALID) return; // a human player has issued a radio command GetChatter()->ResetRadioSilenceDuration(); // if we are doing something important, ignore the radio // unless it is a "report in" request - we can do that while we continue to do other things // TODO: Create "uninterruptable" flag if (m_lastRadioCommand != EVENT_RADIO_REPORT_IN_TEAM) { if (IsBusy()) { // consume command m_lastRadioCommand = EVENT_INVALID; return; } } // wait for reaction time before responding // delay needs to be long enough for the radio message we're responding to to finish float respondTime = 1.0f + 2.0f * GetProfile()->GetReactionTime(); if (IsRogue()) respondTime += 2.0f; if (gpGlobals->time - m_lastRadioRecievedTimestamp < respondTime) return; // rogues won't follow commands, unless already following the player if (!IsFollowing() && IsRogue()) { if (IsRadioCommand(m_lastRadioCommand)) { GetChatter()->Negative(); } // consume command m_lastRadioCommand = EVENT_INVALID; return; } if (!m_radioSubject) return; // respond to command bool canDo = false; const float inhibitAutoFollowDuration = 60.0f; switch (m_lastRadioCommand) { case EVENT_RADIO_REPORT_IN_TEAM: { GetChatter()->ReportingIn(); break; } case EVENT_RADIO_FOLLOW_ME: case EVENT_RADIO_COVER_ME: case EVENT_RADIO_STICK_TOGETHER_TEAM: case EVENT_RADIO_REGROUP_TEAM: { if (!IsFollowing()) { Follow(m_radioSubject); m_radioSubject->AllowAutoFollow(); canDo = true; } break; } case EVENT_RADIO_ENEMY_SPOTTED: case EVENT_RADIO_NEED_BACKUP: case EVENT_RADIO_TAKING_FIRE: { if (!IsFollowing()) { Follow(m_radioSubject); GetChatter()->Say("OnMyWay"); m_radioSubject->AllowAutoFollow(); canDo = false; } break; } case EVENT_RADIO_TEAM_FALL_BACK: { if (TryToRetreat()) canDo = true; break; } case EVENT_RADIO_HOLD_THIS_POSITION: { // find the leader's area SetTask(HOLD_POSITION); StopFollowing(); m_radioSubject->InhibitAutoFollow(inhibitAutoFollowDuration); Hide(TheNavAreaGrid.GetNearestNavArea(&m_radioPosition)); canDo = true; break; } case EVENT_RADIO_GO_GO_GO: case EVENT_RADIO_STORM_THE_FRONT: { StopFollowing(); Hunt(); canDo = true; m_radioSubject->InhibitAutoFollow(inhibitAutoFollowDuration); break; } case EVENT_RADIO_GET_OUT_OF_THERE: { if (TheCSBots()->IsBombPlanted()) { EscapeFromBomb(); m_radioSubject->InhibitAutoFollow(inhibitAutoFollowDuration); canDo = true; } break; } case EVENT_RADIO_SECTOR_CLEAR: { // if this is a defusal scenario, and the bomb is planted, // and a human player cleared a bombsite, check it off our list too if (TheCSBots()->GetScenario() == CCSBotManager::SCENARIO_DEFUSE_BOMB) { if (m_iTeam == CT && TheCSBots()->IsBombPlanted()) { const CCSBotManager::Zone *zone = TheCSBots()->GetClosestZone(m_radioSubject); if (zone) { GetGameState()->ClearBombsite(zone->m_index); // if we are huting for the planted bomb, re-select bombsite if (GetTask() == FIND_TICKING_BOMB) Idle(); canDo = true; } } } break; } default: // ignore all other radio commands for now return; } if (canDo) { // affirmative GetChatter()->Affirmative(); // if we agreed to follow a new command, put away our grenade if (IsRadioCommand(m_lastRadioCommand) && IsUsingGrenade()) { EquipBestWeapon(); } } // consume command m_lastRadioCommand = EVENT_INVALID; }
CBlastnAppArgs::CBlastnAppArgs() { CRef<IBlastCmdLineArgs> arg; static const string kProgram("blastn"); arg.Reset(new CProgramDescriptionArgs(kProgram, "Nucleotide-Nucleotide BLAST")); const bool kQueryIsProtein = false; m_Args.push_back(arg); m_ClientId = kProgram + " " + CBlastVersion().Print(); static const string kDefaultTask = "megablast"; SetTask(kDefaultTask); set<string> tasks (CBlastOptionsFactory::GetTasks(CBlastOptionsFactory::eNuclNucl)); tasks.erase("vecscreen"); // vecscreen has its own program arg.Reset(new CTaskCmdLineArgs(tasks, kDefaultTask)); m_Args.push_back(arg); m_BlastDbArgs.Reset(new CBlastDatabaseArgs); m_BlastDbArgs->SetDatabaseMaskingSupport(true); arg.Reset(m_BlastDbArgs); m_Args.push_back(arg); m_StdCmdLineArgs.Reset(new CStdCmdLineArgs); arg.Reset(m_StdCmdLineArgs); m_Args.push_back(arg); arg.Reset(new CGenericSearchArgs(kQueryIsProtein, false, true)); m_Args.push_back(arg); arg.Reset(new CNuclArgs); m_Args.push_back(arg); arg.Reset(new CDiscontiguousMegablastArgs); m_Args.push_back(arg); arg.Reset(new CFilteringArgs(kQueryIsProtein)); m_Args.push_back(arg); arg.Reset(new CGappedArgs); m_Args.push_back(arg); m_HspFilteringArgs.Reset(new CHspFilteringArgs); arg.Reset(m_HspFilteringArgs); m_Args.push_back(arg); arg.Reset(new CWindowSizeArg); m_Args.push_back(arg); arg.Reset(new COffDiagonalRangeArg); m_Args.push_back(arg); arg.Reset(new CMbIndexArgs); m_Args.push_back(arg); m_QueryOptsArgs.Reset(new CQueryOptionsArgs(kQueryIsProtein)); arg.Reset(m_QueryOptsArgs); m_Args.push_back(arg); m_FormattingArgs.Reset(new CFormattingArgs); arg.Reset(m_FormattingArgs); m_Args.push_back(arg); m_MTArgs.Reset(new CMTArgs); arg.Reset(m_MTArgs); m_Args.push_back(arg); m_RemoteArgs.Reset(new CRemoteArgs); arg.Reset(m_RemoteArgs); m_Args.push_back(arg); m_DebugArgs.Reset(new CDebugArgs); arg.Reset(m_DebugArgs); m_Args.push_back(arg); }
/*------------------------------------------------------*/ void LoadFromPc(char *p) { void InProg(void); int ReadPar(char *); char q[LINK_LEN],*r,*s,*ss[16]; int i,j,k; long y,z; lib *l; command *c,**cp; switch(*p) { case 'd': Lr=scanLLA(Lr,++p,null); if(!Lr) { j=0; switch(strscan(p,ss,',',16)) { case 2: j=atoi(ss[1]); case 1: if(l=FindLib(LinkAddrStr(ss[0]))) { copylib(l,Lr=makelib()); if(j) for(Lr->xc=Lr->x; --j && Lr->xc->next;) Lr->xc=Lr->xc->next; else Lr->x=Lr->xc=freecoord(Lr->x); Ungetch(REFRESH,0); } else puts_pc("!NOT_FOUND\r\n"); break; default: puts_pc("!SYNTAX\r\n"); break; } } break; case 'l': if(i=LinkAddrStr(++p)) { freelib(Lc); Lc=makelib(); Lc->ltype=LinkAddrType(i); Lc->n=LinkAddrN(i); } else InsertLib(&Lc); break; case 'M': if(sscanf(++p," %d,%04X,%04X,%s",&k,&i,&j,q)==4) { if(Mscan) /* znak, da je editor odprt ! */ if(Mscan->c->maxopt) { /* vrstica in obseg aktivna ? */ if(k) if(--k <= Mscan->c->maxopt) { Mscan->active = k; Refresh(); } break; } r=strchr(q,','); *r++=0; cp=NULL; if(!strcmp(q,"message")) cp=&CP; if(!strcmp(q,"gun")) cp=&GUN; if(!strcmp(q,"meteo")) cp=&METEO; if(!cp) break; /*......................................................................................*/ if(!*cp) new_command(cp); else{ c=*cp; do if(c->chk == j) *cp=c; else c=c->next; while(c != *cp); if((*cp)->chk != j) new_command(cp); } (*cp)->chk=j; c=*cp; s=(char *)c; i = sizeof(command) - sizeof(command *) - sizeof(int); while(i--) { sscanf(r,"%02X",&j); *s++ = j; ++r;++r; } c->chk *= -1; if(cp == &CP) Ungetch(GXM_MESSAGE_ID,0); if(cp == &GUN) Ungetch(GXM_GUN_ID,0); } break; case 'r': if(crest && (sscanf(++p," %ld %ld",&y,&z) == 2)) { add_coord(crest,0,y,z); crest->xc->refp=null; } else DeleteTask(DMRtimeout,RTC_task); break; case 'c': i=j=0; if(Lc) Lc=scanLLA(Lc,++p,eof); break; case 'g': if(Lc && (sscanf(++p," %s %d %d",q,&j,&k) == 3)) { for(i=0; Guns[i].name; ++i) if(!strcmp(Guns[i].name,q)) { Lc->gun=i; Lc->refd=j; Lc->powder=k; } } break; case 'a': if(Lc && (sscanf(++p,"%s %d",q,&j) == 2)) { for(i=0; Guns[Lc->gun].ammo[i]; ++i) if(!strcmp(Guns[Lc->gun].ammo[i],q)) { Lc->ammpcs[i]=j; r=strchr(p,'+'); s=strrchr(p,'+'); if(r) do Lc->ammpcs[i] += 0x1000; while(r++ != s); r=strchr(p,'-'); s=strrchr(p,'-'); if(r) do Lc->ammpcs[i] -= 0x1000; while(r++ != s); } } break; case 'p': if(sscanf(++p,"%d,%d",&i,&j) == 2) if(i<12 && j<4) { xyLCD(i,j); Ungetch(GXM_CURSOR_POS,0); } break; case 'm': LoadHexRec(p,'m',_MenuCode); break; case 'h': LoadHexRec(p,'h',_MenuHead); break; case 't': if(Lc) { ++p; ++p; Lc->txt=addtxt(Lc,p); } else LoadHexRec(p,'t',_TextCode); break; case 'T': if(sscanf(++p," %x %x",&i,&j)==2) { sprintf(q,"%04X\r\n",readTEMP(i,j)); puts_pc(q); } break; case 'f': if(ReadPar(++p)) break; i=strscan(p,ss,' ',16); if(i>=2) { sscanf(ss[0],"%lx",&eebott); sscanf(ss[1],"%lx",&eetop); if(eebott < (long)FLASHTOP) { puts_pc("!ILL_ADDRESS\r\n"); break; } if(eetop > (long)FLASHTOP+0x80000L) { puts_pc("!ILL_ADDRESS\r\n"); break; } if(i==3) { ss[2][8]=0; sprintf(pass,"%-8s",ss[2]); } if(CheckPass(&syspass)) { puts_pc("!NOT_ALLOWED\r\n"); break; } puts_pc("\7\r\nFLASH programming !!!\r\n"); wait(50); InProg(); puts_pc("Done\r\n"); } else puts_pc("!SYNTAX\r\n"); break; case 'b': k=sscanf(++p," %d %d",&i,&j); if(k) if(Baud(CHPC,i)) { if(k==2) Xonoff(j); break; } puts_pc("!SYNTAX\r\n"); break; case 'z': EnterZone(++p); break; case 'G': DeleteTask(ReadPc,RTC_task); Guns=ReadGunData(0,0,0,0,NULL); SetTask(ReadPc,0,RTC_task); break; default: puts_pc("!SYNTAX\r\n"); break; } }
CIVTask::CIVTask(IVTask * pTask) { // Set the task SetTask(pTask); }
CPsiBlastAppArgs::CPsiBlastAppArgs() { bool const kQueryIsProtein = true; bool const kFilterByDefault = false; static const string kProgram("psiblast"); CRef<IBlastCmdLineArgs> arg; arg.Reset(new CProgramDescriptionArgs(kProgram, "Position-Specific Initiated BLAST")); m_Args.push_back(arg); m_ClientId = kProgram + " " + CBlastVersion().Print(); static const string kDefaultTask = "psiblast"; SetTask(kDefaultTask); m_BlastDbArgs.Reset(new CBlastDatabaseArgs); arg.Reset(m_BlastDbArgs); m_Args.push_back(arg); m_StdCmdLineArgs.Reset(new CStdCmdLineArgs); arg.Reset(m_StdCmdLineArgs); m_Args.push_back(arg); arg.Reset(new CGenericSearchArgs(kQueryIsProtein)); m_Args.push_back(arg); arg.Reset(new CFilteringArgs(kQueryIsProtein, kFilterByDefault)); m_Args.push_back(arg); arg.Reset(new CMatrixNameArg); m_Args.push_back(arg); arg.Reset(new CWordThresholdArg); m_Args.push_back(arg); m_HspFilteringArgs.Reset(new CHspFilteringArgs); arg.Reset(m_HspFilteringArgs); m_Args.push_back(arg); arg.Reset(new CWindowSizeArg); m_Args.push_back(arg); m_QueryOptsArgs.Reset(new CQueryOptionsArgs(kQueryIsProtein)); arg.Reset(m_QueryOptsArgs); m_Args.push_back(arg); m_FormattingArgs.Reset(new CFormattingArgs); arg.Reset(m_FormattingArgs); m_Args.push_back(arg); m_MTArgs.Reset(new CMTArgs); arg.Reset(m_MTArgs); m_Args.push_back(arg); m_RemoteArgs.Reset(new CRemoteArgs); arg.Reset(m_RemoteArgs); m_Args.push_back(arg); arg.Reset(new CCompositionBasedStatsArgs); m_Args.push_back(arg); arg.Reset(new CGapTriggerArgs(kQueryIsProtein)); m_Args.push_back(arg); m_PsiBlastArgs.Reset(new CPsiBlastArgs(CPsiBlastArgs::eProteinDb)); arg.Reset(m_PsiBlastArgs); m_Args.push_back(arg); arg.Reset(new CPssmEngineArgs); m_Args.push_back(arg); arg.Reset(new CPhiBlastArgs); m_Args.push_back(arg); m_DebugArgs.Reset(new CDebugArgs); arg.Reset(m_DebugArgs); m_Args.push_back(arg); }
CIVTask::CIVTask() { // Set the task SetTask(NULL); }
void CCSBot::__MAKE_VHOOK(OnEvent)(GameEventType event, CBaseEntity *entity, CBaseEntity *other) { GetGameState()->OnEvent(event, entity, other); GetChatter()->OnEvent(event, entity, other); // Morale adjustments happen even for dead players switch (event) { case EVENT_TERRORISTS_WIN: if (m_iTeam == CT) { DecreaseMorale(); } else { IncreaseMorale(); } break; case EVENT_CTS_WIN: if (m_iTeam == CT) { IncreaseMorale(); } else { DecreaseMorale(); } break; } if (!IsAlive()) return; CBasePlayer *player = static_cast<CBasePlayer *>(entity); // If we just saw a nearby friend die, and we haven't yet acquired an enemy // automatically acquire our dead friend's killer if (!IsAttacking() && (GetDisposition() == ENGAGE_AND_INVESTIGATE || GetDisposition() == OPPORTUNITY_FIRE)) { if (event == EVENT_PLAYER_DIED) { if (BotRelationship(player) == BOT_TEAMMATE) { CBasePlayer *killer = static_cast<CBasePlayer *>(other); // check that attacker is an enemy (for friendly fire, etc) if (killer != NULL && killer->IsPlayer()) { // check if we saw our friend die - dont check FOV - assume we're aware of our surroundings in combat // snipers stay put if (!IsSniper() && IsVisible(&player->pev->origin)) { // people are dying - we should hurry Hurry(RANDOM_FLOAT(10.0f, 15.0f)); // if we're hiding with only our knife, be a little more cautious const float knifeAmbushChance = 50.0f; if (!IsHiding() || !IsUsingKnife() || RANDOM_FLOAT(0, 100) < knifeAmbushChance) { PrintIfWatched("Attacking our friend's killer!\n"); Attack(killer); return; } } } } } } switch (event) { case EVENT_PLAYER_DIED: { CBasePlayer *victim = player; CBasePlayer *killer = (other != NULL && other->IsPlayer()) ? static_cast<CBasePlayer *>(other) : NULL; // if the human player died in the single player game, tell the team if (CSGameRules()->IsCareer() && !victim->IsBot() && BotRelationship(victim) == BOT_TEAMMATE) { GetChatter()->Say("CommanderDown", 20.0f); } // keep track of the last player we killed if (killer == this) { m_lastVictimID = victim->entindex(); } // react to teammate death if (BotRelationship(victim) == BOT_TEAMMATE) { // chastise friendly fire from humans if (killer != NULL && !killer->IsBot() && BotRelationship(killer) == BOT_TEAMMATE && killer != this) { GetChatter()->KilledFriend(); } if (IsHunting()) { PrintIfWatched("Rethinking hunt due to teammate death\n"); Idle(); return; } if (IsAttacking()) { if (GetTimeSinceLastSawEnemy() > 0.4f) { PrintIfWatched("Rethinking my attack due to teammate death\n"); // allow us to sneak past windows, doors, etc IgnoreEnemies(1.0f); // move to last known position of enemy - this could cause us to flank if // the danger has changed due to our teammate's recent death SetTask(MOVE_TO_LAST_KNOWN_ENEMY_POSITION, GetEnemy()); MoveTo(&GetLastKnownEnemyPosition()); return; } } } // an enemy was killed else { if (killer != NULL && BotRelationship(killer) == BOT_TEAMMATE) { // only chatter about enemy kills if we see them occur, and they were the last one we see if (GetNearbyEnemyCount() <= 1) { // report if number of enemies left is few and we killed the last one we saw locally GetChatter()->EnemiesRemaining(); if (IsVisible(&victim->pev->origin, CHECK_FOV)) { // congratulate teammates on their kills if (killer != this) { float delay = RANDOM_FLOAT(2.0f, 3.0f); if (killer->IsBot()) { if (RANDOM_FLOAT(0.0f, 100.0f) < 40.0f) GetChatter()->Say("NiceShot", 3.0f, delay); } else { // humans get the honorific if (CSGameRules()->IsCareer()) GetChatter()->Say("NiceShotCommander", 3.0f, delay); else GetChatter()->Say("NiceShotSir", 3.0f, delay); } } } } } } return; } case EVENT_TERRORISTS_WIN: if (m_iTeam == TERRORIST) GetChatter()->CelebrateWin(); return; case EVENT_CTS_WIN: if (m_iTeam == CT) GetChatter()->CelebrateWin(); return; case EVENT_BOMB_DEFUSED: if (m_iTeam == CT && TheCSBots()->GetBombTimeLeft() < 2.0) GetChatter()->Say("BarelyDefused"); return; case EVENT_BOMB_PICKED_UP: { if (m_iTeam == CT && player != NULL) { // check if we're close enough to hear it const float bombPickupHearRangeSq = 1000.0f * 1000.0f; if ((pev->origin - player->pev->origin).LengthSquared() < bombPickupHearRangeSq) { GetChatter()->TheyPickedUpTheBomb(); } } return; } case EVENT_BOMB_BEEP: { // if we don't know where the bomb is, but heard it beep, we've discovered it if (GetGameState()->IsPlantedBombLocationKnown() == false) { // check if we're close enough to hear it const float bombBeepHearRangeSq = 1000.0f * 1000.0f; if ((pev->origin - entity->pev->origin).LengthSquared() < bombBeepHearRangeSq) { // radio the news to our team if (m_iTeam == CT && GetGameState()->GetPlantedBombsite() == CSGameState::UNKNOWN) { const CCSBotManager::Zone *zone = TheCSBots()->GetZone(&entity->pev->origin); if (zone != NULL) GetChatter()->FoundPlantedBomb(zone->m_index); } // remember where the bomb is GetGameState()->UpdatePlantedBomb(&entity->pev->origin); } } return; } case EVENT_BOMB_PLANTED: { // if we're a CT, forget what we're doing and go after the bomb if (m_iTeam == CT) { Idle(); } // if we are following someone, stop following if (IsFollowing()) { StopFollowing(); Idle(); } OnEvent(EVENT_BOMB_BEEP, other); return; } case EVENT_BOMB_DEFUSE_ABORTED: PrintIfWatched("BOMB DEFUSE ABORTED\n"); return; case EVENT_WEAPON_FIRED: case EVENT_WEAPON_FIRED_ON_EMPTY: case EVENT_WEAPON_RELOADED: { if (m_enemy == entity && IsUsingKnife()) ForceRun(5.0f); break; } default: break; } // Process radio events from our team if (player != NULL && BotRelationship(player) == BOT_TEAMMATE && event > EVENT_START_RADIO_1 && event < EVENT_END_RADIO) { // TODO: Distinguish between radio commands and responses if (event != EVENT_RADIO_AFFIRMATIVE && event != EVENT_RADIO_NEGATIVE && event != EVENT_RADIO_REPORTING_IN) { m_lastRadioCommand = event; m_lastRadioRecievedTimestamp = gpGlobals->time; m_radioSubject = player; m_radioPosition = player->pev->origin; } } // player_follows needs a player if (player == NULL) return; if (!IsRogue() && event == EVENT_HOSTAGE_CALLED_FOR_HELP && m_iTeam == CT && IsHunting()) { if ((entity->pev->origin - pev->origin).IsLengthGreaterThan(1000.0f)) return; if (IsVisible(&entity->Center())) { m_task = COLLECT_HOSTAGES; m_taskEntity = NULL; Run(); m_goalEntity = entity; MoveTo(&entity->pev->origin, m_hostageEscortCount == 0 ? SAFEST_ROUTE : FASTEST_ROUTE); PrintIfWatched("I'm fetching a hostage that called out to me\n"); return; } } // don't pay attention to noise that friends make if (!IsEnemy(player)) return; float range; PriorityType priority; bool isHostile; if (IsGameEventAudible(event, entity, other, &range, &priority, &isHostile) == false) return; if (event == EVENT_HOSTAGE_USED) { if (m_iTeam == CT) return; if ((entity->pev->origin - pev->origin).IsLengthGreaterThan(range)) return; GetChatter()->HostagesBeingTaken(); if (!GetGameState()->GetNearestVisibleFreeHostage() && m_task != GUARD_HOSTAGE_RESCUE_ZONE && GuardRandomZone()) { m_task = GUARD_HOSTAGE_RESCUE_ZONE; m_taskEntity = NULL; SetDisposition(OPPORTUNITY_FIRE); PrintIfWatched("Trying to beat them to an escape zone!\n"); } } // check if noise is close enough for us to hear const Vector *newNoisePosition = &player->pev->origin; float newNoiseDist = (pev->origin - *newNoisePosition).Length(); if (newNoiseDist < range) { // we heard the sound if ((IsLocalPlayerWatchingMe() && cv_bot_debug.value == 3.0f) || cv_bot_debug.value == 4.0f) { PrintIfWatched("Heard noise (%s from %s, pri %s, time %3.1f)\n", (event == EVENT_WEAPON_FIRED) ? "Weapon fire " : "", STRING(player->pev->netname), (priority == PRIORITY_HIGH) ? "HIGH" : ((priority == PRIORITY_MEDIUM) ? "MEDIUM" : "LOW"), gpGlobals->time); } if (event == EVENT_PLAYER_FOOTSTEP && IsUsingSniperRifle() && newNoiseDist < 300.0) EquipPistol(); // should we pay attention to it // if noise timestamp is zero, there is no prior noise if (m_noiseTimestamp > 0.0f) { // only overwrite recent sound if we are louder (closer), or more important - if old noise was long ago, its faded const float shortTermMemoryTime = 3.0f; if (gpGlobals->time - m_noiseTimestamp < shortTermMemoryTime) { // prior noise is more important - ignore new one if (priority < m_noisePriority) return; float oldNoiseDist = (pev->origin - m_noisePosition).Length(); if (newNoiseDist >= oldNoiseDist) return; } } // find the area in which the noise occured // TODO: Better handle when noise occurs off the nav mesh // TODO: Make sure noise area is not through a wall or ceiling from source of noise // TODO: Change GetNavTravelTime to better deal with NULL destination areas CNavArea *noiseArea = TheNavAreaGrid.GetNavArea(newNoisePosition); if (noiseArea == NULL) noiseArea = TheNavAreaGrid.GetNearestNavArea(newNoisePosition); if (noiseArea == NULL) { PrintIfWatched(" *** Noise occurred off the nav mesh - ignoring!\n"); return; } m_noiseArea = noiseArea; // remember noise priority m_noisePriority = priority; // randomize noise position in the area a bit - hearing isn't very accurate // the closer the noise is, the more accurate our placement // TODO: Make sure not to pick a position on the opposite side of ourselves. const float maxErrorRadius = 400.0f; const float maxHearingRange = 2000.0f; float errorRadius = maxErrorRadius * newNoiseDist / maxHearingRange; m_noisePosition.x = newNoisePosition->x + RANDOM_FLOAT(-errorRadius, errorRadius); m_noisePosition.y = newNoisePosition->y + RANDOM_FLOAT(-errorRadius, errorRadius); // make sure noise position remains in the same area m_noiseArea->GetClosestPointOnArea(&m_noisePosition, &m_noisePosition); m_isNoiseTravelRangeChecked = false; // note when we heard the noise m_noiseTimestamp = gpGlobals->time; } }
CBlastpAppArgs::CBlastpAppArgs() { CRef<IBlastCmdLineArgs> arg; static const string kProgram("blastp"); arg.Reset(new CProgramDescriptionArgs(kProgram, "Protein-Protein BLAST")); const bool kQueryIsProtein = true; bool const kFilterByDefault = false; m_Args.push_back(arg); m_ClientId = kProgram + " " + CBlastVersion().Print(); static const string kDefaultTask = "blastp"; SetTask(kDefaultTask); set<string> tasks (CBlastOptionsFactory::GetTasks(CBlastOptionsFactory::eProtProt)); arg.Reset(new CTaskCmdLineArgs(tasks, kDefaultTask)); m_Args.push_back(arg); m_BlastDbArgs.Reset(new CBlastDatabaseArgs); m_BlastDbArgs->SetDatabaseMaskingSupport(true); arg.Reset(m_BlastDbArgs); m_Args.push_back(arg); m_StdCmdLineArgs.Reset(new CStdCmdLineArgs); arg.Reset(m_StdCmdLineArgs); m_Args.push_back(arg); arg.Reset(new CGenericSearchArgs(kQueryIsProtein)); m_Args.push_back(arg); arg.Reset(new CFilteringArgs(kQueryIsProtein, kFilterByDefault)); m_Args.push_back(arg); arg.Reset(new CMatrixNameArg); m_Args.push_back(arg); arg.Reset(new CWordThresholdArg); m_Args.push_back(arg); m_HspFilteringArgs.Reset(new CHspFilteringArgs); arg.Reset(m_HspFilteringArgs); m_Args.push_back(arg); arg.Reset(new CWindowSizeArg); m_Args.push_back(arg); m_QueryOptsArgs.Reset(new CQueryOptionsArgs(kQueryIsProtein)); arg.Reset(m_QueryOptsArgs); m_Args.push_back(arg); m_FormattingArgs.Reset(new CFormattingArgs); arg.Reset(m_FormattingArgs); m_Args.push_back(arg); m_MTArgs.Reset(new CMTArgs); arg.Reset(m_MTArgs); m_Args.push_back(arg); arg.Reset(new CGappedArgs); m_Args.push_back(arg); m_RemoteArgs.Reset(new CRemoteArgs); arg.Reset(m_RemoteArgs); m_Args.push_back(arg); arg.Reset(new CCompositionBasedStatsArgs); m_Args.push_back(arg); m_DebugArgs.Reset(new CDebugArgs); arg.Reset(m_DebugArgs); m_Args.push_back(arg); }