int main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer //*************** Initialization Section *************************** InitializeVariables(); InitPorts(); // InitTimerSystem(); //********************* End of Initialization Section ********************* _BIS_SR(GIE); //Enable Global Interrupts Here ONLY // static const unsigned char myArray[] ={ZERO, ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, A, B, LC, D, E, F}; while (1) { handle(); // // ManageSoftwareTimers(); // Debouncer(&(rotaryEncoder.SwitchA)); // debounce SwitchA // Debouncer(&(rotaryEncoder.SwitchB)); // debounce SwitchB // stateMachine(&rotaryEncoder, gEncoderState); // go through the state machine and change the counter variable respectively // } return 0; }
void TCompiler::initializeGLPosition(TIntermNode* root) { InitVariableList list; sh::ShaderVariable var(GL_FLOAT_VEC4, 0); var.name = "gl_Position"; list.push_back(var); InitializeVariables(root, list); }
ProfileInfo::ProfileInfo(CStringArray &aKeys, CStringArray &aValues) { InitializeVariables(); m_aKeys.Append(aKeys); m_aValues.Append(aValues); ExtractTargetFormat(); ExtractStorageDistribution(); }
/* ******************************************************************* * Function: void PluginCallback( PluginInfo::CALLBACK_REASON reason, PluginInterface* thePluginInterface ) * * Description : The main plugin callback for Virtools Dev * * * Parameters : * reason r Message passed to the callback * thePluginInterface r The plugin interface pointer * Returns : * ******************************************************************* */ void PluginCallback( PluginInfo::CALLBACK_REASON reason, PluginInterface* thePluginInterface ) { switch( reason ) { case PluginInfo::CR_LOAD: { thePluginInterfaceObject = thePluginInterface; [!if MainMenuCB] InitMenu() ; UpdateMenu() ; [!endif] [!if KeyboardShortcutsCB] RegisterKeyboardShortcutCategory() ; RegisterKeyboardShortcuts() ; [!endif] [!if VariablesCB] InitializeVariables() ; [!endif] } break; case PluginInfo::CR_UNLOAD: { [!if MainMenuCB] RemoveMenu() ; [!endif] [!if KeyboardShortcutsCB] UnregisterKeyboardShortcutCategory() ; [!endif] [!if VariablesCB] DeinitializeVariables() ; [!endif] thePluginInterfaceObject = NULL; } break; case PluginInfo::CR_NEWCOMPOSITIONNAME: { } break; [!if GetNotificationsCB] case PluginInfo::CR_NOTIFICATION: { } break; [!endif] } }
ProfileInfo::ProfileInfo(ProfileInfo *pProfileInfo) { InitializeVariables(); m_iProfileID = pProfileInfo->GetID(); m_iProfileVersion = pProfileInfo->GetVersion(); m_iProfileType = pProfileInfo->GetType(); m_csFilename = pProfileInfo->GetFilename(); m_csTitle = pProfileInfo->GetTitle(); m_csTargetFormat = pProfileInfo->GetTargetFormat(); m_csStorageDistribution = pProfileInfo->GetStorageDistribution(); m_bActivated = pProfileInfo->IsActivated(); m_bCreatedByAdmin = pProfileInfo->IsCreatedByAdmin(); pProfileInfo->GetKeysAndValues(m_aKeys, m_aValues); }
void TCompiler::initializeOutputVariables(TIntermNode *root) { InitVariableList list; if (shaderType == GL_VERTEX_SHADER) { for (auto var : varyings) { list.push_back(var); } } else { ASSERT(shaderType == GL_FRAGMENT_SHADER); for (auto var : outputVariables) { list.push_back(var); } } InitializeVariables(root, list); }
int main (int argc, char **argv) { double startTime; int info; /* used to check for functions returning nonzeros */ GAVec ga_x; /* solution vector */ TAO_SOLVER tao; /* TAO_SOLVER solver context */ TAO_GA_APPLICATION taoapp; /* TAO application context */ TaoTerminateReason reason; AppCtx user; /* user-defined application context */ /*initialize GA and MPI */ int heap = 400000, stack = 400000; MPI_Init (&argc, &argv); /* initialize MPI */ GA_Initialize (); /* initialize GA */ user.me = GA_Nodeid (); user.nproc = GA_Nnodes (); startTime = MPI_Wtime(); if (user.me == 0) { if (GA_Uses_fapi ()) GA_Error ("Program runs with C array API only", 0); printf ("Using %ld processes\n", (long) user.nproc); fflush (stdout); } heap /= user.nproc; stack /= user.nproc; if (!MA_init (MT_F_DBL, stack, heap)) GA_Error ("MA_init failed", stack + heap); /* initialize memory allocator */ /* Initialize TAO */ TaoInitialize (&argc, &argv, (char *) 0, help); /* Initialize problem parameters */ user.ndim = NDIM; user.natoms = NATOMS; user.BlockSize = BLOCKSIZE; /* Allocate vectors for the solution and gradient */ int dims[2]; dims[0] = user.ndim*user.natoms; ga_x = NGA_Create (C_DBL, 1, dims, "GA_X", NULL); if (!ga_x) GA_Error ("lennard-jones.main::NGA_Create ga_x", ga_x); /* Set up structures for data distribution */ info = SetupBlocks(&user); CHKERRQ(info); /* The TAO code begins here */ /* Create TAO solver with desired solution method */ info = TaoCreate (MPI_COMM_WORLD, "tao_lmvm", &tao); CHKERRQ(info); info = TaoGAApplicationCreate (MPI_COMM_WORLD, &taoapp); CHKERRQ(info); /* Set the initial solution */ info = InitializeVariables(ga_x, &user); CHKERRQ(info); info = TaoGAAppSetInitialSolutionVec(taoapp, ga_x); CHKERRQ(info); /* Set routines for function, gradient */ info = TaoGAAppSetObjectiveAndGradientRoutine (taoapp, FormFunctionGradient, (void *) &user); CHKERRQ(info); /* Check for TAO command line options */ info = TaoSetFromOptions (tao); CHKERRQ(info); /* SOLVE THE APPLICATION */ info = TaoSolveGAApplication (taoapp, tao); CHKERRQ(info); /* To View TAO solver information use */ info = TaoView(tao); CHKERRQ(info); /* Get termination information */ info = TaoGetTerminationReason (tao, &reason); if(info) GA_Error("lennard-jones.main.TaoGetTerminationReason",info); if (user.me == 0) { if (reason <= 0) printf("Try a different TAO method, adjust some parameters, or check the function evaluation routines\n"); printf("WALL TIME TAKEN = %lf\n", MPI_Wtime()-startTime); /*output the solutions */ printf ("The solution is :\n"); } GA_Print (ga_x); /* Free TAO data structures */ info = TaoDestroy (tao); CHKERRQ(info); info = TaoGAAppDestroy (taoapp); CHKERRQ(info); /* Free GA data structures */ GA_Destroy (ga_x); if (!MA_pop_stack(user.memHandle)) ga_error("Main::MA_pop_stack for memHandle failed",0); /* Finalize TAO, GA, and MPI */ TaoFinalize (); GA_Terminate (); MPI_Finalize (); return 0; }
int main (int argc, char **argv) { double startTime; int info; /* used to check for functions returning nonzeros */ GAVec ga_x; /* solution vector */ TAO_SOLVER tao; /* TAO_SOLVER solver context */ TAO_GA_APPLICATION taoapp; /* TAO application context */ TaoTerminateReason reason; AppCtx user; /* user-defined application context */ /*initialize GA and MPI */ int heap = 4000, stack = 4000; MPI_Init (&argc, &argv); /* initialize MPI */ GA_Initialize (); /* initialize GA */ if (!MA_init(MT_F_DBL, stack, heap)) GA_Error((char*)"MA_init failed", stack+heap); /* Initialize TAO */ TaoInitialize (&argc, &argv, (char *) 0, help); startTime = MPI_Wtime(); /* Initialize problem parameters */ user.natoms = NATOMS; user.ndim = NDIM; user.n = user.natoms*user.ndim; /* Create working space */ if (MA_push_stack(C_DBL, 2*user.n, "Vector buffers", &user.memHandle) == MA_FALSE) GA_Error((char*)"MAIN::ma_alloc_get failed",2*user.n); /* Allocate Global Array vector for the solution */ int dims[2]; dims[0] = user.n; ga_x = NGA_Create (C_DBL, 1, dims, (char*)"GA_X", NULL); if (!ga_x) GA_Error ((char*)"lennard-jones.main::NGA_Create ga_x", ga_x); /* The TAO code begins here */ /* Create TAO solver with desired solution method */ info = TaoCreate (MPI_COMM_WORLD, "tao_cg", &tao); CHKERRQ(info); info = TaoGAApplicationCreate (MPI_COMM_WORLD, &taoapp); CHKERRQ(info); /* Set initial vector */ info = InitializeVariables(ga_x, &user); CHKERRQ(info); info = TaoGAAppSetInitialSolutionVec(taoapp, ga_x); CHKERRQ(info); /* Set routines for function, gradient */ info = TaoGAAppSetObjectiveAndGradientRoutine (taoapp, FormFunctionGradient, (void *) &user); CHKERRQ(info); /* Check for TAO command line options */ info = TaoSetFromOptions (tao); CHKERRQ(info); /* SOLVE THE APPLICATION */ info = TaoSolveGAApplication (taoapp, tao); CHKERRQ(info); /* To View TAO solver information use */ info = TaoView(tao); CHKERRQ(info); /* Get termination information */ info = TaoGetTerminationReason (tao, &reason); CHKERRQ(info); if (reason <= 0) printf("Try a different TAO method, adjust some parameters, or check the function evaluation routines\n"); printf("TIME TAKEN = %lf\n", MPI_Wtime()-startTime); /*output the solutions */ printf ("The solution is :\n"); GA_Print (ga_x); /* Free TAO data structures */ info = TaoDestroy (tao); CHKERRQ(info); info = TaoGAAppDestroy (taoapp); CHKERRQ(info); /* Free GA data structures */ GA_Destroy (ga_x); if (!MA_pop_stack(user.memHandle)) GA_Error((char*)"Main::MA_pop_stack failed",0); /* Finalize TAO, GA, and MPI */ TaoFinalize (); GA_Terminate (); MPI_Finalize (); return 0; }
//----------------------------------------------------------------------------------------------------// // This is the message handler function for the main dialog box. It is responsible for handling // any interaction with it's controls and for updating the trajectory views that we'll be displaying. //----------------------------------------------------------------------------------------------------// LRESULT CALLBACK DemoDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) //----------------------------------------------------------------------------------------------------// { static HWND hTopView; static HWND hSideView; WNDCLASSEX wclass; char str[16]; int status; RECT r; HDC hdc; switch (message) { // Initialize the dialog box here: case WM_INITDIALOG: // setup a child window class so we can create a couple // of windows to draw the two trajectory views on wclass.cbSize = sizeof(wclass); wclass.style = CS_HREDRAW | CS_VREDRAW; wclass.lpfnWndProc = DefaultWndProc; wclass.cbClsExtra = 0; wclass.cbWndExtra = 0; wclass.hInstance = hinst; wclass.hIcon = NULL; wclass.hCursor = NULL; wclass.hbrBackground = (HBRUSH) CreateSolidBrush(RGB(0,0,0)); wclass.lpszMenuName = NULL; wclass.lpszClassName = "ViewClass"; wclass.hIconSm = NULL; RegisterClassEx(&wclass); // Now go ahead and create a child window for the top view hTopView = CreateWindowEx( 0L, "ViewClass", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER, 150, 10, 500, 200, hDlg, NULL, hinst, NULL); // Tag the window with our identifier, MYTOPVIEW, so that we // can distinguish it from the side view window when it's time // to draw in the window. SetWindowLong(hTopView, GWL_USERDATA, MYTOPVIEW); // Show the window ShowWindow(hTopView, SW_SHOW); UpdateWindow(hTopView); // Now go ahead and create a child window for the side view hSideView = CreateWindowEx( 0L, "ViewClass", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER, 150, 10+10+200, 500, 200, hDlg, NULL, hinst, NULL); // Tag the window with our identifier, MYSIDEVIEW, so that we // can distinguish it from the top view window when it's time // to draw in the window. SetWindowLong(hSideView, GWL_USERDATA, MYSIDEVIEW); // Show the window ShowWindow(hSideView, SW_SHOW); UpdateWindow(hSideView); // Now initialize all of the edit controls on the dialog box with our // default values for each variable. // Set default values for all variables InitializeVariables(); // Now convert each variable value to a string and // set the appropriate edit control sprintf( str, "%f", Vm ); SetDlgItemText(hDlg, IDC_VM, str); sprintf( str, "%f", Alpha ); SetDlgItemText(hDlg, IDC_ALPHA, str); sprintf( str, "%f", Gamma ); SetDlgItemText(hDlg, IDC_GAMMA, str); sprintf( str, "%f", L ); SetDlgItemText(hDlg, IDC_L, str); sprintf( str, "%f", Yb ); SetDlgItemText(hDlg, IDC_YB, str); sprintf( str, "%f", X ); SetDlgItemText(hDlg, IDC_X, str); sprintf( str, "%f", Y ); SetDlgItemText(hDlg, IDC_Y, str); sprintf( str, "%f", Z ); SetDlgItemText(hDlg, IDC_Z, str); sprintf( str, "%f", Length ); SetDlgItemText(hDlg, IDC_LENGTH, str); sprintf( str, "%f", Width ); SetDlgItemText(hDlg, IDC_WIDTH, str); sprintf( str, "%f", Height ); SetDlgItemText(hDlg, IDC_HEIGHT, str); break; // handle the dialog controls here: case WM_COMMAND: switch( LOWORD( wParam) ) { case IDC_REFRESH: // update the variables with // the values shown in the edit controls GetDlgItemText(hDlg, IDC_VM, str, 15); Vm = atof(str); GetDlgItemText(hDlg, IDC_ALPHA, str, 15); Alpha = atof(str); GetDlgItemText(hDlg, IDC_GAMMA, str, 15); Gamma = atof(str); GetDlgItemText(hDlg, IDC_L, str, 15); L = atof(str); GetDlgItemText(hDlg, IDC_YB, str, 15); Yb = atof(str); GetDlgItemText(hDlg, IDC_X, str, 15); X = atof(str); GetDlgItemText(hDlg, IDC_Y, str, 15); Y = atof(str); GetDlgItemText(hDlg, IDC_Z, str, 15); Z = atof(str); GetDlgItemText(hDlg, IDC_LENGTH, str, 15); Length = atof(str); GetDlgItemText(hDlg, IDC_WIDTH, str, 15); Width = atof(str); GetDlgItemText(hDlg, IDC_HEIGHT, str, 15); Height = atof(str); // re-initialize the time and position of the shell time = 0; s.i = 0; s.j = 0; s.k = 0; // Repaint the views hdc = GetDC(hTopView); GetClientRect(hTopView, &r); DrawTopView(hdc, &r); ReleaseDC(hTopView, hdc); hdc = GetDC(hSideView); GetClientRect(hSideView, &r); DrawSideView(hdc, &r); ReleaseDC(hSideView, hdc); break; case IDC_FIRE: // update the variables with // the values shown in the edit controls GetDlgItemText(hDlg, IDC_VM, str, 15); Vm = atof(str); GetDlgItemText(hDlg, IDC_ALPHA, str, 15); Alpha = atof(str); GetDlgItemText(hDlg, IDC_GAMMA, str, 15); Gamma = atof(str); GetDlgItemText(hDlg, IDC_L, str, 15); L = atof(str); GetDlgItemText(hDlg, IDC_YB, str, 15); Yb = atof(str); GetDlgItemText(hDlg, IDC_X, str, 15); X = atof(str); GetDlgItemText(hDlg, IDC_Y, str, 15); Y = atof(str); GetDlgItemText(hDlg, IDC_Z, str, 15); Z = atof(str); GetDlgItemText(hDlg, IDC_LENGTH, str, 15); Length = atof(str); GetDlgItemText(hDlg, IDC_WIDTH, str, 15); Width = atof(str); GetDlgItemText(hDlg, IDC_HEIGHT, str, 15); Height = atof(str); // initialize the time and status variables status = 0; time = 0; // start stepping through time for the sim. // until the target is hit, the shell hits // the ground, or the sim. times out. while(status == 0) { // do the next time step status = DoSimulation(); // update the views hdc = GetDC(hTopView); GetClientRect(hTopView, &r); DrawTopView(hdc, &r); ReleaseDC(hTopView, hdc); hdc = GetDC(hSideView); GetClientRect(hSideView, &r); DrawSideView(hdc, &r); ReleaseDC(hSideView, hdc); } // Report results if (status == 1) MessageBox(NULL, "Direct Hit", "Score!", MB_OK); if (status == 2) MessageBox(NULL, "Missed Target", "No Score.", MB_OK); if (status == 3) MessageBox(NULL, "Timed Out", "Error", MB_OK); break; case ID_CLOSE: // clean up the child windows and close the dialog box DestroyWindow(hTopView); DestroyWindow(hSideView); EndDialog(hDlg, 1); break; case IDCANCEL: // clean up the child windows and close the dialog box DestroyWindow(hTopView); DestroyWindow(hSideView); EndDialog(hDlg, 0); break; } break; default: return( FALSE ); } return ( TRUE ); }
CISO::CISO() { // TRACE("CISO::CTR #2\n"); m_szIniFile[0] = 0; InitializeVariables(); }
CISO::CISO(char *inifile) { // TRACE("CISO::CTR #1\n"); strncpy(m_szIniFile,inifile,sizeof(m_szIniFile)); InitializeVariables(); }
ProfileInfo::ProfileInfo(CString &csFilename) { InitializeVariables(); m_csFilename = csFilename; }
ProfileInfo::ProfileInfo() { InitializeVariables(); }