/** Main JWM event loop. */ void EventLoop(void) { XEvent event; TimeType start; /* Loop processing events until it's time to exit. */ while(JLIKELY(!shouldExit)) { if(JLIKELY(WaitForEvent(&event))) { ProcessEvent(&event); } } /* Process events one last time. */ GetCurrentTime(&start); for(;;) { if(JXPending(display) == 0) { if(!IsSwallowPending()) { break; } else { TimeType now; GetCurrentTime(&now); if(GetTimeDifference(&start, &now) > RESTART_DELAY) { break; } } } if(WaitForEvent(&event)) { ProcessEvent(&event); } } }
void UT_CIceConnectionHandler::UT_CNATFWConnectionHandler_SetSendingStatusLL() { TInetAddr addr( KRemoteAddr, KRemotePort ); addr.SetFamily( KAfInet ); if ( TIceTestUtils::AllocTestEnabled() ) { iConnectionHandler->SetSendingStateL( *iLocalCandidates[0], EStreamingStateActive, addr ); } else { TInt count = iPluginContainer->Count(); for ( TInt i( 0 ); i < count; i++ ) { iConnectionHandler->SetSendingStateL( *iLocalCandidates[i], EStreamingStateActive, addr ); WaitForEvent( MIceNatPluginEventObs::ESendingActivated ); EUNIT_ASSERT( iEventStreamId == iStreamId && KErrNone == iEventErrCode ); iConnectionHandler->SetSendingStateL( *iLocalCandidates[i], EStreamingStatePassive, addr ); WaitForEvent( MIceNatPluginEventObs::ESendingDeactivated ); EUNIT_ASSERT( iEventStreamId == iStreamId && KErrNone == iEventErrCode ); } } }
// 发送HTTP请求消息体数据函数 BOOL CHttpClient::SendReqBodyData(const CHAR * lpBuf, DWORD dwLen, DWORD& dwSendLen) { BOOL bRet; if (NULL == m_hRequest || NULL == lpBuf || dwLen <= 0) return FALSE; dwSendLen = 0; bRet = ::InternetWriteFile(m_hRequest, lpBuf, dwLen, &dwSendLen); if (!bRet) { if (::GetLastError() != ERROR_IO_PENDING) return FALSE; bRet = WaitForEvent(REQUEST_COMPLETE_EVENT, INFINITE); if (!bRet) return FALSE; } else { bRet = WaitForEvent(USER_CANCEL_EVENT, 0); if (!bRet) return FALSE; } return TRUE; }
void UT_CIceHostResolver::UT_CICEHostResolver_ConnectServerLL() { RSocketServ dummyServer; TName dummyName; iResolver->ConnectServerL( dummyServer, dummyName ); WaitForEvent( EServerConnected ); }
bool ImageUpdate() { if( WaitForEvent(MOUNT, &g_objUsbSta.UDisk[0], 15000)==0 ) { char const szUpdateFile[32] = "image.bin"; char diskPathUpfile[128] = {0}; //升级路径+升级文件 sprintf(diskPathUpfile, "/mnt/%s/%s", UDISK_UP_PATH, szUpdateFile); #if VEHICLE_TYPE == VEHICLE_M if( G_ImageUpdate(diskPathUpfile, 1)==true ) #endif #if VEHICLE_TYPE == VEHICLE_V8 || VEHICLE_TYPE == VEHICLE_M2 if( G_ImageUpdate(diskPathUpfile, 0)==true ) #endif { PRTMSG(MSG_DBG, "%s update succ\n", szUpdateFile); DelErrLog(); // 升级成功后程序从分区5启动 DelVerFile(); // 升级成功后修改系统版本号 return true; } } return false; }
bool ExeUpdate() { if( WaitForEvent(MOUNT, &g_objUsbSta.UDisk[0], 15000)==0 ) { char const szUpdateFile[32] = "exe.bin"; char diskPathUpfile[128] = {0}; //升级路径+升级文件 sprintf(diskPathUpfile, "/mnt/%s/%s", UDISK_UP_PATH, szUpdateFile); // 将升级文件exe.bin复制到part3的下载目录下,以作为升级备份 if( AppIntact(diskPathUpfile) == false || 0 != system("cp -f /mnt/UDisk/part1/exe.bin /mnt/Flash/part3/Down/exe.bin") ) { PRTMSG(MSG_DBG, "cp exe.bin to part3 fail!\n"); return false; } #if VEHICLE_TYPE == VEHICLE_M if( G_ExeUpdate(diskPathUpfile, 1) == true ) #endif #if VEHICLE_TYPE == VEHICLE_V8 || VEHICLE_TYPE == VEHICLE_M2 if( G_ExeUpdate(diskPathUpfile, 0) == true ) #endif { PRTMSG(MSG_DBG, "soft update succ\n"); DelErrLog(); // 升级成功后程序从分区5启动 return true; } } return false; }
void confirmComplete(double x1, double y1, double x2, double y2)//确认完成按钮函数 { MovePen(x1,y1); DrawLine(x2-x1,0); DrawLine(0,y2-y1); DrawLine(x1-x2,0); DrawLine(0,y1-y2); double distance1; double distance2; double X,Y; SetPenColor(RED); distance1=(x2-x1-GetStringWidth("输入完成"))/2; distance2=(y1-y2-GetStringWidth("输"))/2; MovePen(x1+distance1,y1-distance2); DrawString("输入完成"); SetPenColor(BLACK); while(1) { while(!(WaitForEvent()==KEYDOWN)){} if(GetStruckKey() == VK_LBUTTON) { X = GetMouseX(); Y = GetMouseY(); if((X >= x1 && X <= x2) && (Y >= y2 && Y <= y1))//鼠标点击在所规定的范围内 { EatEgg();//吃掉完成键和信息输入框的蛋 break; } } } }
bool xorg::testing::XServer::WaitForEventOfType(::Display *display, int type, int extension, int evtype, time_t timeout) { while (WaitForEvent(display, timeout)) { XEvent event; if (!XPeekEvent(display, &event)) throw std::runtime_error("Failed to peek X event"); if (event.type != type) { if (XNextEvent(display, &event) != Success) throw std::runtime_error("Failed to remove X event"); continue; } if (event.type != GenericEvent || extension == -1) return true; XGenericEvent *generic_event = reinterpret_cast<XGenericEvent*>(&event); if (generic_event->extension != extension) { if (XNextEvent(display, &event) != Success) throw std::runtime_error("Failed to remove X event"); continue; } if (evtype == -1 || generic_event->evtype == evtype) return true; if (XNextEvent(display, &event) != Success) throw std::runtime_error("Failed to remove X event"); } return false; }
/** Select a window for performing an action. */ void ChooseWindow(const MenuAction *action) { XEvent event; ClientNode *np; GrabMouseForChoose(); for(;;) { WaitForEvent(&event); if(event.type == ButtonPress) { if(event.xbutton.button == Button1) { np = FindClient(event.xbutton.subwindow); if(np) { client = np; RunWindowCommand(action); } } break; } else if(event.type == KeyPress) { break; } } JXUngrabPointer(display, CurrentTime); }
void UT_CIceConnectionHandler::CreateCandidatePairsL() { TIceNatPluginContainerIter iterator = TIceNatPluginContainerIter( *iPluginContainer ); while ( !iterator.IsDone() ) { CNATFWPluginApi* item = iterator++; item->FetchCandidateL( iStreamId, 0, KAfInet ); WaitForEvent( MIceNatPluginEventObs::EFetchingCompleted ); } CNATFWCandidate* remoteCandidate = CNATFWCandidate::NewLC(); TInetAddr remoteAddr( INET_ADDR( 192, 168, 0, 1 ), 5000 ); remoteCandidate->SetTransportAddrL( remoteAddr ); for ( TInt i = 0; i < iLocalCandidates.Count(); ++i ) { CNATFWCandidatePair* pair = CNATFWCandidatePair::NewLC( *iLocalCandidates[i], *remoteCandidate ); iPairs.AppendL( pair ); CleanupStack::Pop( pair ); } CleanupStack::PopAndDestroy( remoteCandidate ); }
void UT_CIceHostResolver::UT_CICEHostResolver_FetchCandidateLL( ) { if ( TIceTestUtils::AllocTestEnabled() ) { iResolver->FetchCandidateL( KTestStreamIdRtp1, 0, KAfInet ); iResolver->FetchCandidateL( KTestStreamIdRtcp1, 0, KAfInet ); WaitForEvent( EFetchingCompleted ); WaitForEvent( EFetchingCompleted ); } else { EUNIT_ASSERT_NO_LEAVE( iResolver->FetchCandidateL( KTestStreamIdRtp1, 0, KAfInet ) ); EUNIT_ASSERT_NO_LEAVE( iResolver->FetchCandidateL( KTestStreamIdRtcp1, 0, KAfInet ) ); WaitForEvent( EFetchingCompleted ); WaitForEvent( EFetchingCompleted ); } }
// ***************************************************************************** void loop() { WaitForEvent(0); NMEA2000.ParseMessages(); N2kDataToNMEA0183.Update(); // We need to clear output streams input data to avoid them to get stuck. FlushStreamInput(NMEA0183_Out_Stream); #ifdef N2kForward_Stream FlushStreamInput(N2kForward_Stream); #endif }
int CKTIrdMod::Release() { if( m_pthreadRecv ) { m_bEscRecv = true; usleep(100000); if( WaitForEvent(ThreadExit, &m_pthreadRecv, 3000) ) { pthread_cancel(m_pthreadRecv); usleep(100000); } m_pthreadRecv = 0; } m_bEscRecv = false; if( m_pthreadWork ) { m_bEscWork = true; usleep(100000); if( WaitForEvent(ThreadExit, &m_pthreadWork, 3000) ) { pthread_cancel(m_pthreadWork); usleep(100000); } m_pthreadWork = 0; } m_bEscWork = false; ComClose(); return 0; }
// 获取HTTP响应消息体数据函数 BOOL CHttpClient::GetRespBodyData(CHAR * lpBuf, DWORD dwLen, DWORD& dwRecvLen) { INTERNET_BUFFERSA stInetBuf = {0}; BOOL bRet; if (NULL == m_hRequest || NULL == lpBuf || dwLen <= 0) return FALSE; dwRecvLen = 0; memset(lpBuf, 0, dwLen); stInetBuf.dwStructSize = sizeof(stInetBuf); stInetBuf.lpvBuffer = lpBuf; stInetBuf.dwBufferLength = dwLen; bRet = ::InternetReadFileExA(m_hRequest, &stInetBuf, 0, (DWORD_PTR)this); if (!bRet) { if (::GetLastError() != ERROR_IO_PENDING) return FALSE; bRet = WaitForEvent(REQUEST_COMPLETE_EVENT, INFINITE); if (!bRet) return FALSE; } else { bRet = WaitForEvent(USER_CANCEL_EVENT, 0); if (!bRet) return FALSE; } dwRecvLen = stInetBuf.dwBufferLength; return TRUE; }
bool SysUpdate() { if( WaitForEvent(MOUNT, &g_objUsbSta.UDisk[0], 15000)==0 ) { int iUpdateFileCnt = 0; int i; char szMtdPath[][32] = {BOOT_PART, KERN_PART, ROOT_PART, UPD_PART, APP_PART}; char const szUpdateFile[][32] = { "boot.bin", "kernel.bin", "root.bin", "update.bin", "app.bin"}; char diskPathUpfile[128] = {0}; //升级路径+升级文件 for(i=0; i<(sizeof(szUpdateFile)/sizeof(szUpdateFile[0])); i++) { sprintf(diskPathUpfile, "/mnt/%s/%s", UDISK_UP_PATH, szUpdateFile[i]); if( access(diskPathUpfile, F_OK)==0 ) { iUpdateFileCnt++; #if VEHICLE_TYPE == VEHICLE_M if( G_SysUpdate(diskPathUpfile, szMtdPath[i], 1)!=0 ) #endif #if VEHICLE_TYPE == VEHICLE_V8 || VEHICLE_TYPE == VEHICLE_M2 if( G_SysUpdate(diskPathUpfile, szMtdPath[i], 0)!=0 ) #endif { PRTMSG(MSG_DBG, "%s update fail\n", szUpdateFile[i]); return false; } if(i == 0 || i == 1 || i == 2) DelVerFile(); // 升级成功后修改系统版本号 else if(i == 3 || i == 4) DelErrLog(); // 升级成功后程序从分区5启动 } } if( iUpdateFileCnt!=0 ) { PRTMSG(MSG_DBG, "system update succ\n"); return true; } } return false; }
bool AppUpdate() { if( WaitForEvent(MOUNT, &g_objUsbSta.UDisk[0], 15000)==0 ) { int iUpdateFileCnt = 0; int i; char const szUpdateFile[][32] = {"QianExe", "ComuExe", "SockServExe", "IOExe", "UpdateExe", "DvrExe", "libComuServ.so"}; char diskPathUpfile[128] = {0}; //升级路径+升级文件 char flashPathUpfile[128] = {0}; for(i=0; i<(sizeof(szUpdateFile)/sizeof(szUpdateFile[0])); i++) { sprintf(diskPathUpfile, "/mnt/%s/%s", UDISK_UP_PATH, szUpdateFile[i]); sprintf(flashPathUpfile, "/mnt/Flash/part5/%s", szUpdateFile[i]); if( access(diskPathUpfile, F_OK)==0 ) { iUpdateFileCnt++; #if VEHICLE_TYPE == VEHICLE_M if( G_AppUpdate(diskPathUpfile, flashPathUpfile, 1)!=0 ) #endif #if VEHICLE_TYPE == VEHICLE_V8 || VEHICLE_TYPE == VEHICLE_M2 if( G_AppUpdate(diskPathUpfile, flashPathUpfile, 0)!=0 ) #endif { PRTMSG(MSG_DBG, "%s update fail\n", szUpdateFile[i]); return false; } } } if( iUpdateFileCnt!=0 ) { PRTMSG(MSG_DBG, "soft update succ\n"); DelErrLog(); // 升级成功后程序从分区5启动 return true; } } return false; }
// Control flow of evolution void GaMultithreadingAlgorithm::ControlFlow() { while( 1 ) { // now parameters and state cannot be changed BlockParameterChanges(); BlockStateChange(); int count = ( (const GaMultithreadingAlgorithmParams&) GetAlgorithmParameters() ).GetNumberOfWorkers(); if( _state == GAS_RUNNING ) // execute control step before workers BeforeWorkers(); // release working threads _workersThreadOut = _workersThreadIn = count; UnlockSemaphore( _workerForkSync, count ); // wait for working threads to finish the job WaitForEvent( _controlSync ); // still running? if( _state != GAS_RUNNING ) { // stop the threads // now it safe to change parameters and state ReleaseParameterChanages(); ReleaseStateChange(); break; } // execute control step after workers AfterWorkers(); // stop algorithm is criteria is reached CheckStopCriteria(); // now it safe to change parameters and state ReleaseStateChange(); ReleaseParameterChanages(); } }
// 结束发送HTTP请求函数 BOOL CHttpClient::EndSendRequest() { BOOL bRet; if (NULL == m_hRequest) return FALSE; bRet = ::HttpEndRequest(m_hRequest, NULL, HSR_INITIATE, (DWORD_PTR)this); if (!bRet) { if (::GetLastError() != ERROR_IO_PENDING) return FALSE; bRet = WaitForEvent(REQUEST_COMPLETE_EVENT, INFINITE); if (!bRet) return FALSE; } return TRUE; }
// 发送HTTP请求函数 BOOL CHttpClient::SendRequest(const CHAR * lpData, DWORD dwLen) { BOOL bRet; if (NULL == m_hRequest) return FALSE; bRet = ::HttpSendRequest(m_hRequest, NULL, 0, (LPVOID)lpData, dwLen); if (!bRet) { if (::GetLastError() != ERROR_IO_PENDING) return FALSE; } bRet = WaitForEvent(REQUEST_COMPLETE_EVENT, INFINITE); if (!bRet) return FALSE; else return TRUE; }
void FixLog::run() { bool qempty; AutoLocker autolock(qLock_); do{ autolock.lockRead(); qempty = queue_.empty(); if( qempty ) { autolock.unlock(); if( !WaitForEvent(qEvent_) || (online_ == -1) ) break; } else { dequeue(autolock); } } while(online_ == 1); QThread::exec(); }
int send_byte(void* unused, uchar ch, unsigned timeout) { uchar buf[2] = { TELNET_IAC, TELNET_IAC }; unsigned len=1; DWORD result; if(telnet && ch==TELNET_IAC) /* escape IAC char */ len=2; else buf[0]=ch; if(RingBufFree(&outbuf)<len) { fprintf(statfp,"FLOW"); flows++; result=WaitForEvent(outbuf_empty,timeout*1000); fprintf(statfp,"\b\b\b\b \b\b\b\b"); if(result!=WAIT_OBJECT_0) { fprintf(statfp ,"\n!TIMEOUT (%d) waiting for output buffer to flush (%u seconds, %u bytes)\n" ,result, timeout, RingBufFull(&outbuf)); newline=TRUE; if(RingBufFree(&outbuf)<len) return(-1); } } RingBufWrite(&outbuf,buf,len); #if !defined(RINGBUF_EVENT) ResetEvent(outbuf_empty); #endif #if 0 if(debug_tx) lprintf(LOG_DEBUG,"TX: %s",chr(ch)); #endif return(0); }
// 开始发送HTTP请求函数 BOOL CHttpClient::SendRequestEx(DWORD dwLen) { INTERNET_BUFFERS stInetBuf = {0}; BOOL bRet; if (NULL == m_hRequest) return FALSE; stInetBuf.dwStructSize = sizeof(INTERNET_BUFFERS); stInetBuf.dwBufferTotal = dwLen; bRet = ::HttpSendRequestEx(m_hRequest, &stInetBuf, NULL, 0, (DWORD_PTR)this); if (!bRet) { if (::GetLastError() != ERROR_IO_PENDING) return FALSE; bRet = WaitForEvent(REQUEST_COMPLETE_EVENT, INFINITE); if (!bRet) return FALSE; } return TRUE; }
double showDeleteInput(double x1, double y1, double x2, double y2, double distance,char* string,int k)//界面输入呈现函数 { char strForInput[200]={'\0'};//储存输入字符的字符数组 char spaceStrForInput[200]={'\0'};//用于清空输入的空白字符数组 int cntForInput=0;//数组参数 double save;//存输入字符串的浮点型 double bytes=GetStringWidth("火"); int j,i; double X1,Y1,X2,Y2;//储存当前框的左上角坐标和右下角坐标 double X,Y;//获取鼠标的坐标 X1=x1+distance+GetStringWidth(string);//左上X Y1=y1-(k+1)*distance-k*bytes;//左上Y X2=x1+distance+GetStringWidth(string)+50;//左下X Y2=y1-(k+2)*distance-(k+1)*bytes;//左下Y for(i=0;i<15;i++)//初始化清空字符 { spaceStrForInput[i]=' '; } while(1) { while(!(WaitForEvent()==KEYDOWN)){}//若未遇到 KEYDOWN事件(键盘输入或者鼠标点击),则什么都不做。 if(GetStruckKey() == VK_LBUTTON)//鼠标左键点击进入输入模式 { X = GetMouseX(); Y = GetMouseY(); if((X >= X1 && X <= X2) && (Y >= Y2 && Y <= Y1))//鼠标点击在所规定的范围内 { //回显用户输入,按下Esc时退出输入 while(1) { while(!(WaitForEvent() == KEYDOWN)) {}//非键盘和鼠标输入时什么都不做 strForInput[cntForInput] = GetStruckKey(); if(strForInput[cntForInput]==-67||strForInput[cntForInput]==VK_SUBTRACT)//使可以输入负号 strForInput[cntForInput]='-'; else if(strForInput[cntForInput]==VK_NUMPAD1)//小键盘输入 strForInput[cntForInput]='1'; else if(strForInput[cntForInput]==VK_NUMPAD2) strForInput[cntForInput]='2'; else if(strForInput[cntForInput]==VK_NUMPAD3) strForInput[cntForInput]='3'; else if(strForInput[cntForInput]==VK_NUMPAD4) strForInput[cntForInput]='4'; else if(strForInput[cntForInput]==VK_NUMPAD5) strForInput[cntForInput]='5'; else if(strForInput[cntForInput]==VK_NUMPAD6) strForInput[cntForInput]='6'; else if(strForInput[cntForInput]==VK_NUMPAD7) strForInput[cntForInput]='7'; else if(strForInput[cntForInput]==VK_NUMPAD8) strForInput[cntForInput]='8'; else if(strForInput[cntForInput]==VK_NUMPAD9) strForInput[cntForInput]='9'; else if(strForInput[cntForInput]==VK_NUMPAD0) strForInput[cntForInput]='0'; if( strForInput[cntForInput] == VK_ESCAPE )//当按下ESC键时退出输入模式 { break; } else { MovePen(X1,Y1); DrawString(strForInput);//显示字符串 } cntForInput++; } cntForInput = 0; save=atof(strForInput); for(j = 0; j < 200; ++j) strForInput[j] = '\0'; printf("input\n");//输入模式完成后输出input字样 } } else if(GetStruckKey() == VK_BACK)//键盘输入Backspace清除字符 { X = GetMouseX(); Y = GetMouseY(); if((X >= X1 && X <= X2) && (Y >= Y2 && Y <= Y1)) //input按钮被按下 { MovePen(X1,Y1); DrawString(spaceStrForInput); printf("clear\n");//清除完成后输出clear字样 } } if(GetStruckKey()==VK_RBUTTON)//点击鼠标中键,输入完成 { printf("complete\n"); break; } } return save; }
/** Move a client window. */ char MoveClient(ClientNode *np, int startx, int starty) { XEvent event; int oldx, oldy; int doMove; int north, south, east, west; int height; MaxFlags maxFlags; Assert(np); if(!(np->state.border & BORDER_MOVE)) { return 0; } if(np->state.status & STAT_FULLSCREEN) { return 0; } GrabMouseForMove(); RegisterCallback(0, SignalMove, NULL); np->controller = MoveController; shouldStopMove = 0; oldx = np->x; oldy = np->y; maxFlags = np->state.maxFlags; if(!(GetMouseMask() & (Button1Mask | Button2Mask))) { StopMove(np, 0, oldx, oldy, maxFlags); return 0; } GetBorderSize(&np->state, &north, &south, &east, &west); startx -= west; starty -= north; currentClient = np; atTop = atBottom = atLeft = atRight = 0; doMove = 0; for(;;) { WaitForEvent(&event); if(shouldStopMove) { np->controller = NULL; SetDefaultCursor(np->parent); UnregisterCallback(SignalMove, NULL); return doMove; } switch(event.type) { case ButtonRelease: if(event.xbutton.button == Button1 || event.xbutton.button == Button2) { StopMove(np, doMove, oldx, oldy, maxFlags); return doMove; } break; case MotionNotify: DiscardMotionEvents(&event, np->window); np->x = event.xmotion.x_root - startx; np->y = event.xmotion.y_root - starty; /* Get the move time used for desktop switching. */ if(!(atLeft | atTop | atRight | atBottom)) { if(event.xmotion.state & Mod1Mask) { moveTime.seconds = 0; moveTime.ms = 0; } else { GetCurrentTime(&moveTime); } } /* Determine if we are at a border for desktop switching. */ atLeft = atTop = atRight = atBottom = 0; if(event.xmotion.x_root == 0) { atLeft = 1; } else if(event.xmotion.x_root == rootWidth - 1) { atRight = 1; } if(event.xmotion.y_root == 0) { atTop = 1; } else if(event.xmotion.y_root == rootHeight - 1) { atBottom = 1; } if(event.xmotion.state & Mod1Mask) { /* Switch desktops immediately if alt is pressed. */ if(atLeft | atRight | atTop | atBottom) { TimeType now; GetCurrentTime(&now); UpdateDesktop(&now); } } else { /* If alt is not pressed, snap to borders. */ DoSnap(np); } if(!doMove && (abs(np->x - oldx) > MOVE_DELTA || abs(np->y - oldy) > MOVE_DELTA)) { if(np->state.maxFlags) { MaximizeClient(np, MAX_NONE); startx = np->width / 2; starty = -north / 2; MoveMouse(np->parent, startx, starty); } CreateMoveWindow(np); doMove = 1; } if(doMove) { if(settings.moveMode == MOVE_OUTLINE) { ClearOutline(); height = north + south; if(!(np->state.status & STAT_SHADED)) { height += np->height; } DrawOutline(np->x - west, np->y - north, np->width + west + east, height); } else { JXMoveWindow(display, np->parent, np->x - west, np->y - north); SendConfigureEvent(np); } UpdateMoveWindow(np); RequirePagerUpdate(); } break; default: break; } } }
/** Move a client window (keyboard or menu initiated). */ char MoveClientKeyboard(ClientNode *np) { XEvent event; int oldx, oldy; int moved; int height; int north, south, east, west; MaxFlags maxFlags; Assert(np); if(!(np->state.border & BORDER_MOVE)) { return 0; } if(np->state.status & STAT_FULLSCREEN) { return 0; } maxFlags = np->state.maxFlags; if(np->state.maxFlags != MAX_NONE) { MaximizeClient(np, MAX_NONE); } if(JUNLIKELY(JXGrabKeyboard(display, np->parent, True, GrabModeAsync, GrabModeAsync, CurrentTime))) { Debug("MoveClient: could not grab keyboard"); return 0; } GrabMouseForMove(); GetBorderSize(&np->state, &north, &south, &east, &west); oldx = np->x; oldy = np->y; RegisterCallback(0, SignalMove, NULL); np->controller = MoveController; shouldStopMove = 0; CreateMoveWindow(np); UpdateMoveWindow(np); MoveMouse(rootWindow, np->x, np->y); DiscardMotionEvents(&event, np->window); if(np->state.status & STAT_SHADED) { height = 0; } else { height = np->height; } for(;;) { WaitForEvent(&event); if(shouldStopMove) { np->controller = NULL; SetDefaultCursor(np->parent); UnregisterCallback(SignalMove, NULL); return 1; } moved = 0; if(event.type == KeyPress) { DiscardKeyEvents(&event, np->window); switch(GetKey(&event.xkey) & 0xFF) { case KEY_UP: if(np->y + height > 0) { np->y -= 10; } break; case KEY_DOWN: if(np->y < rootHeight) { np->y += 10; } break; case KEY_RIGHT: if(np->x < rootWidth) { np->x += 10; } break; case KEY_LEFT: if(np->x + np->width > 0) { np->x -= 10; } break; default: StopMove(np, 1, oldx, oldy, maxFlags); return 1; } MoveMouse(rootWindow, np->x, np->y); DiscardMotionEvents(&event, np->window); moved = 1; } else if(event.type == MotionNotify) { DiscardMotionEvents(&event, np->window); np->x = event.xmotion.x; np->y = event.xmotion.y; moved = 1; } else if(event.type == ButtonRelease) { StopMove(np, 1, oldx, oldy, maxFlags); return 1; } if(moved) { if(settings.moveMode == MOVE_OUTLINE) { ClearOutline(); DrawOutline(np->x - west, np->y - west, np->width + west + east, height + north + west); } else { JXMoveWindow(display, np->parent, np->x - west, np->y - north); SendConfigureEvent(np); } UpdateMoveWindow(np); RequirePagerUpdate(); } } }
// 打开HTTP请求函数 BOOL CHttpClient::OpenRequest(LPCTSTR lpszUrl, HTTP_REQ_METHOD nReqMethod/* = REQ_METHOD_GET*/) { TCHAR szScheme[INTERNET_MAX_URL_LENGTH] = {0}; TCHAR szHostName[INTERNET_MAX_URL_LENGTH] = {0}; TCHAR szUrlPath[INTERNET_MAX_URL_LENGTH] = {0}; WORD nPort = 0; DWORD dwAccessType; LPCTSTR lpszProxy; BOOL bRet; bRet = ParseURL(lpszUrl, szScheme, INTERNET_MAX_URL_LENGTH, // 解析Url szHostName, INTERNET_MAX_URL_LENGTH, nPort, szUrlPath, INTERNET_MAX_URL_LENGTH); if (!bRet) return FALSE; m_hCompleteEvent = ::CreateEvent(NULL, FALSE, FALSE, NULL); // 创建事件句柄 m_hCancelEvent = ::CreateEvent(NULL, FALSE, FALSE, NULL); if (NULL == m_hCompleteEvent || NULL == m_hCancelEvent) { CloseRequest(); return FALSE; } if (m_strProxy.size() > 0) { dwAccessType = INTERNET_OPEN_TYPE_PROXY; lpszProxy = m_strProxy.c_str(); } else { dwAccessType = INTERNET_OPEN_TYPE_PRECONFIG; lpszProxy = NULL; } m_hInternet = ::InternetOpen(CHROME_USER_AGENT, dwAccessType, lpszProxy, NULL, INTERNET_FLAG_ASYNC); if (NULL == m_hInternet) { CloseRequest(); return FALSE; } if (m_strUser.size() > 0) // 设置代理用户名 { ::InternetSetOptionEx(m_hInternet, INTERNET_OPTION_PROXY_USERNAME, (LPVOID)m_strUser.c_str(), m_strUser.size() + 1, 0); } if (m_strPwd.size() > 0) // 设置代理密码 { ::InternetSetOptionEx(m_hInternet, INTERNET_OPTION_PROXY_PASSWORD, (LPVOID)m_strPwd.c_str(), m_strPwd.size() + 1, 0); } // DWORD dwTimeOut; // DWORD dwSize = sizeof(dwTimeOut); // ::InternetQueryOption(m_hInternet, INTERNET_OPTION_CONNECT_TIMEOUT, (LPVOID)&dwTimeOut, &dwSize); INTERNET_STATUS_CALLBACK lpCallBackFunc; // 设置状态回调函数 lpCallBackFunc = ::InternetSetStatusCallback(m_hInternet, (INTERNET_STATUS_CALLBACK)&StatusCallback); if (INTERNET_INVALID_STATUS_CALLBACK == lpCallBackFunc) { CloseRequest(); return FALSE; } m_dwContext = CONNECTED_EVENT; m_hConnect = ::InternetConnect(m_hInternet, szHostName, nPort, NULL, _T("HTTP/1.1"), INTERNET_SERVICE_HTTP, 0, (DWORD_PTR)this); if (NULL == m_hConnect) { if (::GetLastError() != ERROR_IO_PENDING) { CloseRequest(); return FALSE; } } bRet = WaitForEvent(CONNECTED_EVENT, m_dwConnectTimeOut); if (!bRet) { CloseRequest(); return FALSE; } TCHAR * lpMethod; if (nReqMethod == REQ_METHOD_GET) lpMethod = _T("GET"); else lpMethod = _T("POST"); DWORD dwFlags = INTERNET_FLAG_RELOAD | INTERNET_FLAG_NO_CACHE_WRITE; if (INTERNET_DEFAULT_HTTPS_PORT == nPort) dwFlags |= INTERNET_FLAG_SECURE; m_dwContext = REQUEST_OPENED_EVENT; m_hRequest = ::HttpOpenRequest(m_hConnect, lpMethod, szUrlPath, _T("HTTP/1.1"), NULL, NULL, dwFlags, (DWORD_PTR)this); if (NULL == m_hRequest) { if (::GetLastError() != ERROR_IO_PENDING) { CloseRequest(); return FALSE; } } bRet = WaitForEvent(REQUEST_OPENED_EVENT, INFINITE); if (!bRet) { CloseRequest(); return FALSE; } return TRUE; }
/** Move a client window. */ char MoveClient(ClientNode *np, int startx, int starty, int snap) { XEvent event; int oldx, oldy; int doMove; int north, south, east, west; int height; int hmax, vmax; Assert(np); if(!(np->state.border & BORDER_MOVE)) { return 0; } if(np->state.status & STAT_FULLSCREEN) { return 0; } GrabMouseForMove(); RegisterCallback(0, SignalMove, NULL); np->controller = MoveController; shouldStopMove = 0; oldx = np->x; oldy = np->y; vmax = 0; hmax = 0; if(!(GetMouseMask() & (Button1Mask | Button2Mask))) { StopMove(np, 0, oldx, oldy, 0, 0); return 0; } GetBorderSize(&np->state, &north, &south, &east, &west); startx -= west; starty -= north; currentClient = np; atTop = 0; atBottom = 0; atLeft = 0; atRight = 0; doMove = 0; for(;;) { WaitForEvent(&event); if(shouldStopMove) { np->controller = NULL; SetDefaultCursor(np->parent); UnregisterCallback(SignalMove, NULL); return doMove; } switch(event.type) { case ButtonRelease: if(event.xbutton.button == Button1 || event.xbutton.button == Button2) { StopMove(np, doMove, oldx, oldy, hmax, vmax); return doMove; } break; case MotionNotify: DiscardMotionEvents(&event, np->window); np->x = event.xmotion.x_root - startx; np->y = event.xmotion.y_root - starty; GetCurrentTime(&moveTime); atLeft = 0; atTop = 0; atRight = 0; atBottom = 0; if(event.xmotion.x_root == 0) { atLeft = 1; } else if(event.xmotion.x_root == rootWidth - 1) { atRight = 1; } if(event.xmotion.y_root == 0) { atTop = 1; } else if(event.xmotion.y_root == rootHeight - 1) { atBottom = 1; } if(snap) { DoSnap(np); } if(!doMove && (abs(np->x - oldx) > MOVE_DELTA || abs(np->y - oldy) > MOVE_DELTA)) { if(np->state.status & (STAT_HMAX | STAT_VMAX)) { if(np->state.status & STAT_HMAX) { hmax = 1; } if(np->state.status & STAT_VMAX) { vmax = 1; } MaximizeClient(np, 0, 0); startx = np->width / 2; starty = -north / 2; MoveMouse(np->parent, startx, starty); } CreateMoveWindow(np); doMove = 1; } if(doMove) { if(settings.moveMode == MOVE_OUTLINE) { ClearOutline(); height = north + south; if(!(np->state.status & STAT_SHADED)) { height += np->height; } DrawOutline(np->x - west, np->y - north, np->width + west + east, height); } else { JXMoveWindow(display, np->parent, np->x - west, np->y - north); SendConfigureEvent(np); } UpdateMoveWindow(np); UpdatePager(); } break; default: break; } } }
int main(int argc, char **argv) { char str[MAX_PATH+1]; char fname[MAX_PATH+1]; char ini_fname[MAX_PATH+1]; char* p; char* arg; int i; int retval; uint fnames=0; FILE* fp; BOOL tcp_nodelay; char compiler[32]; str_list_t fname_list; fname_list=strListInit(); DESCRIBE_COMPILER(compiler); errfp=stderr; #ifdef __unix__ statfp=stderr; #else statfp=stdout; #endif sscanf("$Revision: 1.77 $", "%*s %s", revision); fprintf(statfp,"\nSynchronet External X/Y/Zmodem v%s-%s" " Copyright %s Rob Swindell\n\n" ,revision ,PLATFORM_DESC ,__DATE__+7 ); xmodem_init(&xm,NULL,&mode,lputs,xmodem_progress,send_byte,recv_byte,is_connected,NULL); zmodem_init(&zm,NULL,lputs,zmodem_progress,send_byte,recv_byte,is_connected,NULL,data_waiting); /* Generate path/sexyz[.host].ini from path/sexyz[.exe] */ SAFECOPY(str,argv[0]); p=getfname(str); SAFECOPY(fname,p); *p=0; if((p=getfext(fname))!=NULL) *p=0; strcat(fname,".ini"); iniFileName(ini_fname,sizeof(ini_fname),str,fname); if((fp=fopen(ini_fname,"r"))!=NULL) fprintf(statfp,"Reading %s\n",ini_fname); tcp_nodelay =iniReadBool(fp,ROOT_SECTION,"TCP_NODELAY",TRUE); telnet =iniReadBool(fp,ROOT_SECTION,"Telnet",TRUE); debug_tx =iniReadBool(fp,ROOT_SECTION,"DebugTx",FALSE); debug_rx =iniReadBool(fp,ROOT_SECTION,"DebugRx",FALSE); debug_telnet =iniReadBool(fp,ROOT_SECTION,"DebugTelnet",FALSE); pause_on_exit =iniReadBool(fp,ROOT_SECTION,"PauseOnExit",FALSE); pause_on_abend =iniReadBool(fp,ROOT_SECTION,"PauseOnAbend",FALSE); log_level =iniReadLogLevel(fp,ROOT_SECTION,"LogLevel",log_level); outbuf.highwater_mark =iniReadInteger(fp,ROOT_SECTION,"OutbufHighwaterMark",1100); outbuf_drain_timeout =iniReadInteger(fp,ROOT_SECTION,"OutbufDrainTimeout",10); outbuf_size =iniReadInteger(fp,ROOT_SECTION,"OutbufSize",16*1024); progress_interval =iniReadInteger(fp,ROOT_SECTION,"ProgressInterval",1); if(iniReadBool(fp,ROOT_SECTION,"Debug",FALSE)) log_level=LOG_DEBUG; xm.send_timeout =iniReadInteger(fp,"Xmodem","SendTimeout",xm.send_timeout); /* seconds */ xm.recv_timeout =iniReadInteger(fp,"Xmodem","RecvTimeout",xm.recv_timeout); /* seconds */ xm.byte_timeout =iniReadInteger(fp,"Xmodem","ByteTimeout",xm.byte_timeout); /* seconds */ xm.ack_timeout =iniReadInteger(fp,"Xmodem","AckTimeout",xm.ack_timeout); /* seconds */ xm.block_size =iniReadInteger(fp,"Xmodem","BlockSize",xm.block_size); /* 128 or 1024 */ xm.max_errors =iniReadInteger(fp,"Xmodem","MaxErrors",xm.max_errors); xm.g_delay =iniReadInteger(fp,"Xmodem","G_Delay",xm.g_delay); zm.init_timeout =iniReadInteger(fp,"Zmodem","InitTimeout",zm.init_timeout); /* seconds */ zm.send_timeout =iniReadInteger(fp,"Zmodem","SendTimeout",zm.send_timeout); /* seconds */ zm.recv_timeout =iniReadInteger(fp,"Zmodem","RecvTimeout",zm.recv_timeout); /* seconds */ zm.crc_timeout =iniReadInteger(fp,"Zmodem","CrcTimeout",zm.crc_timeout); /* seconds */ zm.block_size =iniReadInteger(fp,"Zmodem","BlockSize",zm.block_size); /* 1024 */ zm.max_block_size =iniReadInteger(fp,"Zmodem","MaxBlockSize",zm.max_block_size); /* 1024 or 8192 */ zm.max_errors =iniReadInteger(fp,"Zmodem","MaxErrors",zm.max_errors); zm.recv_bufsize =iniReadInteger(fp,"Zmodem","RecvBufSize",0); zm.no_streaming =!iniReadBool(fp,"Zmodem","Streaming",TRUE); zm.want_fcs_16 =!iniReadBool(fp,"Zmodem","CRC32",TRUE); zm.escape_telnet_iac =iniReadBool(fp,"Zmodem","EscapeTelnetIAC",TRUE); zm.escape_8th_bit =iniReadBool(fp,"Zmodem","Escape8thBit",FALSE); zm.escape_ctrl_chars =iniReadBool(fp,"Zmodem","EscapeCtrlChars",FALSE); dszlog_path =iniReadBool(fp,"DSZLOG","Path",TRUE); dszlog_short =iniReadBool(fp,"DSZLOG","Short",FALSE); dszlog_quotes =iniReadBool(fp,"DSZLOG","Quotes",FALSE); if(fp!=NULL) fclose(fp); if(zm.recv_bufsize > 0xffff) zm.recv_bufsize = 0xffff; if(outbuf_size < MIN_OUTBUF_SIZE) outbuf_size = MIN_OUTBUF_SIZE; else if(outbuf_size > MAX_OUTBUF_SIZE) outbuf_size = MAX_OUTBUF_SIZE; fprintf(statfp,"Output buffer size: %u\n", outbuf_size); RingBufInit(&outbuf, outbuf_size); #if !defined(RINGBUF_EVENT) outbuf_empty=CreateEvent(NULL,/* ManualReset */TRUE, /*InitialState */TRUE,NULL); #endif #if 0 if(argc>1) { fprintf(statfp,"Command line: "); for(i=1;i<argc;i++) fprintf(statfp,"%s ",argv[i]); fprintf(statfp,"\n",statfp); } #endif for(i=1;i<argc;i++) { if(sock==INVALID_SOCKET && isdigit(argv[i][0])) { sock=atoi(argv[i]); continue; } if(!(mode&(SEND|RECV))) { if(toupper(argv[i][0])=='S' || toupper(argv[i][0])=='R') { /* cmd */ if(toupper(argv[i][0])=='R') mode|=RECV; else mode|=SEND; switch(argv[i][1]) { case 'c': case 'C': mode|=XMODEM|CRC; break; case 'x': xm.block_size=128; case 'X': mode|=XMODEM; break; case 'b': /* sz/rz compatible */ case 'B': case 'y': xm.block_size=128; case 'Y': mode|=(YMODEM|CRC); break; case 'g': case 'G': mode|=(YMODEM|CRC|GMODE); break; case 'z': case 'Z': mode|=(ZMODEM|CRC); break; default: fprintf(statfp,"Unrecognized command '%s'\n\n",argv[i]); fprintf(statfp,usage); bail(1); } continue; } if(toupper(argv[i][0])=='V') { fprintf(statfp,"%-8s %s\n",getfname(__FILE__) ,revision); fprintf(statfp,"%-8s %s\n",getfname(xmodem_source()),xmodem_ver(str)); fprintf(statfp,"%-8s %s\n",getfname(zmodem_source()),zmodem_ver(str)); #ifdef _DEBUG fprintf(statfp,"Debug\n"); #endif fprintf(statfp,"Compiled %s %.5s with %s\n",__DATE__,__TIME__,compiler); fprintf(statfp,"%s\n",os_version(str)); bail(0); } arg=argv[i]; if(*arg=='-') { while(*arg=='-') arg++; if(stricmp(arg,"telnet")==0) { telnet=TRUE; continue; } if(stricmp(arg,"rlogin")==0 || stricmp(arg,"ssh")==0 || stricmp(arg,"raw")==0) { telnet=FALSE; continue; } if(stricmp(arg,"debug")==0) { log_level=LOG_DEBUG; continue; } if(stricmp(arg,"quotes")==0) { dszlog_quotes=TRUE; continue; } switch(toupper(*arg)) { case 'K': /* sz/rz compatible */ xm.block_size=1024; break; case 'C': /* sz/rz compatible */ mode|=CRC; break; case '2': zm.max_block_size=2048; break; case '4': zm.max_block_size=4096; break; case '8': /* ZedZap */ zm.max_block_size=8192; break; case 'O': /* disable Zmodem CRC-32 */ zm.want_fcs_16=TRUE; break; case 'S': /* disable Zmodem streaming */ zm.no_streaming=TRUE; break; case 'G': /* Ymodem-G */ mode|=GMODE; break; case 'Y': mode|=OVERWRITE; break; case '!': pause_on_abend=TRUE; break; } } } else if((argv[i][0]=='+' || argv[i][0]=='@') && fexist(argv[i]+1)) { if(mode&RECVDIR) { fprintf(statfp,"!Cannot specify both directory and filename\n"); bail(1); } sprintf(str,"%s",argv[i]+1); if((fp=fopen(str,"r"))==NULL) { fprintf(statfp,"!Error %d opening filelist: %s\n",errno,str); bail(1); } while(!feof(fp) && !ferror(fp)) { if(!fgets(str,sizeof(str),fp)) break; truncsp(str); strListAppend(&fname_list,strdup(str),fnames++); } fclose(fp); } else if(mode&(SEND|RECV)){ if(isdir(argv[i])) { /* is a directory */ if(mode&RECVDIR) { fprintf(statfp,"!Only one directory can be specified\n"); bail(1); } if(fnames) { fprintf(statfp,"!Cannot specify both directory and filename\n"); bail(1); } if(mode&SEND) { fprintf(statfp,"!Cannot send directory '%s'\n",argv[i]); bail(1); } mode|=RECVDIR; } strListAppend(&fname_list,argv[i],fnames++); } } if(!telnet) zm.escape_telnet_iac = FALSE; if(sock==INVALID_SOCKET || sock<1) { #ifdef __unix__ if(STDOUT_FILENO > STDIN_FILENO) sock=STDOUT_FILENO; else sock=STDIN_FILENO; stdio=TRUE; fprintf(statfp,"No socket descriptor specified, using STDIO\n"); telnet=FALSE; #else fprintf(statfp,"!No socket descriptor specified\n\n"); fprintf(errfp,usage); bail(1); #endif } #ifdef __unix__ else statfp=stdout; #endif if(!(mode&(SEND|RECV))) { fprintf(statfp,"!No command specified\n\n"); fprintf(statfp,usage); bail(1); } if(mode&(SEND|XMODEM) && !fnames) { /* Sending with any or recv w/Xmodem */ fprintf(statfp,"!Must specify filename or filelist\n\n"); fprintf(statfp,usage); bail(1); } #ifdef __unix__ if(stdio) { struct termios term; memset(&term,0,sizeof(term)); cfsetispeed(&term,B19200); cfsetospeed(&term,B19200); term.c_iflag &= ~(IMAXBEL|IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON); term.c_oflag &= ~OPOST; term.c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN); term.c_cflag &= ~(CSIZE|PARENB); term.c_cflag |= CS8; atexit(resetterm); tcgetattr(STDOUT_FILENO, &origterm); tcsetattr(STDOUT_FILENO, TCSADRAIN, &term); } #endif /* Code disabled. Why? ToDo */ /* if(mode&RECVDIR) backslash(fname[0]); */ if(!winsock_startup()) bail(-1); /* Enable the Nagle Algorithm */ #ifdef __unix__ if(!stdio) { #endif lprintf(LOG_DEBUG,"Setting TCP_NODELAY to %d",tcp_nodelay); setsockopt(sock,IPPROTO_TCP,TCP_NODELAY,(char*)&tcp_nodelay,sizeof(tcp_nodelay)); #ifdef __unix__ } #endif if(!socket_check(sock, NULL, NULL, 0)) { lprintf(LOG_WARNING,"No socket connection"); bail(-1); } if((dszlog=getenv("DSZLOG"))!=NULL) { if((logfp=fopen(dszlog,"w"))==NULL) { lprintf(LOG_WARNING,"Error %d opening DSZLOG file: %s",errno,dszlog); bail(-1); } } /* Install Ctrl-C/Break signal handler here */ #if defined(_WIN32) SetConsoleCtrlHandler(ControlHandler, TRUE /* Add */); #elif defined(__unix__) signal(SIGQUIT,break_handler); signal(SIGINT,break_handler); signal(SIGTERM,break_handler); signal(SIGHUP,SIG_IGN); /* Don't die on SIGPIPE */ signal(SIGPIPE,SIG_IGN); #endif #if !SINGLE_THREADED _beginthread(output_thread,0,NULL); #endif if(mode&RECV) retval=receive_files(fname_list, fnames); else retval=send_files(fname_list, fnames); #if !SINGLE_THREADED lprintf(LOG_DEBUG,"Waiting for output buffer to empty... "); if(WaitForEvent(outbuf_empty,5000)!=WAIT_OBJECT_0) lprintf(LOG_DEBUG,"FAILURE"); #endif terminate=TRUE; /* stop output thread */ /* Code disabled. Why? ToDo */ /* sem_post(outbuf.sem); sem_post(outbuf.highwater_sem); */ fprintf(statfp,"Exiting - Error level: %d, flows: %u, select_errors=%u" ,retval, flows, select_errors); fprintf(statfp,"\n"); bail(retval); }
void isDefault(double x1, double y1, double x2, double y2)//是否使用默认配置函数 { LayEgg();//是否的蛋 int i; double parameter; double distance1; double distance2; MovePen(x1+235,y1+20); DrawString("是否使用默认配置"); MovePen(x1,y1); DrawLine(x2-x1,0); DrawLine(0,y2-y1); DrawLine(x1-x2,0); DrawLine(0,y1-y2); MovePen(x1+(x2-x1)/2,y1); DrawLine(0,y2-y1); distance1=((x2-x1)/2-GetStringWidth("是"))/2; distance2=(y1-y2-GetStringWidth("是"))/2; MovePen(x1+distance1,y1-distance2); DrawString("是"); MovePen(x1+(x2-x1)/2+distance1,y1-distance2); DrawString("否"); double X,Y; while(1) { while(!(WaitForEvent()==KEYDOWN)){} if(GetStruckKey() == VK_LBUTTON) { X = GetMouseX(); Y = GetMouseY(); if((X >= x1 && X <= x1+(x2-x1)/2) && (Y >= y2 && Y <= y1))//鼠标点击在所规定的范围内 { printf("使用默认配置\n"); EatEgg(); break; } else if((X > x1+(x2-x1)/2 && X <= x2) && (Y >= y2 && Y <= y1)) { printf("不使用默认配置\n\n"); printf("本输入框使用方法如下:\n"); printf("1. 在输入时应一项一项一次输入。\n"); printf("2. 点击鼠标左键为输入模式,键盘Backspace为清除模式,鼠标右键为确认模式。\n"); printf("3. 进入输入模式,输入相应的数字后,点击ESC键可退出输入模式,此时,在相应区域点击Backspace键则可清除相应数字,\n 再次输入如上。点击鼠标右键完成输入后则可进入下一项的输入。\n"); printf("4. 在全部信息输入完成后,会出现完成按钮,点击则最终完成信息输入。\n"); EatEgg(); LayEgg(); createInputFrame(INPUT_LEFT_UP_X, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE);//建立输入信息框 printf("\n下面开始输入A火车信息:\n"); for(i=1;i<=7;i++)//进行A火车信息的配置 { //parameter=0,省略了 switch(i) { case 1:trainA.type = (int)showDeleteInput(INPUT_LEFT_UP_X, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"火车类型(1表示快车,2表示慢车):",i);break; case 2:trainA.speed = showDeleteInput(INPUT_LEFT_UP_X, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"火车速度(m/s)(0到10):",i);break; case 3:trainA.direction = (int)showDeleteInput(INPUT_LEFT_UP_X, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"方向(顺时针为1,逆时针为-1):",i);break; case 4:trainA.trackLen = showDeleteInput(INPUT_LEFT_UP_X, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"轨道长度(m)(0到100):",i);break; case 5:trainA.position = showDeleteInput(INPUT_LEFT_UP_X, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"初始位置(0至轨道长度):",i);break; case 6:trainA.time = showDeleteInput(INPUT_LEFT_UP_X, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"启动时间(从程序开始运行起/s):",i);break; case 7:trainA.restTime = showDeleteInput(INPUT_LEFT_UP_X, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"公共轨道停留时间:",i);break; } } printf("A火车信息已经输入完成。\n"); printf("下面开始输入B火车信息:\n"); for(i=1;i<=7;i++)//进行B火车信息的配置 { parameter=(INPUT_RIGHT_DOWN_X-INPUT_LEFT_UP_X)/4; switch(i) { case 1:trainB.type = (int)showDeleteInput(INPUT_LEFT_UP_X+parameter, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"火车类型(1表示快车,2表示慢车):",i);break; case 2:trainB.speed = showDeleteInput(INPUT_LEFT_UP_X+parameter, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"火车速度(m/s)(0到10):",i);break; case 3:trainB.direction = (int)showDeleteInput(INPUT_LEFT_UP_X+parameter, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"方向(顺时针为1,逆时针为-1):",i);break; case 4:trainB.trackLen = showDeleteInput(INPUT_LEFT_UP_X+parameter, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"轨道长度(m)(0到100):",i);break; case 5:trainB.position = showDeleteInput(INPUT_LEFT_UP_X+parameter, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"初始位置(0至轨道长度):",i);break; case 6:trainB.time = showDeleteInput(INPUT_LEFT_UP_X+parameter, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"启动时间(从程序开始运行起/s):",i);break; case 7:trainB.restTime = showDeleteInput(INPUT_LEFT_UP_X+parameter, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"公共轨道停留时间:",i);break; } } printf("B火车信息已经输入完成。\n"); printf("下面开始输入C火车信息:\n"); for(i=1;i<=7;i++)//进行C火车信息的配置 { parameter=(INPUT_RIGHT_DOWN_X-INPUT_LEFT_UP_X)*2/4; switch(i) { case 1:trainC.type = (int)showDeleteInput(INPUT_LEFT_UP_X+parameter, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"火车类型(1表示快车,2表示慢车):",i);break; case 2:trainC.speed = showDeleteInput(INPUT_LEFT_UP_X+parameter, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"火车速度(m/s)(0到10):",i);break; case 3:trainC.direction = (int)showDeleteInput(INPUT_LEFT_UP_X+parameter, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"方向(顺时针为1,逆时针为-1):",i);break; case 4:trainC.trackLen = showDeleteInput(INPUT_LEFT_UP_X+parameter, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"轨道长度(m)(0到100):",i);break; case 5:trainC.position = showDeleteInput(INPUT_LEFT_UP_X+parameter, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"初始位置(0至轨道长度):",i);break; case 6:trainC.time = showDeleteInput(INPUT_LEFT_UP_X+parameter, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"启动时间(从程序开始运行起/s):",i);break; case 7:trainC.restTime = showDeleteInput(INPUT_LEFT_UP_X+parameter, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"公共轨道停留时间:",i);break; } } printf("C火车信息已经输入完成。\n"); printf("下面开始输入探测点信息:\n"); for(i=1;i<=8;i++)//进行探测点信息的配置 { parameter=(INPUT_RIGHT_DOWN_X-INPUT_LEFT_UP_X)*3/4; switch(i) { case 1:a1_in = showDeleteInput(INPUT_LEFT_UP_X+parameter, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"A车、B车公轨A车的入口探测点:",i);break; case 2:a1_out = showDeleteInput(INPUT_LEFT_UP_X+parameter, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"A车、B车公轨A车的出口探测点:",i);break; case 3:b_in = showDeleteInput(INPUT_LEFT_UP_X+parameter, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"A车、B车公轨B车的入口探测点:",i);break; case 4:b_out = showDeleteInput(INPUT_LEFT_UP_X+parameter, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"A车、B车公轨B车的出口探测点:",i);break; case 5:a2_in = showDeleteInput(INPUT_LEFT_UP_X+parameter, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"A车、C车公轨A车的入口探测点:",i);break; case 6:a2_out = showDeleteInput(INPUT_LEFT_UP_X+parameter, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"A车、C车公轨A车的出口探测点:",i);break; case 7:c_in = showDeleteInput(INPUT_LEFT_UP_X+parameter, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"A车、C车公轨C车的入口探测点:",i);break; case 8:c_out = showDeleteInput(INPUT_LEFT_UP_X+parameter, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"A车、C车公轨C车的出口探测点:",i);break; } } printf("探测点信息输入完成:\n"); printf("请点击面板上的完成键"); confirmComplete(320, 400, 900, 250); EatEgg(); break; } } } }
bool CPluginHelper::Work() { DWORD Timeout = m_Engine->GetFrameTimeout() * m_Plugin->GetHelperCount(); int FrameLength = m_Engine->GetFrameLength(); while (1) { m_IdleEvent.Set(); // signal idleness if (!WaitForEvent(m_InputEvent, Timeout)) // wait for input return(!m_KillFlag); int parms = m_Plugin->GetParmCount(); for (int i = 0; i < parms; i++) { // for each plugin parameter if (m_ParmTarget[i] != m_ParmShadow[i]) { // if target differs from shadow m_FFInst.SetParam(i, m_ParmTarget[i]); // update freeframe plugin m_ParmShadow[i] = m_ParmTarget[i]; // update shadow } } ASSERT(m_InputFrame[0] != NULL); // sanity check int NumInputs = GetNumInputs(); if (m_Plugin->UsingProcessCopy()) { // if using process copy QREAD(m_Engine->GetFreeQueue(), m_OutFrame); // get output frame if (!m_Plugin->GetBypass()) { // if not bypassed for (int InpIdx = 0; InpIdx < NumInputs; InpIdx++) m_InFrameBuf[InpIdx] = m_InputFrame[InpIdx]->Buf; ProcessFrameCopyStruct pfcs; pfcs.InputFrames = m_InFrameBuf.GetData(); pfcs.numInputFrames = NumInputs; pfcs.OutputFrame = m_OutFrame->Buf; AddProcessHistorySample(TRUE); m_FFInst.ProcessFrameCopy(pfcs); // process frame AddProcessHistorySample(FALSE); } else // bypassed; copy first input to output memcpy(m_OutFrame->Buf, m_InputFrame[0], FrameLength); if (!WaitForEvent(m_OutputEvent, Timeout)) // wait for output token return(!m_KillFlag); // write output frame to output queues int outs = m_Plugin->GetOutputCount(); ASSERT(outs > 0); // if no outputs, we shouldn't be running m_OutFrame->RefCount = outs; // set output refs for (int OutIdx = 0; OutIdx < outs; OutIdx++) { QOUTPUT(m_Plugin->GetOutputQueue(OutIdx), m_OutFrame); } m_OutFrame = NULL; // free input frames for (int InpIdx = 0; InpIdx < NumInputs; InpIdx++) { if (!InterlockedDecrement(&m_InputFrame[InpIdx]->RefCount)) { QWRITE(m_Engine->GetFreeQueue(), m_InputFrame[InpIdx]); } m_InputFrame[InpIdx] = NULL; // for monitoring } } else { // in place if (!m_Plugin->GetBypass()) { // if not bypassed AddProcessHistorySample(TRUE); m_FFInst.ProcessFrame(m_InputFrame[0]->Buf); // process frame AddProcessHistorySample(FALSE); } if (!WaitForEvent(m_OutputEvent, Timeout)) // wait for output token return(!m_KillFlag); // write frame to output queues int outs = m_Plugin->GetOutputCount(); ASSERT(outs > 0); // if no outputs, we shouldn't be running m_InputFrame[0]->RefCount = outs; // set output refs for (int OutIdx = 0; OutIdx < outs; OutIdx++) { QOUTPUT(m_Plugin->GetOutputQueue(OutIdx), m_InputFrame[0]); } m_InputFrame[0] = NULL; // for monitoring } m_NextOutputEvent->Set(); // pass output token } }