Ejemplo n.º 1
0
static Condition* GetCondition(char* string)
{
	unsigned int count;
	char **lines = GetStrings( string, count );
	Condition *condition = new Condition();
	for (size_t i = 0; i < count; ++i) {
		Trigger *trigger = GenerateTrigger(lines[i]);
		if (!trigger) {
			printMessage("DLGImporter", "Can't compile trigger: %s\n" , YELLOW, lines[i]);
		} else {
			condition->triggers.push_back(trigger);
		}
		free( lines[i] );
	}
	free( lines );
	return condition;
}
Ejemplo n.º 2
0
//-----------------------------------------------------------------------------
void CIfcbDlg::OnBnClickedTrigger() {

	GenerateTrigger();
}
Ejemplo n.º 3
0
Store* STOImporter::GetStore(Store *s)
{
    unsigned int i;

    if (!s)
        return NULL;

    // saving in original version requires the original version
    // otherwise it is set to 0 at construction time
    if (core->SaveAsOriginal) {
        s->version = version;
    }

    str->ReadDword( &s->Type );
    str->ReadDword( &s->StoreName );
    str->ReadDword( &s->Flags );
    str->ReadDword( &s->SellMarkup );
    str->ReadDword( &s->BuyMarkup );
    str->ReadDword( &s->DepreciationRate );
    str->ReadWord( &s->StealFailureChance );
    str->ReadWord( &s->Capacity ); //will be overwritten for V9.0
    str->Read( s->unknown, 8 );
    str->ReadDword( &s->PurchasedCategoriesOffset );
    str->ReadDword( &s->PurchasedCategoriesCount );
    str->ReadDword( &s->ItemsOffset );
    str->ReadDword( &s->ItemsCount );
    str->ReadDword( &s->Lore );
    str->ReadDword( &s->IDPrice );
    str->ReadResRef( s->RumoursTavern );
    str->ReadDword( &s->DrinksOffset );
    str->ReadDword( &s->DrinksCount );
    str->ReadResRef( s->RumoursTemple );
    str->ReadDword( &s->AvailableRooms );
    for (i = 0; i < 4; i++) {
        str->ReadDword( &s->RoomPrices[i] );
    }
    str->ReadDword( &s->CuresOffset );
    str->ReadDword( &s->CuresCount );
    str->Read( s->unknown2, 36 );

    if (version == 90) { //iwd stores
        ieDword tmp;

        str->ReadDword( &tmp );
        s->Capacity = (ieWord) tmp;
        str->Read( s->unknown3, 80 );
    } else {
        memset( s->unknown3, 0, 80 );
    }

    size_t size = s->PurchasedCategoriesCount * sizeof( ieDword );
    s->purchased_categories=(ieDword *) malloc(size);

    size = s->CuresCount * sizeof( STOCure );
    s->cures=(STOCure *) malloc(size);

    size = s->DrinksCount * sizeof( STODrink );
    s->drinks=(STODrink *) malloc(size);

    for(size=0; size<s->ItemsCount; size++) {
        STOItem *si = new STOItem();
        memset(si, 0, sizeof(STOItem) );
        s->items.push_back( si );
    }

    str->Seek( s->PurchasedCategoriesOffset, GEM_STREAM_START );
    GetPurchasedCategories( s );

    str->Seek( s->ItemsOffset, GEM_STREAM_START );
    for (i = 0; i < s->ItemsCount; i++) {
        STOItem *item = s->items[i];
        GetItem(item);
        //it is important to handle this field as signed
        if (item->InfiniteSupply>0) {
            char *TriggerCode = core->GetString( (ieStrRef) item->InfiniteSupply );
            item->trigger = GenerateTrigger(TriggerCode);
            core->FreeString(TriggerCode);

            //if there are no triggers, GetRealStockSize is simpler
            //also it is compatible only with pst/gemrb saved stores
            s->HasTriggers=true;
        }
    }

    str->Seek( s->DrinksOffset, GEM_STREAM_START );
    for (i = 0; i < s->DrinksCount; i++) {
        GetDrink(s->drinks+i);
    }

    str->Seek( s->CuresOffset, GEM_STREAM_START );
    for (i = 0; i < s->CuresCount; i++) {
        GetCure(s->cures+i);
    }

    return s;
}
Ejemplo n.º 4
0
//-----------------------------------------------------------------------------
void CIfcbDlg::OnTimer(UINT_PTR nIDEvent) {

	static UINT32 prevCount = 0;
	CString fpsText;
	unsigned int fps;
	CString str;
	//int stepCount;
	char cval[20];
	CString valstr;
	CStringToChar(cval, &valstr);
	CString args;		
	CString args2;	

	switch (nIDEvent) {
		case SYRINGE_TIMER_ID:
			DEBUG_MESSAGE(_T("Syringe timeout fired\r\n"));
			AcqComplete(END_AUTO);						// finish this run
			if (++syringesDone < nSyringes) {			// start a new run if required
				if (!AcqInit())
					Stop();
			} else {									// release the start button
				RunButton.SetCheck(BST_UNCHECKED);
				grabbing = false;						// this stops the data files being written twice
				OnBnClickedRun();
				if (autoShutdown)
					ShutdownWindows();
			}
			break;

		case TRIGGER_TIMER_ID:
			GenerateTrigger();
			break;

		case AUTOSTART_TIMER_ID:
			KillTimer(AUTOSTART_TIMER_ID);
			if (nSyringes) {							// start a run if required
				RunButton.SetCheck(BST_CHECKED);
				OnBnClickedRun();
			}
			break;

		case ACQ_START_TIMEOUT_ID:
			DEBUG_MESSAGE(_T("Trigger timeout fired\r\n"));
			AcqComplete(END_RETRY);						// finish this run
			if (!AcqInit())								// start a new run
				Stop();
			break;

		case FRAMERATE_TIMER_ID:
			if (!grabbing)
				break;
			UINT32_TYPE thisCount;
			thisCount = TabContainer.tabPages[cameraTab]->GetFrameCount();
//			TabContainer.tabPages[cameraTab]->SetDlgItemInt(IDC_FRAMEDROPPEDCOUNT, (thisCount - prevCount) * 2, FALSE);
			fps = (thisCount - prevCount) * 2;
			prevCount = thisCount;
			fpsText.Format(_T("%d.%d"), fps / 10, fps % 10);
			TabContainer.tabPages[cameraTab]->SetDlgItemText(IDC_FRAMEDROPPEDCOUNT, fpsText);
			break;

		case FRAMECOUNT_TIMER_ID:
			if (!grabbing)
				break;
			TabContainer.tabPages[cameraTab]->SetDlgItemInt(IDC_FRAMECOUNT, TabContainer.tabPages[cameraTab]->GetFrameCount(), FALSE);
			break;

		case TCP_TIMER_ID:
			HandleTcp();
			break;

		case PZT_TIMER_ID:							// synchronise the PZT command to only happen directly after a capture
			rqPZT = true;
			//PZTcommand(PZTmode RUN);
			break;

		case PZT_SCAN_TIMER_ID:
			rqPZT = true; // at 492, add this here to see if it fixes eventual-crashing problem with scanning
			str.Format(_T("in scan timer; stepCount = %d\r\n"), stepCount);
				DEBUG_MESSAGE_EXT(str); 
				//To DoFreqScan,
				//we want a loop using a counter for FreqStep (e.g.,StepCounter), 
				//so that at each StepCounter, FreqStep is added to NewFreq. 
				//This loop needs to extend over multiple syringes (i.e., using 
				//freqstepsPerSyr = minPerSyr / minPerStep (from Fileio.cpp) 
				//to keep track of when to go back to StartFreq.
				//We want the loop to continue indefinitely so that multiple scans
				//can be made as instrument temperature is varied (for calibration).

				if (stepCount == 1) {
					PZTfrequency = (int)(StartFreq + FreqStep);
				}
				else if(stepCount % freqstepsPerCycle == 0) {
					PZTfrequency = (int)StartFreq;
				}
				else {
					PZTfrequency = PZTfrequency + (int)FreqStep;
				}
				WriteFreqFile();
					/*args.Format(_T(" --nogui --on --noinit --hz %d --volts %d"), PZTfrequency, PZTvolts);
					DEBUG_MESSAGE_EXT(args); 
					DEBUG_MESSAGE_EXT(_T("\r\n"));
					str = sigGenPath; // note -- this includes the file name as well as path (e.g., "C:\AcousticFocusingWHOI\sig_gen\sig-gen-v1.0.4_64bit\sig-gen-v1.0.4\sig-gen")
					//DEBUG_MESSAGE_EXT(str); 
					DEBUG_MESSAGE_EXT(_T("\r\n"));
					//args2.Format(_T("floor(freqstepsPerSyr) = %f"), floor(freqstepsPerSyr)); 
					args2.Format(_T("freqstepsPerCycle = %d"), int(floor(freqstepsPerCycle))); 
					DEBUG_MESSAGE_EXT(args2); 
					DEBUG_MESSAGE_EXT(_T("\r\n"));
					//args.Format(_T(""));
					//str = "%windir\\system32\\notepad.exe";
					//str += (args);
					//DEBUG_MESSAGE_EXT(str);
					//DEBUG_MESSAGE_EXT(_T("\r\n")); 
					ShellExecute(NULL, _T("open"), str, args, NULL, SW_HIDE);	
					//ShellExecute(NULL, _T("open"), str, args, NULL, SW_NORMAL);	
					*/
					stepCount = stepCount + 1;
					//return;
			rqPZT =  true;
			//}
			break;
			

		case CAPTURE_TIMER_ID:						// used when hasCamera == false
			if (rqStop) {
				Stop();
				break;
			}

			if (!grabbing)
				break;
			
			if (!CheckForCapture()) {
				if (rqStop)
					Stop();
				break;
			}

			KillTimer(ACQ_START_TIMEOUT_ID);
			triggerTickCount = GetTickCount();
			ProcessTrigger(0);
			SetHWParams();							// change any parameters that need it

			// alignment graph plot - takes about 0.5 ms
			if (GraphData.GraphType != GraphData.GRAPH_NONE) {
				TabContainer.tabPages[graphTab]->UpdateGraph();
				TabContainer.tabPages[graphTab]->PostMessage(WM_PAINT, 0, 0);
			}

			DaqArmTrigger();
			if (rqStop)
				Stop();
			break;

		default:
			break;
	}
}