void fan(int c, int p , int v){ if(p <= tree[c].l && v >= tree[c].r) { fxor(c); return ; } Pushdown(c); if(v <= tree[c].m ) fan(L(c),p,v); else if(p > tree[c].m) fan(R(c),p,v); else { fan(L(c),p,tree[c].m); fan(R(c),tree[c].m+1,v); } Pushup(c); }
void StateContext::setup() { fan()->setup(); display()->setup(); led()->setup(); sensor()->setup(); button()->setup(); }
int main(void) { int f,res,b[300],ji; char a[300][20],c[20]; while(scanf("%s",&a[0])!=EOF) { strcpy(c,a[0]); res=pan(a[0]); ji=1; for(ji=1;0==res;ji++) { b[ji]=tod(a[ji-1]); fan(a[ji-1]); b[ji]=b[ji]+tod(a[ji-1]); tos(b[ji],a[ji]); res=pan(a[ji]); } printf("%d\n",ji-1); printf("%s",c); for(f=1;f<ji;f++) { printf("--->"); printf("%s",a[f]); } printf("\n"); } return 0; }
void StateContext::update() { fan()->update(); display()->update(); led()->update(); sensor()->update(); button()->update(); }
void AirTerminalSingleDuctParallelPIUReheat_Impl::setFanAvailabilitySchedule(Schedule & schedule) { auto component = fan(); if( auto constantFan = component.optionalCast<FanConstantVolume>() ) { constantFan->setAvailabilitySchedule(schedule); } else if( auto onOffFan = component.optionalCast<FanOnOff>() ) { onOffFan->setAvailabilitySchedule(schedule); } else if( auto variableFan = component.optionalCast<FanVariableVolume>() ) { variableFan->setAvailabilitySchedule(schedule); } };
int main() { startDaemon(); Fan fan("/sys/devices/platform/applesmc.768", "fan1"); Sensor coreOne( "/sys/devices/platform/applesmc.768/subsystem/devices/coretemp.0", "temp2"); Sensor coreTwo( "/sys/devices/platform/applesmc.768/subsystem/devices/coretemp.0", "temp3"); Load load("/proc", "stat"); fan.writeContent(fan.getPath() + "/" + fan.getName() + "_manual", "1"); #if FANMINSPEED fan.setFanMinSpeed(FANMINSPEED); #endif #if FANMAXSPEED fan.setFanMaxSpeed(FANMAXSPEED); #endif int loadFactor = (fan.getFanMaxSpeed() - fan.getFanMinSpeed()) / (LOADSCALETO - LOACSCALEFROM); int sensorFacotor = (fan.getFanMaxSpeed() - fan.getFanMinSpeed()) / (SENSORSCALETO - SENSORSCALEFROM); while (1) { double loadAverage = 0; double sensorAverage = 0; for (int i = 0; i < AVERAGECOUNT; i++) { loadAverage += load.getAverage(); sensorAverage += (coreOne.getTemp() + coreTwo.getTemp()); sleep(SLEEPTIME); } loadAverage = loadAverage / AVERAGECOUNT; sensorAverage = sensorAverage / ((2 * AVERAGECOUNT) * 100000); logToFile(DAEMON_LOG, dtos(loadAverage).c_str()); logToFile(DAEMON_LOG, dtos(sensorAverage).c_str()); if (loadAverage > LOACSCALEFROM) { fan.setSpeed( fan.getFanMinSpeed() + loadFactor * (loadAverage - LOACSCALEFROM)); } else { fan.setSpeed( fan.getFanMinSpeed() + sensorFacotor * (sensorAverage - SENSORSCALEFROM)); } } return (0); }
int SlotFan::GetCardTypeIDFromHardware() { FANPOW_OnLine fan(SlotFan::GetSn()); int rtnV = 0; if( mod.processFANCommand(fan) == DEFErrorSuccess ) { uint8* result = fan.getResultBuff(); if( result[1] != 0 ) { rtnV = FAN_CARD_TYPEID; } } return rtnV; }
int main() { int t; // freopen("/home/plac/problem/input.txt","r",stdin); scanf("%d",&t); // freopen("/home/plac/problem/output.txt","w",stdout); for(int CASE = 1; CASE <= t; CASE ++){ int n ; scanf("%d",&n); scanf("%s",str); build(1,0,n-1); int q; scanf("%d",&q); printf("Case %d:\n",CASE); while(q--) { int a, b ; char t1[10],t2[2]; scanf("%s %d %d",t1,&a,&b); if(t1[0] == 'r'){ fan(1,a,b); }else if(t1[0] == 'q'){ tsum = 0 ; ok = 1; getsum(1,a,b); if(ok == 1 && tsum == 0 && (b-a+1)%2 == 0) printf("YES\n"); else printf("NO\n"); }else{ scanf("%s",t2); if(t2[0] == '(') update(1,a,b,1); else update(1,a,b,-1); } } printf("\n"); } return 0 ; }
ZoneHVACTerminalUnitVariableRefrigerantFlow::ZoneHVACTerminalUnitVariableRefrigerantFlow(const Model& model) : ZoneHVACComponent(ZoneHVACTerminalUnitVariableRefrigerantFlow::iddObjectType(),model) { OS_ASSERT(getImpl<detail::ZoneHVACTerminalUnitVariableRefrigerantFlow_Impl>()); Schedule alwaysOnSchedule = model.alwaysOnDiscreteSchedule(); setTerminalUnitAvailabilityschedule(alwaysOnSchedule); autosizeSupplyAirFlowRateDuringCoolingOperation(); autosizeSupplyAirFlowRateWhenNoCoolingisNeeded(); autosizeSupplyAirFlowRateDuringHeatingOperation(); autosizeSupplyAirFlowRateWhenNoHeatingisNeeded(); autosizeOutdoorAirFlowRateDuringCoolingOperation(); autosizeOutdoorAirFlowRateDuringHeatingOperation(); autosizeOutdoorAirFlowRateWhenNoCoolingorHeatingisNeeded(); setSupplyAirFanOperatingModeSchedule(alwaysOnSchedule); setZoneTerminalUnitOnParasiticElectricEnergyUse(30); setZoneTerminalUnitOffParasiticElectricEnergyUse(20); setRatedTotalHeatingCapacitySizingRatio(1.0); CoilCoolingDXVariableRefrigerantFlow coolingCoil(model); coolingCoil.setName(name().get() + " Cooling Coil"); getImpl<detail::ZoneHVACTerminalUnitVariableRefrigerantFlow_Impl>()->setCoolingCoil(coolingCoil); CoilHeatingDXVariableRefrigerantFlow heatingCoil(model); heatingCoil.setName(name().get() + " Heating Coil"); getImpl<detail::ZoneHVACTerminalUnitVariableRefrigerantFlow_Impl>()->setHeatingCoil(heatingCoil); FanOnOff fan(model,alwaysOnSchedule); fan.setName(name().get() + " Fan"); getImpl<detail::ZoneHVACTerminalUnitVariableRefrigerantFlow_Impl>()->setSupplyAirFan(fan); }
// Genera los grafos usados para optimizar las heurísticas vector<vector<nodo>> generar_grafos() { vector<vector<nodo>> grafos; int initial = 1; int max = 10; int increment = 1; // Familia lattice for(int m = initial; m <= max; m += increment) for(int n = initial; n <= max; n += increment) { grafos.push_back(lattice(m, n)); } // Familia (K_n U Claw_m)^c for(int m = initial; m <= max; m += increment) for(int n = initial; n <= max; n += increment) { grafos.push_back(kn_union_claw_m_complemento(m, n)); } // Familia lollipop for(int m = initial; m <= max; m += increment) for(int n = initial; n <= max; n += increment) { grafos.push_back(lollipop(m, n)); } // Familia fan for(int m = initial; m <= max; m += increment) for(int n = initial; n <= max; n += increment) { grafos.push_back(fan(m, n)); } // Familia ninja for(int n = initial; n <= max; n += increment) { grafos.push_back(ninja(n)); } return grafos; }
// HarmonicOscillator(int ssamples, int ccontrols){ HarmonicOscillator() { Nstate = controls; HeightConstant = controls; // increasing HALFd moves center of waveform to the right HALFd = controls / 2.0f; // 5.0f, samples / 10 // int HalfSize= samples / 10; // increasing HalfSize moves center of waveform to the right HalfSize = samples / controls; // 21, samples / 10 // controlvalues = new int[controls]; // Fill the coefficient array used in functions PSI_n_form() for(int j=0; j<HeightConstant; j++) alfan[j] = fan(j); nfact[0] = 1.0f; for(int j=1; j<HeightConstant; j++) nfact[j] = nfact[j-1]*(float)j; initialisePSIArray(); }
OptionalModelObject ReverseTranslator::translateFanConstantVolume( const WorkspaceObject & workspaceObject ) { OptionalModelObject result,temp; OptionalSchedule schedule; OptionalWorkspaceObject owo = workspaceObject.getTarget(Fan_ConstantVolumeFields::AvailabilityScheduleName); if(!owo) { LOG(Error, "Error importing object: " << workspaceObject.briefDescription() << " Can't find Schedule: "); return result; } temp = translateAndMapWorkspaceObject( *owo); if(temp) { schedule = temp->optionalCast<Schedule>(); } if( !schedule ) { LOG(Error, "Error importing object: " << workspaceObject.name().get() <<"Failed to convert iddObjects into model Objects. Maybe they do not exist in model yet"); return result; } openstudio::model::FanConstantVolume fan( m_model, *schedule ); OptionalString optS = workspaceObject.name(); if(optS) { fan.setName(*optS); } //inlet and outlet nodes are set my the HVACAirLoop OptionalDouble d; d = workspaceObject.getDouble(openstudio::Fan_ConstantVolumeFields::FanTotalEfficiency); if(d) { fan.setFanEfficiency(*d); } d = workspaceObject.getDouble(openstudio::Fan_ConstantVolumeFields::PressureRise); if(d) { fan.setPressureRise(*d); } d = workspaceObject.getDouble(openstudio::Fan_ConstantVolumeFields::MaximumFlowRate); if(d) { fan.setMaximumFlowRate(*d); } d = workspaceObject.getDouble(openstudio::Fan_ConstantVolumeFields::MotorEfficiency); if(d) { fan.setMotorEfficiency(*d); } d = workspaceObject.getDouble(openstudio::Fan_ConstantVolumeFields::MotorInAirstreamFraction); if(d) { fan.setMotorInAirstreamFraction(*d); } optS=workspaceObject.getString(openstudio::Fan_ConstantVolumeFields::EndUseSubcategory); if(optS) { fan.setEndUseSubcategory(*optS); } result=fan; return result; }
int main(int argc, char **argv) { glutInit(&argc,argv); my_setup(canvas_Width,canvas_Height,canvas_Name); vector <int >new_fan; if(argc!=2){ cout<<"<usuage>:mismatched arguments"<<endl; exit(0); } ifstream mesh_input(argv[1]); if(mesh_input.is_open()) read_input_mesh(mesh_input,v_count,f_count,d_vb,d_ib); else{ cout<<"Cannot open input mesh"<<endl; exit(0); } mesh_input.close();//Finised with reading mesh data vector < vector<int> >fan(v_count); vector < vector<edge> >e(v_count); create_lists(e,d_ib,f_count); //delete[]d_ib;//done with index buffer list triangle_fan_create(e,d_vb,fan); output=new vertex_buffer[v_count]; size=fan[0].size(); for(int i=0;i<fan.size();i++){ for(int j=0;j<size;j++){ new_fan.push_back(fan[i][j]); } } test=&new_fan[0]; clock_t start=clock(); for(int i=0;i<10;i++) zhou_shimada(d_vb,output,test,fan[0].size(),v_count); clock_t stop=clock(); cout<<"Elapsed time="<<(double)((stop-start))/CLOCKS_PER_SEC<<endl; // print_output(output,v_count); glutDisplayFunc(display_func); glutKeyboardFunc(keyboard); glutMainLoop(); return 0; }
static bool const buildCircleData (float radius, const unsigned int subdivisions, const osg::Vec3& orientation, osg::Geometry* geom, const bool wire ) { unsigned int numSub( subdivisions ); unsigned int totalVerts(0); if( numSub < 3 ) numSub = 3; if( numSub > 65530 ) { // Would create index array too large for use with DrawElementsUShort. Clamp. numSub = 65530; // leave headroom for a few spares osg::notify( osg::WARN ) << "buildCircleData: Clamping subdivisions to " << numSub << std::endl; } totalVerts = ( (numSub+2) ); // +2: Center, and final, closing vertex osg::notify( osg::INFO ) << "buildCircleData: totalVerts: " << totalVerts << std::endl; // Create data arrays and configure the Geometry osg::ref_ptr< osg::Vec3Array > vertices( new osg::Vec3Array ); vertices->resize( totalVerts ); geom->setVertexArray( vertices.get() ); osg::ref_ptr< osg::Vec3Array > normals; osg::ref_ptr< osg::Vec2Array > texCoords; if( !wire ) { normals = new osg::Vec3Array; normals->resize( totalVerts ); geom->setNormalArray( normals.get() ); geom->setNormalBinding( osg::Geometry::BIND_PER_VERTEX ); texCoords = new osg::Vec2Array; texCoords->resize( totalVerts ); geom->setTexCoordArray( 0, texCoords.get() ); } { osg::Vec4Array* osgC = new osg::Vec4Array; osgC->push_back( osg::Vec4( 1., 1., 1., 1. ) ); geom->setColorArray( osgC ); geom->setColorBinding( osg::Geometry::BIND_OVERALL ); } // Create the vertices, normals, and tex coords. unsigned int idx( 0 ); unsigned int subCounter; const osg::Vec3 centerVecZero( 0., 0., 0. ); osg::Vec3 normalVec( orientation ); normalVec.normalize(); // center: idx=0 (*vertices)[ idx ] = centerVecZero; if( !wire ) { (*normals)[ idx ] = normalVec; (*texCoords)[ idx ].set( centerVecZero.x(), centerVecZero.y() ); } // if idx++; // Find ideal base vector (at 90 degree angle to normalVec) osg::Vec3 crossVec( 1., 0., 0. ); if( osg::absolute( normalVec * crossVec ) > .9 ) crossVec = osg::Vec3( 0., 1., 0. ); osg::Vec3 baseVec = normalVec ^ crossVec; baseVec.normalize(); // circle-loop for( subCounter=0; subCounter<=numSub; subCounter++ ) { const double t( (double)(subCounter) / (double)numSub ); const double subAngle( t * 2.0 * osg::PI); // subAngle is in range (0,2pi) radians. osg::Matrix m( osg::Matrix::rotate( subAngle, normalVec ) ); osg::Vec3 v( baseVec * m ); (*vertices)[ idx ] = ( v * radius ); //osg::notify( osg::ALWAYS ) << v << std::endl; if( !wire ) { (*normals)[ idx ] = normalVec; const osg::Vec3 vRad(v * radius); (*texCoords)[ idx ].set( vRad.x(), vRad.y() ); } // if idx++; } if( idx != totalVerts ) { osg::notify( osg::WARN ) << "buildCircleData: Error creating vertices." << std::endl; osg::notify( osg::WARN ) << " idx " << idx << " != totalVerts " << totalVerts << std::endl; } // Create PrimitiveSets. if( !wire ) { // Solid -- Use GL_TRIANGLE_FAN // Create indices -- top group of triangles osg::DrawElementsUShort* fan( new osg::DrawElementsUShort( GL_TRIANGLE_FAN ) ); fan->resize( numSub+2 ); // center, 1...n, 1 again to close idx = 0; // push center (*fan)[ idx ] = 0; idx++; // circle loop for( unsigned int subCount=0; subCount<numSub+1; subCount++ )// numsub+1 gets us start, ring and end (which duplicates start) { (*fan)[ idx ] = idx; idx++; } geom->addPrimitiveSet( fan ); } // if !wire else { // Wire -- Use GL_LINE_LOOP // we skip vertex #0 (center) when drawing the LINE_LOOP // Create indices osg::DrawElementsUShort* ring; ring = new osg::DrawElementsUShort( GL_LINE_LOOP ); ring->resize( numSub+1 ); unsigned int loopIdx; for( loopIdx=0; loopIdx<numSub+1; loopIdx++ ) // numsub+1 gets us start, ring and end (which duplicates start) { (*ring)[ loopIdx ] = loopIdx + 1; // skipping #0, center } // for geom->addPrimitiveSet( ring ); } // wire return( true ); } // buildCircleData
static bool buildAltAzSphereData( const float radius, const unsigned int subLat, const unsigned int subLong, osg::Geometry* geom, const bool wire ) { unsigned int numLat( subLat ); unsigned int numLong( subLong ); if( numLat < 2 ) numLat = 2; if( numLong < 4 ) numLong = 4; unsigned int totalVerts( (numLat+1) * (numLong+1) ); if( totalVerts > 65535 ) { // Would create index array too large for use with DrawElementsUShort. // For now, clamp. In the future, just use DrawElementsUInt. osg::notify( osg::WARN ) << "makeAltAzSphere: Clamping subdivisions to 128x256." << std::endl; numLat = 128; numLong = 256; totalVerts = ( (numLat+1) * (numLong+1) ); } osg::notify( osg::INFO ) << "makeAltAzSphere: totalVerts: " << totalVerts << std::endl; // Create data arrays and configure the Geometry osg::ref_ptr< osg::Vec3Array > vertices( new osg::Vec3Array ); vertices->resize( totalVerts ); geom->setVertexArray( vertices.get() ); osg::ref_ptr< osg::Vec3Array > normals; osg::ref_ptr< osg::Vec2Array > texCoords; if( !wire ) { normals = new osg::Vec3Array; normals->resize( totalVerts ); geom->setNormalArray( normals.get() ); geom->setNormalBinding( osg::Geometry::BIND_PER_VERTEX ); texCoords = new osg::Vec2Array; texCoords->resize( totalVerts ); geom->setTexCoordArray( 0, texCoords.get() ); } { osg::Vec4Array* osgC = new osg::Vec4Array; osgC->push_back( osg::Vec4( 1., 1., 1., 1. ) ); geom->setColorArray( osgC ); geom->setColorBinding( osg::Geometry::BIND_OVERALL ); } // Create the vertices, normals, and tex coords. unsigned int idx( 0 ); unsigned int latCounter; for( latCounter=numLat+1; latCounter>0; latCounter-- ) { const double t( (double)(latCounter-1) / (double)numLat ); const double latAngle( (t-0.5) * osg::PI ); // latAngle is in range (-pi/2,pi/2) radians. const osg::Vec3 baseVec( cos( latAngle ), 0., sin( latAngle ) ); unsigned int longCounter; for( longCounter=0; longCounter<numLong; longCounter++ ) { const double s( (double)longCounter / (double)numLong ); const double longAngle( s * 2.0 * osg::PI ); // longAngle is in range (0,2pi) radians. const double sinAngle( sin( longAngle ) ); const double cosAngle( cos( longAngle ) ); osg::Vec3 v; v[ 0 ] = baseVec.x() * cosAngle + baseVec.y() * -sinAngle; v[ 1 ] = baseVec.x() * sinAngle + baseVec.y() * cosAngle; v[ 2 ] = baseVec.z(); (*vertices)[ idx ] = ( v * radius ); //osg::notify( osg::ALWAYS ) << v << std::endl; if( !wire ) { (*normals)[ idx ] = v; (*texCoords)[ idx ].set( s, t ); } idx++; } { // Close (required for texture mapping) osg::Vec3 v( baseVec ); (*vertices)[ idx ] = ( v * radius ); //osg::notify( osg::ALWAYS ) << v << std::endl; if( !wire ) { (*normals)[ idx ] = v; (*texCoords)[ idx ].set( 1., t ); } idx++; } } if( idx != totalVerts ) { osg::notify( osg::WARN ) << "AltAzSphere: Error creating vertices." << std::endl; osg::notify( osg::WARN ) << " idx " << idx << " != totalVerts " << totalVerts << std::endl; } // Create PrimitiveSets. if( !wire ) { // Solid -- Use GL_TRIANGLE_STRIPS // Create indices -- top group of triangles osg::DrawElementsUShort* fan( new osg::DrawElementsUShort( GL_TRIANGLES ) ); fan->resize( numLong*3 ); for( idx=0; idx<numLong; idx++ ) { (*fan)[ idx*3 ] = idx; (*fan)[ idx*3+1 ] = numLong + idx + 1; (*fan)[ idx*3+2 ] = numLong + idx + 2; } geom->addPrimitiveSet( fan ); // Create indices -- body osg::DrawElementsUShort* body; unsigned int baseIdx( numLong+1 ); unsigned int stripIdx; for( stripIdx=0; stripIdx<numLat-2; stripIdx++ ) { body = new osg::DrawElementsUShort( GL_TRIANGLE_STRIP ); body->resize( (numLong+1) * 2 ); unsigned int longCounter; for( longCounter=0; longCounter<numLong; longCounter++ ) { (*body)[ longCounter*2 ] = baseIdx; (*body)[ longCounter*2+1 ] = baseIdx + numLong+1; baseIdx++; } // Close strip (*body)[ longCounter*2 ] = baseIdx; (*body)[ longCounter*2+1 ] = baseIdx + numLong+1; baseIdx++; geom->addPrimitiveSet( body ); } // Create indices -- bottom group of triangles fan = new osg::DrawElementsUShort( GL_TRIANGLES ); fan->resize( numLong*3 ); for( idx=0; idx<numLong; idx++ ) { // 14 9 8, 13 8 7, 12 7 6, 11 6 5 (*fan)[ idx*3 ] = totalVerts - 1 - idx; (*fan)[ idx*3+1 ] = totalVerts - 1 - numLong - idx - 1; (*fan)[ idx*3+2 ] = totalVerts - 1 - numLong - idx - 2; } geom->addPrimitiveSet( fan ); } else { // Wire -- Use GL_LINE_LOOP and GL_LINE_STRIP // Create indices -- alt (latitude) osg::DrawElementsUShort* deus; unsigned int baseIdx( numLong+1 ); unsigned int loopIdx; for( loopIdx=0; loopIdx<numLat-1; loopIdx++ ) { deus = new osg::DrawElementsUShort( GL_LINE_LOOP ); deus->resize( numLong ); unsigned int longCounter; for( longCounter=0; longCounter<numLong; longCounter++ ) { (*deus)[ longCounter ] = baseIdx++; } // Skip closing vertex. baseIdx++; geom->addPrimitiveSet( deus ); } // Create indices -- az (longitude) const unsigned int vertsPerLat( numLong+1 ); unsigned int longCounter; for( longCounter=0; longCounter<numLong; longCounter++ ) { deus = new osg::DrawElementsUShort( GL_LINE_STRIP ); deus->resize( numLat+1 ); unsigned int latIdx; for( latIdx=0; latIdx<numLat+1; latIdx++ ) { (*deus)[ latIdx ] = longCounter + (vertsPerLat * latIdx); } geom->addPrimitiveSet( deus ); } } return( true ); }
int testgen(int iNoGate, int iNoPI, int iNoPO, int iMaxLevelAdd2, int iMaxBitSize, int iStem, GATEPTR *pStem, int iMaxBackTrack, int bPhase2, int *piNoRedundant, int *piNoOverBackTrack, int *piNoBackTrack, int *piNoPatterns, int *piPacket, int *piBit, double *plfFanTime, FILE *fpTestFile) // int nog, nopi, nopo, LEVEL, maxbits, nstem, maxbacktrack; // int phase; /* 0: static, 1:dynamic unique path sensitization */ // GATEPTR *stem; // int *nredundant,*noverbacktrack,*nbacktrack,*npacket,*nbit,*ntest; // double *fantime; // FILE *test; { //Intialization: piNoPatterns = 0 int j, iNoBackTrack; status iFaultSelectionMode; int iLastUndetectedFault; int iState; int iNoDetected = 0; FAULTTYPE *pLastUndetectedFault; bool bDone; GATEPTR pLastUndetectedGate; int iArrProfile[BITSIZE]; double lfSeconds, lfMinutes, lfRunTime1, lfRunTime2; iFaultSelectionMode = DEFAULTMODE; //iFaultSelectionMode always = DEFAULTMODE(0) iLastUndetectedFault = g_iNoFault; g_iAllOne = ~(ALL1 << 1); //0x00000001 bDone = FALSE; while (!bDone) { // iMaxBackTrack ============== 10 by default !! if (iMaxBackTrack == 0) //Impossible { break; } /* select any undetected and untried fault */ pLastUndetectedFault = NULL; switch (iFaultSelectionMode) { case CHECKPOINTMODE: //never come here // while (--iLastUndetectedFault >= 0) // if (is_undetected(g_pFaultList[iLastUndetectedFault])) // { // pLastUndetectedFault = g_pFaultList[iLastUndetectedFault]; // pLastUndetectedGate = pLastUndetectedFault->gate; // if (pLastUndetectedFault->line != OUTFAULT) // { // pLastUndetectedGate = pLastUndetectedGate->inList[pLastUndetectedFault->line]; // } // if (is_checkpoint(pLastUndetectedGate)) // { // break; // } // pLastUndetectedFault = NULL; // } // if (pLastUndetectedFault == NULL) // { // iFaultSelectionMode = DEFAULTMODE; // iLastUndetectedFault = g_iNoFault; // } break; default: //always come here while (--iLastUndetectedFault >= 0) { if (is_undetected(g_pFaultList[iLastUndetectedFault])) { //INPUT: pLastUndetectedFault pLastUndetectedFault = g_pFaultList[iLastUndetectedFault]; break; } } if (pLastUndetectedFault == NULL) { set(bDone); //OK Phase 1 } } //End Switch !!! if (pLastUndetectedFault == NULL) { continue; //OK Phase 2 ----------> EXIT !!!!! } pLastUndetectedGate = pLastUndetectedFault->gate; g_iNoPatternsForOneTime = 0; if (no_faultsim == 'y') //NOT default !!! { printfault(fpTestFile, pLastUndetectedFault, 0); if (logmode == 'y') { printfault(g_fpLogFile, pLastUndetectedFault, 0); } } fprintf(stderr, "iLastUndetectedFault=%d\n", iLastUndetectedFault); getTime(&lfMinutes, &lfSeconds, &lfRunTime1); /* test pattern generation using fan */ if (bPhase2 == FALSE) //Default !! { //iMaxBackTrack == 10 iState = fan(iNoGate, iMaxLevelAdd2, iNoPI, iNoPO, pLastUndetectedFault, iMaxBackTrack, &iNoBackTrack); //Output: iState & g_iPatternsForOneTime & iNoBackTrack & g_net[i] (PI, Test Patterns !!!) } else //bPhase2 == TRUE { //STOP*****************************************STOP //iMaxBackTrack == xx iState = fan1(iNoGate, iMaxLevelAdd2, iNoPI, iNoPO, pLastUndetectedFault, iMaxBackTrack, &iNoBackTrack); //Output: iState & g_iPatternsForOneTime & iNoBackTrack & g_net[i] (PI, Test Patterns !!!) } (*piNoBackTrack) += iNoBackTrack; getTime(&lfMinutes, &lfSeconds, &lfRunTime2); (*plfFanTime) += (lfRunTime2 - lfRunTime1); if (no_faultsim == 'y') ///////////////////////////NOT default { //STOP*********************STOP (*piNoPatterns) += g_iNoPatternsForOneTime; if (g_iNoPatternsForOneTime > 0) //iState == TEST_FOUND { pLastUndetectedFault->detected = DETECTED; iNoDetected++; } else if (iState == NO_TEST) { /* redundant faults */ pLastUndetectedFault->detected = REDUNDANT; (*piNoRedundant)++; } else //iState == OVER_BACKTRACK { /* over backtracking */ pLastUndetectedFault->detected = PROCESSED; (*piNoOverBackTrack)++; } } //no_faultsim != 'y' else if (iState == TEST_FOUND) //////////////////////////Default !!! { /* fault is detected, delete the detected fault from fault list */ pLastUndetectedFault->detected = PROCESSED; (*piNoPatterns)++; /* pLastUndetectedFault->detected=DETECTED; pLastUndetectedGate->nfault--; iNoDetected++; */ /* assign random zero and ones to the unassigned bits */ fill_patterns(fillmode, *piPacket, *piBit, iNoPI); //OUTPUT: g_net[i] (PI) if (_MODE_SIM == 'f') //Default FSIM !!! { for (j = 0; j < iNoPI; j++) { reset(g_net[j]->changed); reset(g_net[j]->freach); g_net[j]->cobserve = ALL0; g_net[j]->output = g_net[j]->output1; //Random-assigned values !! } } else //NOT default: HOPE { for (j = 0; j < iNoGate; j++) { reset(g_net[j]->changed); reset(g_net[j]->freach); } } if (++(*piBit) == iMaxBitSize) { *piBit = 0; (*piPacket)++; } clear(g_stack); /* fault simulation */ //iArrProfile[0] = return of tgen_sim, so weird !! //piNoPatterns NO USE !!! iArrProfile[0] = tgen_sim(iNoGate, iMaxLevelAdd2, iNoPI, iNoPO, iStem, pStem, *piNoPatterns, iArrProfile); iNoDetected += iArrProfile[0]; //Print functions, no big use !! if (compact == 'n') //////////////NOT default, default value is 's'!! { //STOP***********************************STOP if (_MODE_SIM == 'f') //Default !!! { /*printio(test,nopi,nopo,j,*ntest);KHB*/ printio(fpTestFile, iNoPI, iNoPO, 0, *piNoPatterns); if (logmode == 'y') //NOT default !!! { fprintf(g_fpLogFile, "test %4d: ", *piNoPatterns); printinputs(g_fpLogFile, iNoPI, 0); fprintf(g_fpLogFile, " "); printoutputs(g_fpLogFile, iNoPO, 0); fprintf(g_fpLogFile, " %4d faults detected\n", iArrProfile[0]); } } else { fprintf(fpTestFile, "test %4d: ", *piNoPatterns); printiovalues(fpTestFile, g_PrimaryIn, iNoPI, 'o', 'g', 0); fprintf(fpTestFile, " "); printiovalues(fpTestFile, g_PrimaryOut, iNoPO, 'o', 'g', 0); fprintf(fpTestFile, "\n"); if (logmode == 'y') { fprintf(g_fpLogFile, "test %4d: ", *piNoPatterns); printiovalues(g_fpLogFile, g_PrimaryIn, iNoPI, 'o', 'g', 0); fprintf(g_fpLogFile, " "); printiovalues(g_fpLogFile, g_PrimaryOut, iNoPO, 'o', 'g', 0); fprintf(g_fpLogFile, " %4d faults detected", iArrProfile[0]); fprintf(g_fpLogFile, "\n"); } } } if (pLastUndetectedFault->detected != DETECTED) //Why?? So Magic.. { printf("Error in test generation\n"); } } else if (iState == NO_TEST) { /* redundant faults */ pLastUndetectedFault->detected = REDUNDANT; (*piNoRedundant)++; if (_MODE_SIM == 'f') //Default !! f:FSIM h:HOPE { removeFaultFromGate(pLastUndetectedFault); if (--pLastUndetectedGate->nfault == 0) { set(g_iUpdateFlag); } } } else //iState == OVER_BACKTRACK { /* over backtracking */ (*piNoOverBackTrack)++; pLastUndetectedFault->detected = PROCESSED; } } return(iNoDetected); }
int main(){ fan(0); timeToWork(7); medicalTest(60,160,125); return 0; }
void display() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); GLfloat mat_ambient[] = { 0.7, 0.7, 0.7, 1.0 }; GLfloat mat_diffuse[] = { 0.5, 0.5, 0.5, 1.0 }; GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 }; GLfloat mat_shininess[] = { 50.0 }; GLfloat lightintensity[] = { 1, 1, 1, 1.0 }; GLfloat lightposition[] = { 2.0, 2.0, 2.0, 1.0 }; GLfloat lightposition2[] = { -2.0, -2.0, -2.0, 1.0 }; glClearColor(0.5, 0.5, 0.5, 0.0); switch (back) { case 1: glClearColor(1.0, 0.0, 0.0, 0.0); break; case 2: glClearColor(0.0, 0.0, 1.0, 0.0); break; case 3: glClearColor(0.0, 1.0, 0.0, 0.0); break; case 4: glClearColor(0.0, 0.0, 0.0, 0.0); break; } glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); glLightfv(GL_LIGHT0, GL_POSITION, lightposition); glLightfv(GL_LIGHT0, GL_DIFFUSE, lightintensity); glLightfv(GL_LIGHT0, GL_SPECULAR, mat_specular); glLightfv(GL_LIGHT1, GL_POSITION, lightposition2); glLightfv(GL_LIGHT1, GL_DIFFUSE, lightintensity); glLightfv(GL_LIGHT1, GL_SPECULAR, mat_specular); if (lightflag) glEnable(GL_LIGHTING); else glDisable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_LIGHT1); glShadeModel(GL_SMOOTH); glEnable(GL_DEPTH_TEST); glEnable(GL_NORMALIZE); glEnable(GL_COLOR_MATERIAL); if (orthoflag) { glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-1, 1, -1, 1, -20, 20); glMatrixMode(GL_MODELVIEW); } else { glMatrixMode(GL_PROJECTION); glLoadIdentity(); glFrustum(-1.0, 1.0, -1.0, 1.0, 1.0, 10.0); glMatrixMode(GL_MODELVIEW); } glLoadIdentity(); gluLookAt(viewer[0], viewer[1], viewer[2], 0, 0, 0, 0, 1, 0); glRotatef(theta[0], 1, 0, 0); glRotatef(theta[1], 0, 1, 0); glRotatef(theta[2], 0, 0, 1); house(v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7]); htop(h[0], h[1], h[2], h[3], h[4]); tv(t[0], t[1], t[2], t[3]); tvs(ts[0], ts[1], ts[2], ts[3], ts[4], ts[5], ts[6], ts[7]); grass(); sofa1(); rainwater(); sump(); table(); teapot(); tree(); compound(); window(); housefront(hfrt[0], hfrt[1], hfrt[2], hfrt[3]); fan(f[0], f[1], f[2], f[3], f[4], f[5]); fblade(fb[0], fb[1], fb[2], fb[3], fb[4], fb[5], fb[6], fb[7], fb[8], fb[9], fb[10], fb[11], fb[12], fb[13], fb[14], fb[15]); glEnable(GL_DEPTH_TEST); glutSwapBuffers(); }