Exemple #1
0
//---------------------------------------------------------------------------
void __fastcall TThreadTimer::Execute()
{
Sleep(2000);
for (int i=0; i<5400; i++)
{
        Sleep(1000);
        timecount++;
if (timecount>=0 && timecount<10)
        outtime="0"+AnsiString(timecount);
else if (timecount>=10 && timecount<60)
        outtime=AnsiString(timecount);
else if (timecount>=60)
        {
        timecountmin++;
        timecount=0;
        outtime="0"+AnsiString(timecount);
}

if (timecountmin>=0 && timecountmin<10)
        outtimemin="0"+AnsiString(timecountmin);
else if (timecountmin>=10)
        outtimemin=AnsiString(timecountmin);

        Synchronize(&ShowTimer);
}

Synchronize(OutTimer);

}
Exemple #2
0
//---------------------------------------------------------------------------
void __fastcall TServerConnectionTH::Execute(void)
{
	ReturnValue = -1;
	while(!Terminated) {
		try {
			TBluetoothSocket * ASocket = NULL;
			while((!Terminated) && (ASocket == NULL)) {
				ASocket = FServerSocket->Accept(100);
			}
			ReturnValue = 0;
			if(ASocket != NULL) {
				FSocket = ASocket;
				while (!Terminated){
					FData = ASocket->ReadData();
					if(FData.Length > 0) {
						Synchronize(TThreadMethod);
					}
					Sleep(100);
				}
			}
		} catch (Exception &ex) {
			Msg = ex.Message;
			Synchronize(TThreadMethodException);
		}
    }
}
Exemple #3
0
//---------------------------------------------------------------------------
void __fastcall TSendThread::Execute()
{
	SOCKET ConnectSocket;
	int r;

	User = LoginForm->UserEdit->Text;
	Password = LoginForm->PasswordEdit->Text;

	if (ConnectSocket = ConnectToServer(this,  ms, srv))	{
		if (Auth(this, ConnectSocket))	{
			r = XMLFile(this, ConnectSocket, msXML);
			if (r) {
				SendForm->Close();
				ThreadMsg = "Данные успешно переданы.";
				Synchronize(&ShowThreadMessage);
			}
		}
		ShutDownConnection(this, ConnectSocket);
	}
	if (SendForm->Visible == true) {
		ThreadMsg = "Ошибка при передаче данных. Данные не отправлены.";
		Synchronize(&ShowThreadMessage);
	}

	delete msXML;
//	delete ms;
//    SendForm->Close();
	//---- Place thread code here ----
}
//---------------------------------------------------------------------------
void __fastcall WriterThread::Execute()
{
   //---- Place thread code here ----
   // sit on WaitForSingleObject, waiting for recorder buffers to be written
   // When write done update write block number

   GJV_thread::setThreadName( "WAV writer" );
   try
   {
      while ( !Terminated )
      {
         if ( WaitForSingleObject( ReleaseWriteEvent, 1000 ) == WAIT_OBJECT_0 )
         {
            // Our event signalled
            while ( WriteBlock < RecordBlock )
            {
               RecBuffer & r = bufflist[ WriteBlock % NBUFFS ];

               if ( r.filled )
               {
                  if ( r.RecBlock != WriteBlock )
                  {
                     Synchronize( &Kill1 );
                     return ;
                  }

#define pttype INT16
                  pttype *q = ( pttype * ) ( r.buff );
                  DDCRET ret = outWave.WriteData ( q, r.Size / 2 );   // size is samples
                  if ( ret != DDC_SUCCESS )
                  {
                     Synchronize( &Kill3 );
                     return ;
                  }
               }
               else
               {
                  Synchronize( &Kill2 );
                  return ;
               }

               r.reset();
               WriteBlock++;
            }
         }
      }
   }
   __finally
   {
      outWave.Close();
   }
}
//---------------------------------------------------------------------------
bool File_Ogg::Header_Begin()
{
    //Synchro
    if (!Synched && !Synchronize())
        return false;

    //Quick test of synchro
    if (CC4(Buffer+Buffer_Offset)!=Ogg::OggS && !Synchronize())
        return false;

    //All should be OK...
    return true;
}
Exemple #6
0
//---------------------------------------------------------------------------
int __fastcall DebuggeeCheckThread::HandleDebugString( DEBUG_EVENT& debug )
{
    void* buffer;
    size_t len = debug.u.DebugString.nDebugStringLength;
    if( len == 0 ) return 1;
    bool isunicode = debug.u.DebugString.fUnicode ? true : false;

    if( isunicode ) {
        buffer = (void*)new wchar_t[len];
        len = len * sizeof(wchar_t);
    } else {
        buffer = (void*)new char[len];
        len = len * sizeof(char);
    }

    // デバッグ文字列を読み出す
    DWORD dwRead;
    BOOL result = ::ReadProcessMemory( proc_info_.hProcess, debug.u.DebugString.lpDebugStringData,
                                       buffer, len, &dwRead );
    if( result == 0 ) {
        ShowLastError();
    } else {
        if( isunicode ) {
            debug_string_ = AnsiString( (wchar_t*)buffer );
        } else {
            debug_string_ = AnsiString( (char*)buffer );
        }
        Synchronize(&SetDebugString);
    }
    delete[] buffer;
    return 1;
}
//---------------------------------------------------------------------------
void __fastcall TComPortRd::Execute()
{
        FlCallBlock = false;
        FlCallSend = false;
        OverlapsRD.hEvent = CreateEvent(NULL, true, true, NULL);
        SetCommMask(ComPortRd, EV_RXCHAR);
        while (!Terminated) {
                WaitCommEvent(ComPortRd, &mask, &OverlapsRD);
                signal = WaitForSingleObject(OverlapsRD.hEvent, 1500);
                if (signal==WAIT_OBJECT_0) {
                        if (GetOverlappedResult(ComPortRd, &OverlapsRD, &temp1, true) ) {
                                if ( (mask & EV_RXCHAR) != 0) {
                                        FlCallSend = true;
                                }
                        }
                }
                else {
                        Sleep(20);
                }
                if ( !EventNewDate ) continue;
                if ( FlCallBlock ) continue;
                if (  FlCallSend ) {
                        ClearCommError(ComPortRd, &temp2, &curstat);
                        btr = curstat.cbInQue;
                        if (btr)
                                Synchronize(EventNewDateSynhr);
                        else
                                FlCallSend = false;
                }
        }
        CloseHandle(OverlapsRD.hEvent);
}
//---------------------------------------------------------------------------
bool File_Vc1::Header_Parser_QuickSearch()
{
    while (           Buffer_Offset+4<=Buffer_Size
      &&   CC3(Buffer+Buffer_Offset)==0x000001)
    {
        //Getting start_code
        int8u start_code=CC1(Buffer+Buffer_Offset+3);

        //Searching start
        if (Streams[start_code].Searching_Payload)
            return true;

        //Getting size
        Buffer_Offset+=4;
        while(Buffer_Offset+4<=Buffer_Size && CC3(Buffer+Buffer_Offset)!=0x000001)
        {
            Buffer_Offset+=2;
            while(Buffer_Offset<Buffer_Size && Buffer[Buffer_Offset]!=0x00)
                Buffer_Offset+=2;
            if (Buffer_Offset<Buffer_Size && Buffer[Buffer_Offset-1]==0x00 || Buffer_Offset>=Buffer_Size)
                Buffer_Offset--;
        }
    }

    if (Buffer_Offset+4<=Buffer_Size)
        Trusted_IsNot("VC-1, Synchronisation lost");
    Synched=false;
    return Synchronize();
}
//---------------------------------------------------------------------------
bool File_AvsV::Header_Parser_QuickSearch()
{
    while (       Buffer_Offset+4<=Buffer_Size
      &&   Buffer[Buffer_Offset  ]==0x00
      &&   Buffer[Buffer_Offset+1]==0x00
      &&   Buffer[Buffer_Offset+2]==0x01)
    {
        //Getting start_code
        int8u start_code=Buffer[Buffer_Offset+3];

        //Searching start or timestamp
        if (Streams[start_code].Searching_Payload)
            return true;

        //Synchronizing
        Buffer_Offset+=4;
        Synched=false;
        if (!Synchronize_0x000001())
            return false;
    }

    if (Buffer_Offset+3==Buffer_Size)
        return false; //Sync is OK, but start_code is not available
    Trusted_IsNot("AVS Video, Synchronisation lost");
    return Synchronize();
}
Exemple #10
0
//---------------------------------------------------------------------------
bool File_Dirac::Header_Parser_QuickSearch()
{
    while (       Buffer_Offset+5<=Buffer_Size
      &&   Buffer[Buffer_Offset  ]==0x42
      &&   Buffer[Buffer_Offset+1]==0x42
      &&   Buffer[Buffer_Offset+2]==0x43
      &&   Buffer[Buffer_Offset+3]==0x44) //"BBCD"
    {
        //Getting start_code
        int8u start_code=CC1(Buffer+Buffer_Offset+4);

        //Searching start
        if (Streams[start_code].Searching_Payload)
            return true;

        //Getting size
        Buffer_Offset+=BigEndian2int32u(Buffer+Buffer_Offset+5);
    }

    if (Buffer_Offset+4==Buffer_Size)
        return false; //Sync is OK, but start_code is not available
    if (Buffer_Offset+5<=Buffer_Size)
        Trusted_IsNot("Dirac, Synchronisation lost");
    Synched=false;
    return Synchronize();
}
//---------------------------------------------------------------------------
bool File_Wvpk::Header_Begin()
{
    //Specific cases
    if (FromMKV)
        return true;
        
    if (!File__Tags_Helper::Header_Begin())
        return false;

    //Must have enough buffer for having header
    if (Buffer_Offset+4>Buffer_Size)
        return false;

    //Quick test of synchro
    if (Synched && CC4(Buffer+Buffer_Offset)!=CC4("wvpk"))
    {
        Trusted_IsNot("WavPack, Synchronisation lost");
        Synched=false;
    }

    //Synchro
    if (!Synched && !Synchronize())
        return false;

    return true;
}
Exemple #12
0
//---------------------------------------------------------------------------
void CTerminalRobotTyper::HandleTicketStub(){
	//向服务器后台提交修改本张票的打印状态,非本地文件出票,上传后台
	Ticket *currentTicket =(Ticket *)terminal->currentRequest;
	if (currentTicket->fileData){
		//发票任务需要等待一会,等终端机复位或者界面切换,也就是下边的代码执行完
		controller->fileDataDealer->NotifyPrint(terminal);
	}else{
		bool success =terminal->connection->ReplyStub(terminal->currentStub);
		if (!success) {
			controller->AddErrorMessage("终端" +terminal->xmlConfig->TerminalID +"已正常出票,但向后台提交票根时网络错误,票号:" +IntToStr(currentTicket->id) +",请注意出票是否正常。");
			terminal->connection->DisConnect();     //等待下次重新发过来,从票根文件中上传吧
		}
	}
	//统计数据更新,包括在线的和本地的
	terminal->monitor->ticketCount ++;
	terminal->monitor->ticketMoney +=currentTicket->amount;
	//切换当前与上一注记录
	terminal->lastStake =terminal->currentStake;	//默认切换
	//看打印完后的界面,是否自动转到另一投注方式的起始位置,如果是的话就自动转过去
	if (terminal->currentStake->HasAttribute("FinishedNode") && terminal->currentStake->FinishedNode!="") {
		terminal->lastStake =terminal->findStakeByNode(terminal->currentStake->FinishedNode);
	}
	//往下挪一行
	Synchronize(& terminal->panel->GridInsertNewDataLine);
}
//---------------------------------------------------------------------------
bool File_Dts::Header_Begin()
{
    //Must have enough buffer for having header
    if (Buffer_Offset+4>Buffer_Size)
        return false;

    //DTS-HD: Saving offset
    size_t DTS_HD_Offset=Buffer_Offset;

    //Quick test of synchro
    if (Synched && CC4(Buffer+Buffer_Offset)!=SyncCode)
    {
        Info("DTS, Synchronisation lost"); //Should not //TODO: find a better way to detect DTS
        Synched=false;
    }

    //Synchro
    if (!Synched && !Synchronize())
        return false;

    //DTS-HD: Saving difference
    if (Buffer_Offset-DTS_HD_Offset && Frame_Count>0)
        DTS_HD_Unknown_Size=Buffer_Offset-DTS_HD_Offset;

    //All should be OK...
    return true;
}
Exemple #14
0
//---------------------------------------------------------------------------
void __fastcall TPS2_REC::Execute()
{
   //---- Place thread code here ----
   while(!Terminated)
   {
      Synchronize(Show_ASCII);
   }
}
void TProgressThread::Result(int res)
{
 ShowMessage(AnsiString(res));
 while(res<=count){
                                 summary=(res*100)/count;
                                 Synchronize(&TLabelProcess);
        }
}
Exemple #16
0
    virtual void Work()
    {
        // Open a database
        GetViewerMethods()->InvertBackgroundColor();
        GetViewerMethods()->OpenDatabase("/usr/gapps/visit/data/noise.silo");
        Synchronize();

        // Create a plot and draw it.
        int plotType = PlotIndex("Pseudocolor");
        if(plotType != INVALID_PLUGIN_INDEX)
        {
            debug1 << "Plot type = " << plotType << endl;
            GetViewerMethods()->AddPlot(plotType, "hardyglobal");
      
            int threeSlice = OperatorIndex("ThreeSlice");
            if(threeSlice != INVALID_PLUGIN_INDEX)
                GetViewerMethods()->AddOperator(threeSlice);
            GetViewerMethods()->DrawPlots();
        }
        Synchronize();

        // Save an image.
        GetViewerMethods()->SaveWindow();

        // Set some pseudocolor plot attributes using the base class'
        // SetValue methods.
        AttributeSubject *pcAtts = GetViewerState()->GetPlotAttributes(plotType);
        if(pcAtts != 0)
        {
            pcAtts->SetValue("min", 1.5);
            pcAtts->SetValue("minFlag", true);
            pcAtts->SetValue("max", 4.5);
            pcAtts->SetValue("maxFlag", true);
            pcAtts->SetValue("colorTableName", "calewhite");
            pcAtts->Notify();
            GetViewerMethods()->SetPlotOptions(plotType);
        }

        // Save an image.
        GetViewerMethods()->SaveWindow();

        // Enter an event loop so the program keeps running and we can
        // interact with the viewer.
        EventLoop();
    }
