const bool AreaLight::Write(std::ostream &stream) const { if( !WriteHeader( stream, "AreaLight" ) ) return false; Indent(); { // Write the base if( !Light::Write( stream ) ) return false; if( !WriteVariable( stream, "vertex1", _v1 ) || !WriteVariable( stream, "vertex2", _v2 ) || !WriteVariable( stream, "vertex3", _v3 ) || !WriteVariable( stream, "numHorizontalSamples", _numHorizontalSamples ) || !WriteVariable( stream, "numVerticalSamples", _numVerticalSamples ) ) return false; } Unindent(); if( !WriteFooter( stream, "AreaLight" ) ) return false; return true; }
void WriteOutput(FILE * f) { IVAR iout, ivar; VARPTR var, vout; int i; iout = CheckOutVar(); if (iout == 0) { Fprintf(f, indent, "LhsVar(1)=0;\n;return 0;\n"); } else { vout = variables[iout - 1]; switch (vout->type) { case LIST: case TLIST: case MLIST: Fprintf(f, indent, "/* Creation of output %s of length %d*/\n", SGetSciType(vout->type), vout->length); vout->stack_position = icre; icre++; Fprintf(f, indent, "Create%s(%d,%d);\n", SGetSciType(vout->type), vout->stack_position, vout->length); /* loop on output variables */ for (i = 0; i < vout->length; i++) { ivar = vout->el[i]; var = variables[ivar - 1]; Fprintf(f, indent, "/* Element %d: %s*/\n", i + 1, var->name); WriteVariable(f, var, ivar, 1, i + 1); } Fprintf(f, indent, "LhsVar(1)= %d;\nreturn 0;", vout->stack_position); break; case SEQUENCE: /* loop on output variables */ for (i = 0; i < vout->length; i++) { ivar = vout->el[i]; var = variables[ivar - 1]; WriteVariable(f, var, ivar, 0, 0); } Fprintf(f, indent, "return 0;\n"); break; case EMPTY: Fprintf(f, indent, "LhsVar(1)=0;\n;return 0;\n"); break; } } Fprintf(f, --indent, "}\n"); }
void GBStackBrain::ExecuteInstruction(GBStackInstruction ins, GBRobot * robot, GBWorld * world) { GBStackInstruction index = ins & kOpcodeIndexMask; switch ( ins >> kOpcodeTypeShift ) { case otPrimitive: ExecutePrimitive(index, robot, world); break; case otConstantRead: Push(spec->ReadConstant(index)); break; case otVariableRead: Push(ReadVariable(index)); break; case otVariableWrite: WriteVariable(index, Pop()); break; case otVectorRead: PushVector(ReadVectorVariable(index)); break; case otVectorWrite: WriteVectorVariable(index, PopVector()); break; case otLabelRead: Push(spec->ReadLabel(index)); break; case otLabelCall: ExecuteCall(spec->ReadLabel(index)); break; case otHardwareRead: Push(ReadHardware(index, robot, world)); break; case otHardwareWrite: WriteHardware(index, Pop(), robot, world); break; case otHardwareVectorRead: PushVector(ReadHardwareVector(index, robot, world)); break; case otHardwareVectorWrite: WriteHardwareVector(index, PopVector(), robot, world); break; default: throw GBUnknownInstructionError(); break; } }
void MainThread (void const *argument) { static uint16_t last_pic_id = 0; static MENU_ID last_menu_id = MENU_ID_MENU; LaserDiodeInput_Init(pic_id); SolidStateLaserInput_Init(pic_id); LongPulseLaserInput_Init(pic_id); GetDateTime(g_wDGUSTimeout, &datetime); while (1) { ; // Insert thread code here... pic_id = GetPicId(g_wDGUSTimeout, pic_id); GetDateTime(g_wDGUSTimeout, &datetime); last_menu_id = MenuID; UpdateLaserState(pic_id); LaserID = GetLaserID(); // GUI Frames process switch (pic_id) { case FRAME_PICID_LOGO: SetPicId(FRAME_PICID_MAINMENU, g_wDGUSTimeout); break; // Frames process case FRAME_PICID_PASSWORD: PasswordFrame_Process(pic_id); break; case FRAME_PICID_SERVICE_SOLIDSTATELASER: ServiceFrame_Process(pic_id); break; case FRAME_PICID_SERVICE_LASERDIODE: ServiceDiodeFrame_Process(pic_id); break; case FRAME_PICID_SERVICE_BASICSETTINGS: break; // Blank picture, for future release case FRAME_PICID_SERVICECOOLING: CoolingServiceFrame_Process(pic_id); UpdateLaserStatus(); break; // Laser Diode control case FRAME_PICID_LASERDIODE_INPUT: #ifdef LASERIDCHECK_LASERDIODE if (GetLaserID() == LASER_ID_DIODELASER) { if (last_pic_id != pic_id && last_menu_id != MenuID) LaserDiodeInput_Init(pic_id); LaserDiodeInput_Process(pic_id); } else SetPicId(FRAME_PICID_WRONG_EMMITER, g_wDGUSTimeout); #else if (last_pic_id != pic_id && last_menu_id != MenuID) LaserDiodeInput_Init(pic_id); LaserDiodeInput_Process(pic_id); #endif UpdateLaserStatus(); break; case FRAME_PICID_LASERDIODE_TEMPERATUREOUT: case FRAME_PICID_LASERDIODE_PREPARETIMER: case FRAME_PICID_LASERDIODE_FLOWERROR: LaserDiodePrepare_Process(pic_id); UpdateLaserStatus(); break; case FRAME_PICID_LASERDIODE_READY: case FRAME_PICID_LASERDIODE_START: case FRAME_PICID_LASERDIODE_STARTED: LaserDiodeWork_Process(pic_id); case FRAME_PICID_LASERDIODE_PHOTOTYPE: UpdateLaserStatus(); break; // WiFi features case FRAME_PICID_SERVICE_WIFISCANNINGINIT: WifiScanningFrame_Init(pic_id); break; case FRAME_PICID_SERVICE_WIFISCANNING: WifiScanningFrame_Process(pic_id); break; case FRAME_PICID_SERVICE_WIFIAUTHENTICATION: WifiAuthenticationFrame_Process(pic_id); break; case FRAME_PICID_WIFI_LINKING: WiFiLinkFrame_Process(); break; // App idle user state case FRAME_PICID_MAINMENU: if (ip_addr_updated) { WriteVariable(FRAMEDATA_WIFIUP_IPADDR, ip_addr, 16); osSignalWait(DGUS_EVENT_SEND_COMPLETED, g_wDGUSTimeout); ip_addr_updated = false; } StopIfRunning(last_pic_id); case FRAME_PICID_SERVICE: case FRAME_PICID_LANGMENU: // nothing to do break; // Solid State Laser case FRAME_PICID_SOLIDSTATE_INPUT: if (last_pic_id != pic_id && last_menu_id != MenuID) SolidStateLaserInput_Init(pic_id); if (GetLaserID() == LASER_ID_SOLIDSTATE || GetLaserID() == LASER_ID_SOLIDSTATE2) SolidStateLaserInput_Process(pic_id); else SetPicId(FRAME_PICID_WRONG_EMMITER, g_wDGUSTimeout); UpdateLaserStatus(); break; case FRAME_PICID_SOLIDSTATE_SIMMERSTART: case FRAME_PICID_SOLIDSTATE_SIMMER: case FRAME_PICID_SOLIDSTATE_START: case FRAME_PICID_SOLIDSTATE_WORK: SolidStateLaserWork_Process(pic_id); UpdateLaserStatus(); break; case FRAME_PICID_SOLIDSTATE_FLOWERROR: case FRAME_PICID_SOLIDSTATE_OVERHEATING: case FRAME_PICID_SOLIDSTATE_FAULT: SolidStateLaserPrepare_Process(pic_id); UpdateLaserStatus(); break; // Long Pulse Laser case FRAME_PICID_LONGPULSE_INPUT: if (last_pic_id != pic_id && last_menu_id != MenuID) LongPulseLaserInput_Init(pic_id); LongPulseLaserInput_Process(pic_id); UpdateLaserStatus(); /* if (GetLaserID() == LASER_ID_LONGPULSE) LongPulseLaserInput_Process(pic_id); else SetPicId(FRAME_PICID_WRONG_EMMITER, g_wDGUSTimeout);*/ break; case FRAME_PICID_LONGPULSE_SIMMERSTART: case FRAME_PICID_LONGPULSE_SIMMER: if (GetLaserID() == LASER_ID_LONGPULSE) LongPulseLaserWork_Process(pic_id); else SetPicId(FRAME_PICID_WRONG_EMMITER, g_wDGUSTimeout); UpdateLaserStatus(); break; case FRAME_PICID_LONGPULSE_START: case FRAME_PICID_LONGPULSE_WORK: LongPulseLaserWork_Process(pic_id); UpdateLaserStatus(); break; case FRAME_PICID_LONGPULSE_FLOWERROR: case FRAME_PICID_LONGPULSE_OVERHEATING: case FRAME_PICID_LONGPULSE_FAULT: LongPulseLaserPrepare_Process(pic_id); UpdateLaserStatus(); break; case FRAME_PICID_BASICSETTINGS: UpdateLaserStatus(); break; case FRAME_PICID_LOGVIEW: LogFrame_Process(pic_id); break; case FRAME_PICID_WRONG_EMMITER: osDelay(800); SetPicId(FRAME_PICID_MAINMENU, g_wDGUSTimeout); break; case FRAME_PICID_REMOTECONTROL: break; default: SetPicId(FRAME_PICID_MAINMENU, g_wDGUSTimeout); break; } // Remote control if (RemoteControl) { if (pic_id == FRAME_PICID_MAINMENU) SetPicId(FRAME_PICID_REMOTECONTROL, g_wDGUSTimeout); } else if (pic_id == FRAME_PICID_REMOTECONTROL) { SetPicId(FRAME_PICID_MAINMENU, g_wDGUSTimeout); //pic_id = FRAME_PICID_MAINMENU; } last_pic_id = pic_id; osThreadYield (); // suspend thread } }