int CSMDevice::Open() { if(Initial() != 0) return 1; hMapFile = CreateFileMapping( INVALID_HANDLE_VALUE, // use paging file NULL, // default security PAGE_READWRITE, // read/write access 0, // maximum object size (high-order DWORD) this->gComm_SMsize, // maximum object size (low-order DWORD) this->gComm_SMName); // name of mapping object if (hMapFile == NULL) { MessageBox(NULL, TEXT("CreateFileMapping Fail"), TEXT("CSMDevice::Open"), MB_OK); return 2; } pBuf = (unsigned short*) MapViewOfFile(hMapFile, // handle to map object FILE_MAP_ALL_ACCESS, // read/write permission 0, 0, this->gComm_SMsize); if (pBuf == NULL) { MessageBox(NULL, TEXT("MapViewOfFile Fail"), TEXT("CSMDevice::Open"), MB_OK); CloseHandle(hMapFile); return 3; } return 0; }
void main() { Initial(); //Initialize all settings required for general QwikFlash and LCD operation DisplayC(Clear1); //Clear the LCD one time at the beginning of your program DisplayC(Clear2); //Your personal PORT/TRIS/ADCON/etc settings or configurations can go here //Or make your own function and call it TRISBbits.RB0 = 1; // set PortB0 as input port TRISBbits.RB1 = 1; // set PortB1 as input port TRISBbits.RB2 = 1; // set PortB2 as input port TRISBbits.RB3 = 1; // set PortB3 as input port T0CON = 0b00000101; // timer 0 configuration register bit settings INTCON = 0b00110000; // interrupt configuration register bit settings INTCON2 = 0b11110000; // interrupt configuration register 2 bit settings INTCON3 = 0b00001000; // interrupt configuration register 3 bit settings RCON = 0b10000000; TMR0H = 0x67; // Load preload value in timer 0 in high byte TMR0L = 0x69; // Load preload value in timer 0 in low byte INTCONbits.PEIE = 1; // Set PEIE enable bit INTCONbits.GIE = 1; // GIE enable bit T0CONbits.TMR0ON = 1; // turn timer 0 on while (1) { // switch1 is a flag that is set from the low // priority interrupt if (switch1) { DisplayC(pause1); // display the pause symbol Str_2[1] = 0x03; } else { DisplayC(play1); // display the play symbol Str_2[1] = 0x04; } // if switch 1, switch 2, and pushbutton 1 are set // then increment timer if (switch1 == 1 && PORTBbits.RB2 == 1 && PORTBbits.RB3 == 1) { Str_2[7] = '+'; // display ++ for increment Str_2[8] = '+'; timeInDay(); } else { Str_2[7] = ' '; // clear ++ for increment Str_2[8] = ' '; } DisplayC(Str_2); } }
int main (int argc, char *argv[]) { if (InitCVIRTE (0, argv, 0) == 0) return -1; /* out of memory */ if ((panelHandle = LoadPanel (0, "Remotely.uir", PANEL)) < 0) return -1; if ((configHandle = LoadPanel (0, "Remotely.uir", CONFIG)) < 0) return -1; if ((itemHandle = LoadPanel (0, "Remotely.uir", FILE_ITEM)) < 0) return -1; menubarHandle = GetPanelMenuBar (panelHandle); GetPanelHandleFromTabPage (panelHandle, PANEL_TAB, 0, &bbucommonHandle); GetPanelHandleFromTabPage (panelHandle, PANEL_TAB, 1, &rrucommonHandle); GetPanelHandleFromTabPage (panelHandle, PANEL_TAB, 2, &customizingHandle); SetActiveTabPage (panelHandle, PANEL_TAB, 0); if(Initial(0, 0)<0 || Initial(1, 0)<0 || Initial(2, 0)<0 || Initial(3, 0)<0) { SetLed("Read file type information from config.ini to UI error,please try again!",0); } WriteLog(); DisplayPanel (panelHandle); RunUserInterface (); return 0; }
void DancePartner(Person dancer[],int num) { //结构数组dancer中存放跳舞的男女,num是跳舞的人数。 int i; Person p; CirQueue Mdancers,Fdancers; Initial(&Mdancers);//男士队列初始化 Initial(&Fdancers);//女士队列初始化 for(i=0; i<num; i++) { //依次将跳舞者依其性别入队 p=dancer[i]; if(p.sex=='F') EnQueue(&Fdancers,p); //排入女队 else EnQueue(&Mdancers,p); //排入男队 } printf("舞队是:\n"); while(!IsEmpty(&Fdancers)&&!IsEmpty(&Mdancers)) { //依次输入男女舞伴名 p=DeQueue(&Fdancers); //女士出队 printf("%s ",p.name);//打印出队女士名 p=DeQueue(&Mdancers); //男士出队 printf("%s\n",p.name); //打印出队男士名 } if(!IsEmpty(&Fdancers)) { //输出女士剩余人数及队头女士的名字 printf("还有 %d 个女士等下一轮.\n",Fdancers.count); p=Front(&Fdancers); //取队头 printf("%s will be the first to get a partner. \n",p.name); } else if(!IsEmpty(&Mdancers)) { //输出男队剩余人数及队头者名字 printf("还有%d 个男士等下一轮.\n",Mdancers.count); p=Front(&Mdancers); printf("%s will be the first to get a partner.\n",p.name); } }
void CVICALLBACK ConfigItem (int menuBar, int menuItem, void *callbackData, int panel) { if((Initial(1, 0)>=0) && (Initial(2, 0)>=0) && (Initial(3, 0)>=0)) { InstallPopup(itemHandle); } else { SetLed("Read file type or filter information from config.ini to UI error,please try again!",0); } }
int main(){ int k, n, N, p, q, r; double *y_r, *y_i, *x_r, *x_i, w_r, w_i; printf("Please input p q r="); scanf("%d %d %d", &p, &q, &r); N = Generate_N(p, q, r); printf("N=2^%d 3^%d 5^%d = %d\n",p,q,r,N); x_r = (double *) malloc(N*sizeof(double)); x_i = (double *) malloc(N*sizeof(double)); y_r = (double *) malloc(N*sizeof(double)); y_i = (double *) malloc(N*sizeof(double)); Initial(x_r, x_i, N); FFTv3(x_r, x_i, y_r, y_i, N); /* for(int i=0;i<N;++i){ printf("%f\n",y_r[i]); } */ Print_Complex_Vector(y_r, y_i, N); return 0; }
Status CriticalPath(GRAPHIC_TYPE graphic, GRAPHIC_TYPE* result) { int i = 0; int vertex_count = graphic -> vertex_count; int *topological_sort_result_index = (int*)malloc(sizeof(int) * vertex_count), *vertex_earliest_start_time = (int*)malloc(sizeof(int) * vertex_count), *vertex_latest_start_time = (int*)malloc(sizeof(int) * vertex_count); //initial for (i = 0; i < vertex_count; i++) { vertex_earliest_start_time[i] = -1; vertex_latest_start_time[i] = -1; } calculate_topological_sort_result_index(graphic, topological_sort_result_index); calculate_vertex_earliest_start_time(graphic, topological_sort_result_index, vertex_earliest_start_time); vertex_latest_start_time[vertex_count - 1] = vertex_earliest_start_time[vertex_count - 1]; calculate_vertex_latest_start_time(graphic, topological_sort_result_index, vertex_latest_start_time); Initial(result); calculate_critical_path_result(graphic, topological_sort_result_index, vertex_earliest_start_time, vertex_latest_start_time, result); free(topological_sort_result_index); free(vertex_earliest_start_time); free(vertex_latest_start_time); return OK; }
void CBA_FontMap::SetAPType(const CFX_ByteString& sAPType) { m_sAPType = sAPType; Reset(); Initial(); }
__fastcall PCIM114GL::PCIM114GL() { m_byteDIPort=NULL; m_byteDOPort=NULL; m_bAutoMode=false; m_bInitOK=Initial(0); if(!m_bInitOK) { m_byteDIPort=new byte[12]; m_byteDOPort=new byte[12]; } m_dMMtoPLS[Axis_Const::LDY]=10000.0/10.0; m_dMMtoPLS[Axis_Const::LDZ]=10000.0/10.0; m_dMMtoPLS[Axis_Const::SPZ]=10000.0/5.0; m_dMMtoPLS[Axis_Const::MGZ]=10000.0/5.0; m_dMMtoPLS[Axis_Const::LLC]=10000.0/16.0; m_dMMtoPLS[Axis_Const::SPX]=10000.0/16.0; m_dMMtoPLS[Axis_Const::SPY]=10000.0/16.0; m_dMMtoPLS[Axis_Const::CDX]=10000.0/16.0; m_dMMtoPLS[Axis_Const::RLC]=10000.0/16.0; for(int nIndex=0;nIndex<AXIS_SIZE;nIndex++) m_dLastTargetPos[nIndex]=0.0; memset(m_byteDOPort,0,sizeof(byte)*m_vectDIOMap.size() * 2); }
void CJS_EventHandler::OnMenu_Exec( CPDFSDK_FormFillEnvironment* pTargetFormFillEnv, const CFX_WideString& strTargetName) { Initial(JET_MENU_EXEC); m_pTargetFormFillEnv.Reset(pTargetFormFillEnv); m_strTargetName = strTargetName; }
// <<< main function >>> //***************************************************************************** void main(void) { unsigned char i; Initial(); //initial ..... #if (SFNsimple ==0) //char *mySTR = "Complete mode!"; static char *mySTR[3] = { "S-Font test...", "Complete mode!", "Www.Elasa.ir!" }; N11_TypeStr(1, 1, mySTR[1], N11_GetStrLenC(mySTR[1]), BLACK, 150); _delay_ms(2000); N11_TypeStr(1, 1, mySTR[1], N11_GetStrLenC(mySTR[1]), WHITE, 50); _delay_ms(1000); N11_TypeStr(0, 1, mySTR[0], N11_GetStrLenC(mySTR[0]), BLACK, 100); N11_TypeStr(2, 1, mySTR[1], N11_GetStrLenC(mySTR[1]), BLACK, 100); N11_TypeStr(4, 1, mySTR[2], N11_GetStrLenC(mySTR[2]), BLACK, 100); N11_TypeStr(6, 1, mySTR[3], N11_GetStrLenC(mySTR[3]), BLACK, 100); _delay_ms(3000); N11_ChrCls(100); _delay_ms(500); StringAt(1, 1, "YES!!! :)", BLACK); #endif //----- main loop!!! while(1); } //main
void CJS_EventHandler::OnField_Keystroke(CFX_WideString& strChange, const CFX_WideString& strChangeEx, bool KeyDown, bool bModifier, int& nSelEnd, int& nSelStart, bool bShift, CPDF_FormField* pTarget, CFX_WideString& Value, bool bWillCommit, bool bFieldFull, bool& bRc) { Initial(JET_FIELD_KEYSTROKE); m_nCommitKey = 0; m_pWideStrChange = &strChange; m_WideStrChangeEx = strChangeEx; m_bKeyDown = KeyDown; m_bModifier = bModifier; m_pISelEnd = &nSelEnd; m_pISelStart = &nSelStart; m_bShift = bShift; m_strTargetName = pTarget->GetFullName(); m_pValue = &Value; m_bWillCommit = bWillCommit; m_pbRc = &bRc; m_bFieldFull = bFieldFull; }
int main(int argc, char* argv[]) { int * x = NULL; int row = 2; int col = 2; int i, j; int layer = 3; if(argc >= 2) layer = atoi(argv[1]); x = (int*)malloc(row * col * sizeof(int)); memset(x, 0, sizeof(int) * row * col); Initial(x, 2, 2); Hilbert(&x, row, col, layer); printf("Hilbert list:\n"); for(i = 0;i < row * pow(2, layer - 1);i ++) { for(j = 0;j < col * pow(2, layer - 1);j ++) printf("%d \t", x[i * col * (int)pow(2, layer - 1) + j]); printf("\n"); } printf("\nEnd Hilbert layer = %d.\n", layer); free(x); x = NULL; getchar(); return 0; }
void CJS_EventHandler::OnDoc_Open(CPDFSDK_Document* pDoc, const CFX_WideString& strTargetName) { Initial(JET_DOC_OPEN); m_pTargetDoc = pDoc; m_strTargetName = strTargetName; }
void CJS_EventHandler::OnMenu_Exec(CPDFSDK_Document* pTarget, const CFX_WideString& strTargetName) { Initial(JET_MENU_EXEC); m_pTargetDoc = pTarget; m_strTargetName = strTargetName; }
CDataBlockAllocator::CDataBlockAllocator(int nDBNum, int nDBSize, int bIniShareDB ) :m_nMaxDBNum(nDBNum) ,m_nDBSize(nDBSize) { Initial(bIniShareDB); m_MapTest.clear(); }
int main(int argc,char **argv) { PetscErrorCode ierr; PetscInt time_steps = 100,steps; PetscMPIInt size; Vec global; PetscReal dt,ftime; TS ts; MatStructure A_structure; Mat A = 0; ierr = PetscInitialize(&argc,&argv,(char*)0,help);CHKERRQ(ierr); ierr = MPI_Comm_size(PETSC_COMM_WORLD,&size);CHKERRQ(ierr); ierr = PetscOptionsGetInt(NULL,"-time",&time_steps,NULL);CHKERRQ(ierr); /* set initial conditions */ ierr = VecCreate(PETSC_COMM_WORLD,&global);CHKERRQ(ierr); ierr = VecSetSizes(global,PETSC_DECIDE,3);CHKERRQ(ierr); ierr = VecSetFromOptions(global);CHKERRQ(ierr); ierr = Initial(global,NULL);CHKERRQ(ierr); /* make timestep context */ ierr = TSCreate(PETSC_COMM_WORLD,&ts);CHKERRQ(ierr); ierr = TSSetProblemType(ts,TS_NONLINEAR);CHKERRQ(ierr); ierr = TSMonitorSet(ts,Monitor,NULL,NULL);CHKERRQ(ierr); dt = 0.1; /* The user provides the RHS and Jacobian */ ierr = TSSetRHSFunction(ts,NULL,RHSFunction,NULL);CHKERRQ(ierr); ierr = MatCreate(PETSC_COMM_WORLD,&A);CHKERRQ(ierr); ierr = MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,3,3);CHKERRQ(ierr); ierr = MatSetFromOptions(A);CHKERRQ(ierr); ierr = MatSetUp(A);CHKERRQ(ierr); ierr = RHSJacobian(ts,0.0,global,&A,&A,&A_structure,NULL);CHKERRQ(ierr); ierr = TSSetRHSJacobian(ts,A,A,RHSJacobian,NULL);CHKERRQ(ierr); ierr = TSSetFromOptions(ts);CHKERRQ(ierr); ierr = TSSetInitialTimeStep(ts,0.0,dt);CHKERRQ(ierr); ierr = TSSetDuration(ts,time_steps,1);CHKERRQ(ierr); ierr = TSSetSolution(ts,global);CHKERRQ(ierr); ierr = TSSolve(ts,global);CHKERRQ(ierr); ierr = TSGetSolveTime(ts,&ftime);CHKERRQ(ierr); ierr = TSGetTimeStepNumber(ts,&steps);CHKERRQ(ierr); /* free the memories */ ierr = TSDestroy(&ts);CHKERRQ(ierr); ierr = VecDestroy(&global);CHKERRQ(ierr); ierr = MatDestroy(&A);CHKERRQ(ierr); ierr = PetscFinalize(); return 0; }
void main() { Initial(); //Initialize all settings required for general QwikFlash and LCD operation DisplayC(Clear1); //Clear the LCD one time at the beginning of your program DisplayC(Clear2); long retTen; // initialize variable for 10K ohm potentiometer long retPot; // initialize variable for Potentiometer 1 on circuit board SSPSTAT = 0b11000000; // SMP and CKE SSPCON1 = 0b00100000; // Enable SPI serial port //Your personal PORT/TRIS/ADCON/etc settings or configurations can go here //Or make your own function and call it while(1) { Delay10KTCYx(25); retTen = tenK(); // Store value from 10K ohm potentiometer Delay10KTCYx(25); retPot = pot1(); // Store value from Potentiometer 1 on circuit board displayAnalog(retTen, retPot); } }
Status Multiply(SPARSE_MATRIX_TYPE a, SPARSE_MATRIX_TYPE b, SPARSE_MATRIX_TYPE *product) { if (a -> column_length != b -> row_length) return ERROR; Status status = Initial(product, a -> row_length, b -> column_length); if (status != OK) return status; int index_a = 0, index_b = 0; ElementType element; for (index_a = 0; index_a < a -> value_count; index_a++) { for (index_b = 0; index_b < b -> value_count; index_b++) { Triplet *triplet_a = (a -> data) + index_a; Triplet *triplet_b = (b -> data) + index_b; if (triplet_a -> column_index != triplet_b -> row_index) continue; Value(*product, &element, triplet_a -> row_index, triplet_b -> column_index); element += (triplet_a -> value) * (triplet_b -> value); Assign(*product, triplet_a -> row_index, triplet_b -> column_index, element); } } return OK; }
/******************************************************************************* * main subroutine * * This routine will run continuously after program initialization * * Within each iteration it will collect 1 temperature reading, 1 humidity * reading, save the latest data, and check if it should transmit the last * chunk of data from EEPROM * * Inputs: None * Outputs: None ******************************************************************************/ void main(void) { Initial(); while (1) { if ( USARTFlag ) { //Checks if there was a new byte from USART CheckUSART(); } if ( OKGOFlag ) { //Check if "ok to send" has been received if ( SENDFlag ) { //Check if latest data block is ready SendDATA(TTRAN); //Send temperature data FIRST = 0; //Clear flag for first time transmission SENDFlag = 0; //Clear flag for latest chunk of data } } if ( TimeStamp > 900 ) { WakeXBEE(); //Wake up XBEE if more than 15 minutes has } // passed if ( TimeStamp > 3600 ) { //One hour has passed T0CONbits.TMR0ON = 0; //Turn off TMR0 SendBYTE(0xFF); //Send Ack command to tell GSMRS we are done while( 1 ) { TxERROR(TTRAN); } } while ( SECFlag == 0 ) {} //Waits until 1 second has passed ADCON0bits.GO = 1; //Start collecting temperature data while ( ADCON0bits.GO ) {} //Wait for collection to finish ADConverter(); SECFlag = 0; //Reset 1 second counter Store(); //Store latest readings in RAM or EEPROM } }
int main() { int k, n, p, q, r, N; double *y_r, *y_i, *x_r, *x_i, w_r, w_i; clock_t t1, t2; printf("Please input p q r="); scanf("%d %d %d", &p, &q, &r); N = Generate_N(p, q, r); printf("N=2^%d 3^%d 5^%d = %d\n",p,q,r,N); x_r = (double *) malloc(N*sizeof(double)); x_i = (double *) malloc(N*sizeof(double)); y_r = (double *) malloc(N*sizeof(double)); y_i = (double *) malloc(N*sizeof(double)); Initial(x_r, x_i, N); t1 = clock(); FFTr3(x_r, x_i, y_r, y_i, N); t2 = clock(); printf("Fast FT3: %f secs\n", 1.0*(t2-t1)/CLOCKS_PER_SEC); // Print_Complex_Vector(y_r, y_i, N); return 0; }
XArc::XArc(const PNT &c, const PNT &s, const PNT &e, const PNT &n) { m_Cen = c; m_StartPt = s; m_EndPt = e; Initial(); }
void test_Initial() { BINARY_TREE_TYPE tree = NULL; Status status = Initial(&tree); CU_ASSERT_EQUAL(status, OK); CU_ASSERT_PTR_NULL(tree); }
int main(int argc, char *argv[]) { if(argc < 2) { printf("need input file\n"); return 0; } //int64_t *PID = (int64_t *)malloc(sizeof(int64_t)*NUM); int64_t *PID[Array] ; int i; for( i = 0 ; i < Array ; i++) { PID[i] = (int64_t *)malloc(sizeof(int64_t)*(NUM / Array)); } Index *phone = (Index *)malloc(sizeof(Index)*Hash*Col); Initial(); ReadFile(PID,phone,argv[1]); Traverse(PID,phone); phoneQmd(PID,phone); free(phone); for( i = 0 ; i < Array ; i++) { free(PID[i]); } return 0; }
void test_Initial(void) { GENERALIZED_LIST_TYPE list = (GENERALIZED_LIST_TYPE) 1; Status status = ERROR; status = Initial(&list); CU_ASSERT_EQUAL(status, OK); CU_ASSERT_PTR_NULL(list); }
void CJS_EventHandler::OnScreen_OutView(bool bModifier, bool bShift, CPDFSDK_Annot* pScreen) { Initial(JET_SCREEN_OUTVIEW); m_bModifier = bModifier; m_bShift = bShift; m_pTargetAnnot.Reset(pScreen); }
void CJS_EventHandler::OnField_MouseUp(bool bModifier, bool bShift, CPDF_FormField* pTarget) { Initial(JET_FIELD_MOUSEUP); m_bModifier = bModifier; m_bShift = bShift; m_strTargetName = pTarget->GetFullName(); }
void CJS_EventHandler::OnScreen_Close(bool bModifier, bool bShift, CPDFSDK_Annot* pScreen) { Initial(JET_SCREEN_CLOSE); m_bModifier = bModifier; m_bShift = bShift; m_pTargetAnnot.Reset(pScreen); }
int CVICALLBACK Item_Exit (int panel, int event, void *callbackData, int eventData1, int eventData2) { switch (event) { case EVENT_CLOSE: if((Initial(1, 1)>=0) && (Initial(2, 1)>=0) && (Initial(3, 1)>=0)) // write file type inforamtion to config.ini { RemovePopup (itemHandle); } else { SetLed("Write file type or filter information from UI to config.ini error,please try again!",0); } break; } return 0; }
void CJS_EventHandler::OnScreen_MouseExit(bool bModifier, bool bShift, CPDFSDK_Annot* pScreen) { Initial(JET_SCREEN_MOUSEEXIT); m_bModifier = bModifier; m_bShift = bShift; m_pTargetAnnot.Reset(pScreen); }