Exemple #17
0
// ---------------------------------------------------------------------------
void __fastcall chart::Execute() {

	for (int i = 1; i < MainForm->Grid1->RowCount - 1; i++) {
		gph = MainForm->Grid1->Cells[0][i];
		gph2 = MainForm->Grid1->Cells[1][i];
		MainForm->Series1->AddXY(i, gph2.ToDouble(), gph);
	}
	Synchronize(&Update1);
}
Exemple #18
0
//---------------------------------------------------------------------------
//! @return : 処理を継続するかどうか
//! @retval 0 : 終了
//! @retval > 0 : 継続
//! @retval < 0 : ブレーク
int __fastcall DebuggeeCheckThread::HandleDebugEvent( DEBUG_EVENT& debug )
{
    debug_continue_status_ = DBG_CONTINUE;
    switch(debug.dwDebugEventCode) {
    case OUTPUT_DEBUG_STRING_EVENT:	// デバッグ文字列を受信した
        return HandleDebugString( debug );
    case CREATE_PROCESS_DEBUG_EVENT:// プロセスを生成した
//			debug.u.CreateProcessInfo 詳細は未対応
        debug_string_ = AnsiString("プロセスが生成されました。");
        Synchronize(&SetDebugString);
        break;
    case CREATE_THREAD_DEBUG_EVENT:	// スレッドを生成した
        debug_string_ = AnsiString("スレッド ( 0x")
                        + AnsiString::IntToHex( debug.dwThreadId, 8 )
                        + AnsiString(" ) がアドレス ")
                        + AnsiString::IntToHex( (int)debug.u.CreateThread.lpStartAddress, 8 )
                        + AnsiString(" で開始されました。");
        Synchronize(&SetDebugString);
        break;
    case EXIT_THREAD_DEBUG_EVENT:	// スレッドが終了した
        debug_string_ = AnsiString("スレッド ( 0x")
                        + AnsiString::IntToHex( debug.dwThreadId, 8 )
                        + AnsiString(") はコード ")
                        + AnsiString::IntToHex( debug.u.ExitThread.dwExitCode, 8 )
                        + AnsiString(" で終了しました。");
        Synchronize(&SetDebugString);
        break;
    case LOAD_DLL_DEBUG_EVENT:		// DLLをロードした
        return HandleDllLoad( debug );
    case UNLOAD_DLL_DEBUG_EVENT:	// DLLをアンロードした
        return HandleDllUnload( debug );
    case EXCEPTION_DEBUG_EVENT:		// 例外が発生した
        return HandleDebugException( debug );
    case RIP_EVENT:					// RIPイベント
        break;
    case EXIT_PROCESS_DEBUG_EVENT:	// プロセスが終了した
        debug_string_ = AnsiString("プログラムはコード 0x")
                        + AnsiString::IntToHex( debug.u.ExitProcess.dwExitCode, 8 )
                        + AnsiString(" で終了しました。");
        Synchronize(&SetDebugString);
        return 0;
    }
    return 1;
}
//---------------------------------------------------------------------------
void __fastcall TAutoMeasureThread::Execute()
{
//   WaitEvent=CreateEventA(NULL, true, false, NULL);

   n=1;
   ResetEvent(CaptureDone);
   Synchronize(Draw);
   WaitForSingleObject(CaptureDone, INFINITE);
   n=2;
   ResetEvent(AcfDone);
   Synchronize(Draw);
   WaitForSingleObject(AcfDone, INFINITE);
   n=3;
   Synchronize(Draw);

//   CloseHandle(WaitEvent);

	//---- Place thread code here ----
}
Exemple #20
0
//---------------------------------------------------------------------------
int __fastcall DebuggeeCheckThread::HandleDllUnload( DEBUG_EVENT& debug )
{
    std::string dllname;
    if( GetDllInfo( debug.u.UnloadDll.lpBaseOfDll, dllname ) ) {
        debug_string_ = AnsiString( dllname.c_str() );
        debug_string_ += AnsiString( "がアンロードされました" );
        Synchronize(&SetDebugString);
    }
    return 1;
}
Exemple #21
0
//---------------------------------------------------------------------------
int CTerminalRobotTyper::SendTicketKeys(){
    int keysCount =0;
	//把当前待出票放入列表第一行
    Ticket *currentTicket =(Ticket *)terminal->currentRequest;
	AnsiString id =IntToStr(currentTicket->id);
	AnsiString tickstr =currentTicket->number;
	int times =currentTicket->multiple;
	AnsiString gameAdapter =currentTicket->playType +"-" +currentTicket->betType; 	//与其他层次关系不同,不用:而用-
	AnsiString echoName =terminal->GetStakeNameById(currentTicket->gameId, gameAdapter);
	if (echoName ==""){     //终端与游戏的配置问题
		terminal->daemon->suspendTimestamp =GetTickCount();
		controller->AddErrorMessage("终端" +terminal->xmlConfig->TerminalID +"不支持此类游戏出票,请检查配置文件!稍后终端会自动复位。");
        return 0;
	}
	//设置并刷新终端监控信息
    TStringList *line =new TStringList();
	line->Add(id);
	line->Add(tickstr);
	line->Add(IntToStr(times));
	line->Add(gameAdapter);
	line->Add(echoName);
	line->Add(IntToStr(currentTicket->icount));
	line->Add(IntToStr(currentTicket->amount));
    terminal->panel->topLineContent =line;
    Synchronize(&terminal->panel->FillTopLineContent);
    delete line;
	//查找当前票节点
	terminal->currentStake =terminal->findStakeById(currentTicket->gameId, gameAdapter);
	//按照规则,重试出票请求会发给同一台终端,如果本地有文件,直接返回文件票根
	AnsiString binFile =controller->config->BinFileDir +"ticket\\" +id +".bin";
	if (FileExists(binFile)){
		LoadStubFromFile(binFile);
		return 0;		//直接返回,不用等待按键时间,但需要等待出票超时被处理
	}
	//计算两个不同类型的彩票,中间界面跳转需要的按键,并打印跳转
	AnsiString jumpStr =terminal->getJumpInnerCodeString(terminal->lastStake, terminal->currentStake);
	keysCount +=terminal->box->TypeInnerString(jumpStr +"~");
	//调用动态库函数,生成打印号码的按键序列,不包括最后的确认!
	char keys[256] ={0};
	terminal->GeneralTicketKeyStr((currentTicket->gameId +"-" +gameAdapter), tickstr, times, keys);
	keysCount +=terminal->box->TypeInnerString(AnsiString(keys));
	//超出单票的最大金额的提示确认,可能未设置
	if (terminal->xmlConfig->LotteryPos->HasAttribute("NeedConfirmAmount")) {
		if (currentTicket->amount >=terminal->xmlConfig->LotteryPos->NeedConfirmAmount && currentTicket->amount < terminal->xmlConfig->LotteryPos->NeedPasswordAmount) {
			keysCount +=terminal->box->TypeInnerString(terminal->xmlConfig->Keyboard->PrintConfirm);  //一般为200,再次确认
		}else if (currentTicket->amount >=terminal->xmlConfig->LotteryPos->NeedPasswordAmount) {
			keysCount +=terminal->box->TypeInnerString(terminal->xmlConfig->Keyboard->PrintConfirm);
			keysCount +=terminal->box->TypeInnerString("~~~~~~");            //密码界面较慢
			keysCount +=terminal->box->TypeInnerString(terminal->xmlConfig->LotteryPos->SalesPassword);         //金额超出500输入密码确认出票
		}
	}
	//确认出票键
	keysCount +=terminal->box->TypeInnerString(terminal->xmlConfig->Keyboard->PrintConfirm);
	return keysCount;
}
Exemple #22
0
//---------------------------------------------------------------------------
void __fastcall ProcesoThresholdingColorNegro::proceso(AnsiString archivo,AnsiString ArchRes,int Xini,int Xfin,int Yini,int Yfin,int reg)
{
  Synchronize(cargarImagen);
  FILE *streamRes;
  streamRes = fopen (ArchRes.c_str(),"a");
  if(streamRes==NULL){fclose(streamRes);}
  rewind(streamRes);
  int contPixel=0;
  xpos=0;
  ypos=0;
  valorPixel=0;
  int Red,Green,Blue;
  yFinal=0;
  xFinal=0;
  Synchronize(obtenerAltura);
  Synchronize(obtenerAncho);
  for (ypos=0; ypos<yFinal; ypos++)
  {
    for (xpos=0; xpos<xFinal; xpos++)
    {
      Synchronize(obtenerPixel);
      if(valorPixel<=7100000) //dato
      {
        contPixel++;
      }
      else
      {
//        Synchronize(pintarBlanco);
      }

    }
  }
//  double factor=(xFinal*yFinal/1000000.0);
//  double coef=0.0007*pow(factor,-0.9301);
//  double area=contPixel*coef;
  double area=0.013308565*double(contPixel); // bastidor entero
  double lai=area/((Xfin-Xini)*(Yfin-Yini));
  fprintf(streamRes,"%i  %f      %s\n",contPixel,float(lai),(ExtractFileName(archivoOrig)).c_str());
  fclose(streamRes);
  picture->TotalPixel[reg]=contPixel;
  picture->LAI[reg]=lai;
}
Exemple #23
0
//---------------------------------------------------------------------------
void CTerminalRobotTyper::HandleStub(){
	//由于网络或终端等错误状态,造成线程死等待,需要状态重置,不处理后半程
	if (terminal->needReset) return;
	if (terminal->status ==WorkStatus::PRINT) HandleTicketStub();
	else if (terminal->status ==WorkStatus::AWARD) HandleBonusStub();
	else if (terminal->status ==WorkStatus::REPORT) HandleQueryStub();
    //第一张订单正常处理后,重置按键间隔参数
	if (! keyIntervalRestored) Synchronize(&RestoreKeyInterval);
	//声音OK
	if (terminal->panel->CheckBoxSound->Checked) controller->mediaSupport->SoundOK();
}
void	CACFPreferences::DeleteValue(CFStringRef inKey, bool inCurrentUser, bool inCurrentHost, bool inSynchronize)
{
	CFStringRef theUser = inCurrentUser ? kCFPreferencesCurrentUser : kCFPreferencesAnyUser;
	CFStringRef theHost = inCurrentHost ? kCFPreferencesCurrentHost : kCFPreferencesAnyHost;
	CFPreferencesSetValue(inKey, NULL, kCFPreferencesAnyApplication, theUser, theHost);
	
	if(inSynchronize)
	{
		Synchronize(theUser, inCurrentHost, true);
	}
}
Exemple #25
0
  void RenderModule::Render(SceneView* view)
  {
    Setup(view);
    Synchronize(view);

    if (m_flags.test(eRenderRequired))
    {
      DoRender(view);
      m_flags.reset(eRenderRequired);
    }
  }
