Beispiel #1
0
 private static EventObject newEventLokGlobalState(EventMessage eventMessage) {
   int slot = eventMessage.getByte(2);
   int addr = eventMessage.getByte(4);
   int speed = eventMessage.getByte(5);
   boolean direction = ((eventMessage.getByte(6) << 5) == 0 ? false : true);
   int fstate = eventMessage.getByte(6) >> 3;
   return new EventLokGlobalState(addr, slot, speed, direction, fstate);
 }
Beispiel #2
0
 private static EventObject newEventSlotState(EventMessage eventMessage) {
   int slot = eventMessage.getByte(1);
   byte slot_s = (byte) (eventMessage.getByte(2) >> 7);
   byte consist_s = (byte) ((eventMessage.getByte(2) & 0x60) >> 5);
   byte busy_act = (byte) ((eventMessage.getByte(2) & 0x18) >> 3);
   byte type_cod = (byte) (eventMessage.getByte(2) & 0x07);
   return new EventSlotState(slot, slot_s, consist_s, busy_act, type_cod);
 }
Beispiel #3
0
 private static EventObject newEventLissySignalP2(EventMessage eventMessage) {
   int id;
   int lok;
   int speed = 0;
   id = eventMessage.getByte(4);
   lok = eventMessage.getByte(3);
   speed = eventMessage.getByte(6);
   return new EventLissySignalP2(id, lok, speed);
 }
Beispiel #4
0
 private static EventObject newEventLissySignalP1(EventMessage eventMessage) {
   int id;
   int lok;
   boolean direction;
   id = eventMessage.getByte(4);
   lok = eventMessage.getByte(6);
   direction = eventMessage.getByte(3) != 32 ? false : true;
   return new EventLissySignalP1(id, lok, direction);
 }
Beispiel #5
0
 private static EventObject newEventSensorState2(EventMessage eventMessage) {
   int addr = ((byte) (eventMessage.getByte(1) | ((eventMessage.getByte(2) & 0x0F) << 7)));
   byte s_x = (byte) ((eventMessage.getByte(2) & 0x40) >> 6);
   byte s_i = (byte) ((eventMessage.getByte(2) & 0x20) >> 5); // source
   byte s_l = (byte) ((byte) (eventMessage.getByte(2) & 0x10) >> 4); // sensor level
   byte[] bitcontrol = new byte[3];
   bitcontrol[0] = s_x;
   bitcontrol[1] = s_i;
   bitcontrol[2] = s_l;
   return new EventSensorState(addr, bitcontrol);
 }
Beispiel #6
0
 private static EventObject newEventSensorState(EventMessage eventMessage) {
   int byteaddr = ((byte) (eventMessage.getByte(1) | ((eventMessage.getByte(2) & 0x0F) << 7)));
   int dispaddr = (byteaddr / 8) + 1;
   int s_l = (eventMessage.getByte(2) & 0x20) >> 5; // source
   boolean s_i = (((eventMessage.getByte(2) & 0x10) >> 4) == 0 ? false : true); // sensor level
   int sensoraddr = ((((byteaddr * 2) + 1) % 16) + s_l);
   //	String codepos = dispaddr+"."+sensoraddr;
   //      return new EventSensorState(byteaddr, codepos, s_i);
   int id = (dispaddr - 1) * 16 + sensoraddr;
   return new EventSensorState(id, s_i);
 }
 /**
  * Extracts CacheEventMessages and attempts to get a hard reference to the underlying EventMessage
  *
  * <p>If an EventMessage has been invalidated due to SoftReference collection of the Element, it
  * is not propagated. This only affects puts and updates via copy.
  *
  * @param replicationQueueCopy
  * @return a list of EventMessages which were able to be resolved
  */
 private List extractAndResolveEventMessages(int limit) {
   List list = new ArrayList();
   for (int i = 0; i < limit; i++) {
     CacheEventMessage message = replicationQueue.poll();
     if (message == null) {
       break;
     } else {
       EventMessage eventMessage = message.getEventMessage();
       if (eventMessage != null && eventMessage.isValid()) {
         list.add(eventMessage);
       }
     }
   }
   return list;
 }
