public ScramblerRx(TypedCompositeActor container, String name) throws NameDuplicationException, IllegalActionException { super(container, name); input = new TypedIOPort(this, "input", true, false); input.setTypeEquals(ObjectToken.class); output = new TypedIOPort(this, "output", false, true); output.setTypeEquals(ObjectToken.class); LS0Bytes = new Parameter(this, "LS0Bytes", new IntToken(8)); LS0Map = new Parameter(this, "LS0Map", new BooleanToken(false)); S = new Parameter(this, "S", new IntToken(1)); }
public void fire() throws IllegalActionException { ObjectToken ot = (ObjectToken) input.get(0); MuxDataFrame mf = (MuxDataFrame) ot.getValue(); int b; if (_frameCounter == 0) { b = _processFast(mf.getFastByte()); mf.setFastByte(b); if (!_LS0Map) { for (int i = 0; i < _LS0Bytes; i++) { b = _processFast(mf.getLS0Byte(i)); mf.setLS0Byte(b, i); } } if (mf.hasLEX()) { b = _processFast(mf.getLEXByte()); mf.setLEXByte(b); } } else { b = _processInter(mf.getFastByte()); mf.setFastByte(b); if (_LS0Map) { for (int i = 0; i < _LS0Bytes; i++) { b = _processInter(mf.getLS0Byte(i)); mf.setLS0Byte(b, i); } } if (mf.hasLEX()) { b = _processInter(mf.getLEXByte()); mf.setLEXByte(b); } } _frameCounter++; if (_frameCounter == 1 + _S) _frameCounter = 0; ot = new ObjectToken(mf); output.broadcast(ot); }
public boolean postfire() throws IllegalActionException { switch (_state) { case READY: { if (trigger.hasToken(0) && !shutdown.hasToken(0)) { _state = RUNNING; } } break; case RUNNING: { if (shutdown.isKnown()) { if (shutdown.hasToken(0)) { _reset(); break; } } if (emstop_input.isKnown()) { if (emstop_input.hasToken(0)) { _reset(); break; } } } break; } return true; }
public void fire() throws IllegalActionException { if (_state == RUNNING) { if (alfa.isKnown() && !emmode.isKnown()) { // if(alfa.isKnown()) { if (alfa.hasToken(0)) { double _alfa = ((DoubleToken) alfa.get(0)).doubleValue(); /* if(_count > 0) { // so atualiza se um evento true deu inicio _count++; }*/ if (Math.abs(_alfa) >= 0.10) { // tem um evento // _sensorCount++; // if(_count == 0) { // _count = 1; // } _count++; } else { _count = 0; } if (_count == 25) { emmode.broadcast(new Token()); System.out.println("Entering Emergency Mode"); _reset(); // uma vez setado o emmode, so na proxima.... } /* if(_count == 50) { // deu os 100ms if(_maxSensorCount >= 25 || _sensorCount >= 25) { emmode.broadcast(new Token()); System.out.println("Entering Emergency Mode"); _reset(); // uma vez setado o emmode, so na proxima.... } else { _count = 0; _sensorCount = 0; _maxSensorCount = 0; } } else { if(Math.abs(_alfa) >= 0.10) { // tem um evento _sensorCount++; if(_count == 0) { _count = 1; } } if((Math.abs(_alfa) < 0.1) && _count > 0) { // nao tem mais , e estava contando if(_sensorCount > _maxSensorCount) { _maxSensorCount = _sensorCount; } _sensorCount = 0; } } */ } } } if (alfa.isKnown() && !emmode.isKnown()) { emmode.broadcastClear(); } }