Exemple #26
0
//---------------------------------------------------------------------------
void CTerminalRobotTyper::HandleBonusStub(){
	Bonus *bonus =(Bonus *)terminal->currentRequest;
	//上传后台兑奖回执单
	if (!terminal->connection->ReplyStub(terminal->currentStub)){
		controller->AddErrorMessage("终端" +terminal->xmlConfig->TerminalID +"已正常兑奖但回执单未成功上传,票号:" +IntToStr(bonus->id) +",请注意兑奖是否正常。");
		terminal->connection->DisConnect();     //等待下次重新发过来,从票根文件中上传吧
	}
	//修改监控累计数据
	terminal->monitor->prizeCount ++;
	terminal->monitor->prizeMoney +=bonus->bonus;
	//往下挪一行
	Synchronize(& terminal->panel->GridInsertNewDataLine);
}
CFPropertyListRef	CACFPreferences::CopyValue(CFStringRef inKey, bool inCurrentUser, bool inCurrentHost)
{
	//	synchronize to make sure that what's in memory matches what's on disk
	Synchronize(inCurrentUser, inCurrentHost, false);
	
	CFPropertyListRef theAnswer = NULL;
	CFStringRef theUser = inCurrentUser ? kCFPreferencesCurrentUser : kCFPreferencesAnyUser;
	CFStringRef theHost = inCurrentHost ? kCFPreferencesCurrentHost : kCFPreferencesAnyHost;
	
	theAnswer = CFPreferencesCopyValue(inKey, kCFPreferencesAnyApplication, theUser, theHost);
	
	return theAnswer;
}
Exemple #28
0
//---------------------------------------------------------------------------
bool CTerminalRobotTyper::SetCurrentRequest(Request *request){
	if (terminal->status !=WorkStatus::IDLE) return false;
	terminal->currentRequest =request;
	if (request->reqType ==RequestTypeEnum::TICKET) {
		terminal->status =WorkStatus::PRINT;
	}else if (request->reqType ==RequestTypeEnum::BONUS) {
		terminal->status =WorkStatus::AWARD;
	}else if (request->reqType ==RequestTypeEnum::QUERY) {
		terminal->status =WorkStatus::REPORT;
	}
	Synchronize(& terminal->panel->RequestChangePanelUI);
	Suspended =false;
	return true;
}
Exemple #29
0
//---------------------------------------------------------------------------
void __fastcall TWaitDataThread::Execute()
{
  __TRY
  HANDLE hMapFile = NULL;
  LPVOID lpMapAddress = NULL;

  while (!hMapFile) {
    hMapFile = OpenFileMapping(FILE_MAP_READ, // read permission
      FALSE,                         // Do not inherit the name
      FILE_MAP_OBJ_TEXT);            // of the mapping object.
    }
  /*
  if (!hMapFile)
  {
    LastErrorMessage("Could not open file mapping object.");
    throw Exception("hMapFile == NULL");
  }
  */

  lpMapAddress = MapViewOfFile(hMapFile, // handle to mapping object
    FILE_MAP_READ,                     // read permission
    0,                                 // max. object size
    0,                                 // size of hFile
    0);                                // map entire file

  if (!lpMapAddress)
  {
    //ErrorHandler("Could not map view of file.");
    LastErrorMessage("Could not map view of file.");
    throw Exception("lpMapAddress == NULL");
  }

  FirstByteOfData = (TInOutData*)lpMapAddress;

  long i = 0;
  while (!Terminated) {
    if (FirstByteOfData->lNum != i) {
      ::EnterCriticalSection(&m_AccessCriticalSection);
      i = FirstByteOfData->lNum;
      _size = FirstByteOfData->lSize;
      memcpy( _data, FirstByteOfData->ch, _size);
      ::LeaveCriticalSection(&m_AccessCriticalSection);
      Synchronize(UpdateCaption);
      }
    }
  __CATCH
}
Exemple #30
0
Fichier : topo.c Projet : rolk/ug
void DDD_DisplayTopo (void)
{
  int p, i;
  char buf[20];

  DDD_SyncAll();

  if (me==0)
  {
    sprintf(cBuffer, "      ");
    for(p=0; p<procs; p++)
    {
      sprintf(buf, "%2d", p);
      strcat(cBuffer, buf);
    }
    strcat(cBuffer,"\n");
    DDD_PrintLine(cBuffer); fflush(stdout);
  }

  for(p=0; p<procs; p++)
  {
    Synchronize();
    if (p==me)
    {
      sprintf(cBuffer, "%4d: ", me);
      for(i=0; i<procs; i++)
      {
        if (theTopology[i]!=NULL)
        {
          strcat(cBuffer,"<>");
        }
        else
        {
          if (i==p)
            strcat(cBuffer,"--");
          else
            strcat(cBuffer,"  ");
        }
      }
      strcat(cBuffer,"\n");
      DDD_PrintLine(cBuffer);
      DDD_Flush();
    }
  }

  DDD_SyncAll();
}