void TrafficLight::swtch() { if (waiting()) return; switch (stateGet()) { case OFF: case YELLOW: yellow.off(); red.on(); stateSet(RED); wait(delayGet()); break; case RED: red.off(); green.on(); stateSet(GREEN); wait(delayGet()); break; case GREEN: green.off(); green.blinkStart(600); stateSet(GREEN_BLINK); wait(4610); break; case GREEN_BLINK: green.blinkStop(); yellow.on(); stateSet(YELLOW); wait(1000); break; } }
void Emulation::receiveData(const char* text, int length) { emit stateSet(NOTIFYACTIVITY); bufferedUpdate(); //QString unicodeText = _decoder->toUnicode(text,length); QString unicodeText = text; //send characters to terminal emulator for (int i=0;i<unicodeText.length();i++) { receiveChar(unicodeText[i].unicode()); } //look for z-modem indicator //-- someone who understands more about z-modems that I do may be able to move //this check into the above for loop? for (int i=0;i<length;i++) { if (text[i] == '\030') { if ((length-i-1 > 3) && (strncmp(text+i+1, "B00", 3) == 0)) emit zmodemDetected(); } } }
int state(void *handle) { MAIN *m = handle; if (m->var.state != m->var.newstate) { if (darnitRenderFadeChanging(m->darnit) != 2) darnitRenderFadeIn(m->darnit, m->system.fade_duration, 0, 0, 0); else { fprintf(stderr, "Setting new state\n"); stateSet(m); darnitRenderFadeOut(m->darnit, m->system.fade_duration); } } switch (m->var.state) { case STATE_OVERWORLD: npcLoop(m); cameraLoop(m); renderOverworld(m); break; case STATE_INVENTORY: darnitRenderOffset(m->darnit, 0, 0); inventory(m); break; case STATE_TELEPORTING: /* Stubbe, jag har ingen aning om vad det här fallet behöver göra i en huvudslinga */ break; default: /* Egentligen borde vi inte ha ett panikfall, men sådana är reglerna med switch()... */ break; } return 0; }
void Emulation::sendKeyEvent( QKeyEvent* ev ) { emit stateSet(NOTIFYNORMAL); if (!ev->text().isEmpty()) { // A block of text // Note that the text is proper unicode. // We should do a conversion here, but since this // routine will never be used, we simply emit plain ascii. //emit sendBlock(ev->text().toAscii(),ev->text().length()); emit sendData(ev->text().toUtf8(),ev->text().length()); } }
void Emulation::receiveChar(int c) // process application unicode input to terminal // this is a trivial scanner { c &= 0xff; switch (c) { case '\b' : _currentScreen->BackSpace(); break; case '\t' : _currentScreen->Tabulate(); break; case '\n' : _currentScreen->NewLine(); break; case '\r' : _currentScreen->Return(); break; case 0x07 : emit stateSet(NOTIFYBELL); break; default : _currentScreen->ShowCharacter(c); break; }; }
static void setFillMode(doeE env, dcPathFiller pf, ixx fillmode) { dcPathFillerData* p = (dcPathFillerData*)pf; if (stateCheck(p, setFillModeDone)) { doeError_set(env, dcPRError, dcPRError_UNEX_setUsage); return; } if (fillmode != dcPathFiller_NZFILL && fillmode != dcPathFiller_EOFILL) { doeError_set(env, dcPRError, dcPRError_UNK_fillmode); return; } p->redundantReset = FALSE; p->fillmode = fillmode; stateSet(p, setFillModeDone); }
void icetStateSetBoolean(IceTEnum pname, IceTBoolean value) { stateSet(pname, 1, ICET_BOOLEAN, &value); }
void icetStateSetFloat(IceTEnum pname, IceTFloat value) { stateSet(pname, 1, ICET_FLOAT, &value); }
void icetStateSetInteger(IceTEnum pname, IceTInt value) { stateSet(pname, 1, ICET_INT, &value); }
void icetStateSetPointerv(IceTEnum pname, IceTSizeType num_entries, const IceTVoid **data) { stateSet(pname, num_entries, ICET_POINTER, data); }
void icetStateSetDouble(IceTEnum pname, IceTDouble value) { stateSet(pname, 1, ICET_DOUBLE, &value); }
void icetStateSetPointerv(GLenum pname, GLint size, const GLvoid **data) { stateSet(pname, size, ICET_POINTER, data); }
void icetStateSetBooleanv(IceTEnum pname, IceTSizeType num_entries, const IceTBoolean *data) { stateSet(pname, num_entries, ICET_BOOLEAN, data); }
void icetStateSetIntegerv(GLenum pname, GLint size, const GLint *data) { stateSet(pname, size, ICET_INT, data); }
void icetStateSetFloatv(GLenum pname, GLint size, const GLfloat *data) { stateSet(pname, size, ICET_FLOAT, data); }
void icetStateSetBoolean(GLenum pname, GLboolean value) { stateSet(pname, 1, ICET_BOOLEAN, &value); }
void icetStateSetPointer(GLenum pname, const GLvoid *value) { stateSet(pname, 1, ICET_POINTER, &value); }
void icetStateSetInteger(GLenum pname, GLint value) { stateSet(pname, 1, ICET_INT, &value); }
void icetStateSetFloat(GLenum pname, GLfloat value) { stateSet(pname, 1, ICET_FLOAT, &value); }
void icetStateSetDouble(GLenum pname, GLdouble value) { stateSet(pname, 1, ICET_DOUBLE, &value); }
void icetStateSetPointer(IceTEnum pname, const IceTVoid *value) { stateSet(pname, 1, ICET_POINTER, &value); }
osg::ref_ptr<osg::Node> get(const ImageVec_t& images) { osg::ref_ptr<osg::Group> rv( new osg::Group() ); for ( const auto& image : images ) { // here we create a quad that will be texture mapped with the image osg::ref_ptr<osg::Vec3Array> quad( new osg::Vec3Array() ); quad->push_back( image.corners[0] ); quad->push_back( image.corners[1] ); quad->push_back( image.corners[2] ); quad->push_back( image.corners[3] ); osg::ref_ptr<osg::Geometry> geo( new osg::Geometry() ); geo->setVertexArray( quad ); // here we create a drawing elelment to draw on osg::ref_ptr<osg::DrawElementsUInt> primitiveSet( new osg::DrawElementsUInt(osg::PrimitiveSet::QUADS, 0) ); primitiveSet->push_back( 0 ); primitiveSet->push_back( 1 ); primitiveSet->push_back( 2 ); primitiveSet->push_back( 3 ); geo->addPrimitiveSet( primitiveSet ); // the texture mappings osg::ref_ptr<osg::Vec2Array> texCoords( new osg::Vec2Array(4) ); (*texCoords)[3].set( 0.0f, 0.0f ); (*texCoords)[2].set( 1.0f, 0.0f ); (*texCoords)[1].set( 1.0f, 1.0f ); (*texCoords)[0].set( 0.0f, 1.0f ); geo->setTexCoordArray( 0, texCoords ); // now create the goede to hold our created geometry osg::ref_ptr<osg::Geode> geode( new osg::Geode() ); geode->addDrawable( geo ); // create the texture for the image osg::ref_ptr<osg::Texture2D> texture( new osg::Texture2D() ); texture->setResizeNonPowerOfTwoHint(false); texture->setDataVariance(osg::Object::STATIC); texture->setImage( image.image ); texture->setFilter(osg::Texture::MIN_FILTER, osg::Texture::NEAREST); texture->setFilter(osg::Texture::MAG_FILTER, osg::Texture::NEAREST); // put this in decal mode osg::ref_ptr<osg::TexEnv> decalTexEnv( new osg::TexEnv() ); decalTexEnv->setMode(osg::TexEnv::DECAL); // set the state set, lighting and such, so we actually display the image osg::ref_ptr<osg::StateSet> stateSet( geode->getOrCreateStateSet() ); stateSet->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON); stateSet->setTextureAttribute(0, decalTexEnv); stateSet->setMode( GL_LIGHTING, osg::StateAttribute::OFF ); geo->setStateSet(stateSet); // turn off any color binding - we want to use the texture geo->setColorBinding(osg::Geometry::BIND_OFF); // add this image and continue rv->addChild(geode); } return rv; };
void Light::on() { digitalWrite(pin, inversed ? LOW : HIGH); stateSet(ON); }
void icetStateSetBooleanv(GLenum pname, GLint size, const GLboolean *data) { stateSet(pname, size, ICET_BOOLEAN, data); }
void icetStateSetDoublev(IceTEnum pname, IceTSizeType num_entries, const IceTDouble *data) { stateSet(pname, num_entries, ICET_DOUBLE, data); }
void icetStateSetDoublev(GLenum pname, GLint size, const GLdouble *data) { stateSet(pname, size, ICET_DOUBLE, data); }
static void setOutputArea(doeE env, dcPathFiller pf, f32 outlox, f32 outloy, i32 w, i32 h) { dcPathFillerData* p = (dcPathFillerData*)pf; dcFastPathProducer fpp = p->thisFPP; i32 xi, yi; /* check state, parameters */ if (!((dcPathStoreData*)p)->pathDefined) { doeError_set(env, dcPRError, dcPRError_UNEX_setOutputArea); return; } if (w <= 0 || h <= 0) { doeError_set(env, dcPRError, dcPRError_BAD_outputarea); return; } if (!( dcPathFiller_validLoCoord(outlox) && dcPathFiller_validLoCoord(outloy) && dcPathFiller_validHiCoord(outlox + w) && dcPathFiller_validHiCoord(outloy + h))) { doeError_set(env, dcPRException, dcPRException_BAD_COORD_setOutputArea); return; } stateSet(p, setOutputAreaDone); p->outLoX = outlox; p->outLoY = outloy; p->outW = w; p->outH = h; p->outWTiF = w / dcPathFiller_tileSizeF; p->outHTiF = h / dcPathFiller_tileSizeF; if (p->tileRuns != NULL) doeMem_free(env, p->tileRuns); p->fastOutput = w <= dcPathFiller_tileSize && h <= dcPathFiller_tileSize && p->pathBox[0] >= outlox && p->pathBox[1] >= outloy && p->pathBox[2] <= outlox + w && p->pathBox[3] <= outloy + h; if (p->fastOutput) return; /* allocate [tileRuns], indexed [xindex][yindex]; (here we reuse [w] and [h] as width and height in tiles) */ p->outWTi = w = (p->outW + dcPathFiller_tileSize - 1) >> dcPathFiller_tileSizeL2S; p->outHTi = h = (p->outH + dcPathFiller_tileSize - 1) >> dcPathFiller_tileSizeL2S; p->tileRuns = doeMem_malloc(env, sizeof(Run*)*(w + 1) /* array of (Run*), indexed by X */ + sizeof(Run )*(w + 1)*h/* arrays of (Run), indexed by Y */ ); if (p->tileRuns == NULL) { doeError_setNoMemory(env); return; } for (xi = 0; xi <= w; xi++) { p->tileRuns[xi] = (Run*)(p->tileRuns + w + 1) + xi * h; } for (yi = 0; yi < h; yi++) { for (xi = 0; xi <= w; xi++) { p->tileRuns[xi][yi] = NULL; } } (*fpp)->sendTo(env, fpp, p->runsBuilder); if (doeError_occurred(env)) { doeError_setNoMemory(env); return; } /* set things so [nextTile] will advance to the 1st tile */ p->tileXI = w; p->tileYI = -1; (*pf)->nextTile(env, pf); }
void icetStateSetFloatv(IceTEnum pname, IceTSizeType num_entries, const IceTFloat *data) { stateSet(pname, num_entries, ICET_FLOAT, data); }
void Light::off() { digitalWrite(pin, inversed ? HIGH : LOW); stateSet(OFF); }
void icetStateSetIntegerv(IceTEnum pname, IceTSizeType num_entries, const IceTInt *data) { stateSet(pname, num_entries, ICET_INT, data); }