Beispiel #8
0
  private static EventObject newEventDecoderState(EventMessage eventMessage) {
    int id = eventMessage.getByte(1);
    int state = 4;

    switch (eventMessage.getByte(0)) {
      case 130:
        state = 0;
        break;
      case 131:
        state = 1;
        break;
      case 129:
        state = 2;
        break;
      case 133:
        state = 3;
        break;
    }
    return new EventDecoderState(id, state);
  }
 @Override
 public void receive(Message m) {
   if (!(m instanceof EventMessage)) return;
   EventMessage msg = (EventMessage) m;
   if (msg.getEvtId() <= 0 || msg.getEvtId() >= MSG_MAX) System.out.println("unknown");
   else {
     if (messageStrings[msg.getEvtId()] != "timerTick") {
       DebuggingService.getInstance()
           .addMessageAsyncIn(getPeerAddress(), getAddress(), messageStrings[msg.getEvtId()]);
     }
     if (msg instanceof EventWithDataMessage)
       getActor().receiveEvent(this, msg.getEvtId(), ((EventWithDataMessage) msg).getData());
     else getActor().receiveEvent(this, msg.getEvtId(), null);
   }
 }
Beispiel #10
0
  /**
   * @param eventMessage
   * @return
   */
  public static EventObject toEventObject(EventMessage eventMessage) {
    // Just For Debuging
    // System.out.println(eventMessage);
    //
    int eventType = eventMessage.getEventType();
    if (eventType == Protocol.EVENT_SENSOR_STATE) {
      return newEventSensorState(eventMessage);
    }
    if (eventType == Protocol.EVENT_LOK_SPEED) {
      return newEventLokSpeed(eventMessage);
    }
    if (eventType == Protocol.EVENT_LOK_DIRECTION) {
      return newEventLokDirection(eventMessage);
    }
    if (eventType == Protocol.EVENT_LISSY_SIGNAL) {
      return newEventLissySignal(eventMessage);
    }
    if (eventType == Protocol.EVENT_LOK_F_STATE) {
      return newEventLokFstate(eventMessage);
    }
    if (eventType == Protocol.EVENT_LOK_GLOBAL_STATE) {
      return newEventLokGlobalState(eventMessage);
    }
    if (eventType == Protocol.EVENT_TRN_STATE) {
      return newEventTrnState(eventMessage);
    }
    if (eventType == Protocol.EVENT_SENSOR_STATE2) {
      return newEventSensorState2(eventMessage);
    }
    if (eventType == Protocol.EVENT_SLOT_STATE) {
      return newEventSlotState(eventMessage);
    }
    if ((eventType == 131) || (eventType == 133) || (eventType == 129) || (eventType == 130)) {
      return newEventDecoderState(eventMessage);
    }
    if (eventType == Protocol.EVENT_SLOT_CONSIST) {
      return newEventSlotConsist(eventMessage);
    }
    if (eventType == Protocol.EVENT_TURNOUT_STATE) {
      return newEventTrnState(eventMessage);
    }

    return new EventObject("Unknown");
  }
Beispiel #11
0
 private static EventObject newEventLokSpeed(EventMessage eventMessage) {
   int slot = eventMessage.getByte(1);
   int speed = eventMessage.getByte(2);
   return new EventLokSpeed(slot, speed);
 }
Beispiel #12
0
 private static EventObject newEventLokDirection(EventMessage eventMessage) {
   int slot = eventMessage.getByte(1);
   boolean direction = ((eventMessage.getByte(2) >> 5) == 0 ? false : true);
   int func = (eventMessage.getByte(2) & ~(1 << 5));
   return new EventLokDirection(slot, direction, func);
 }
Beispiel #13
0
 private static EventObject newEventLissySignal(EventMessage eventMessage) {
   if (eventMessage.getByte(3) != 32) {
     return newEventLissySignalP1(eventMessage);
   }
   return newEventLissySignalP2(eventMessage);
 }
Beispiel #14
0
 private static EventObject newEventLokFstate(EventMessage eventMessage) {
   int slot = eventMessage.getByte(1);
   int fstate = eventMessage.getByte(2) >> 3;
   return new EventLokFstate(slot, fstate);
 }
Beispiel #15
0
 private static EventObject newEventTrnState(EventMessage eventMessage) {
   return new EventTrnState(
       eventMessage.getByte(1) + 1, (eventMessage.getByte(2) >> 5) == 0 ? false : true);
 }
Beispiel #16
0
 private static EventObject newEventSlotConsist(EventMessage eventMessage) {
   int slot = eventMessage.getByte(1);
   byte consist_s = (byte) eventMessage.getByte(2);
   ;
   return new EventSlotConsist(slot, consist_s);
 }