示例#1
0
 private void initSamples() {
   sampleEvents = new ContextEvent[samples];
   // 1 User is awake
   User u1 = new User(URIROOT + "user1");
   u1.setProperty(Profilable.PROP_HAS_PROFILE, new UserProfile(URIROOT + "user1Profile"));
   sampleEvents[0] = new ContextEvent(u1, Profilable.PROP_HAS_PROFILE);
   // 2 Blind is open
   BlindController b2 = new BlindController(URIROOT + "blind4");
   b2.setProperty(BlindController.PROP_HAS_VALUE, new Integer(100));
   sampleEvents[1] = new ContextEvent(b2, BlindController.PROP_HAS_VALUE);
   // 3 chair is in place
   Furniture f3 = new Furniture(URIROOT + "furniture5");
   f3.setFurnitureType(FurnitureType.Chair);
   f3.setLocation(new Location(URIROOT + "location5"));
   sampleEvents[2] = new ContextEvent(f3, Furniture.PROP_PHYSICAL_LOCATION);
   // 4 light is on
   LightController ls4 = new LightController(URIROOT + "light6");
   ls4.setValue(100);
   sampleEvents[3] = new ContextEvent(ls4, LightController.PROP_HAS_VALUE);
   // 5 socket at 50%
   DimmerController ss5 = new DimmerController(URIROOT + "socket7");
   ss5.setValue(50);
   sampleEvents[4] = new ContextEvent(ss5, DimmerController.PROP_HAS_VALUE);
   // 6 temperature measured
   TemperatureSensor ts6 = new TemperatureSensor(URIROOT + "tempsensor8");
   ts6.setValue(27.5f);
   sampleEvents[5] = new ContextEvent(ts6, TemperatureSensor.PROP_HAS_VALUE);
   // 7 window closed
   WindowController w7 = new WindowController(URIROOT + "window9");
   w7.setValue(StatusValue.Activated);
   sampleEvents[6] = new ContextEvent(w7, WindowController.PROP_HAS_VALUE);
 }
示例#2
0
 // I cant have a preset collection of events because timestamp and URI are
 // set at construction
 public static ContextEvent getSample(int sample) {
   switch (sample) {
     case 0:
       // 1 User is awake
       User u1 = new User(URIROOT + "user1");
       u1.setProperty(Profilable.PROP_HAS_PROFILE, new UserProfile(URIROOT + "user1Profile"));
       return new ContextEvent(u1, Profilable.PROP_HAS_PROFILE);
     case 1:
       // 2 Blind is open
       BlindController b2 = new BlindController(URIROOT + "blind4");
       b2.setProperty(BlindController.PROP_HAS_VALUE, new Integer(100));
       return new ContextEvent(b2, BlindController.PROP_HAS_VALUE);
     case 2:
       // 3 chair is in place
       Furniture f3 = new Furniture(URIROOT + "furniture5");
       f3.setFurnitureType(FurnitureType.Chair);
       f3.setLocation(new Location(URIROOT + "location" + new Integer(6)));
       return new ContextEvent(f3, Furniture.PROP_PHYSICAL_LOCATION);
     case 3:
       // 4 light is on
       LightController ls4 = new LightController(URIROOT + "light6");
       ls4.setValue(new Integer(100));
       return new ContextEvent(ls4, LightController.PROP_HAS_VALUE);
     case 4:
       // 7 socket at 50%
       DimmerController ss5 = new DimmerController(URIROOT + "socket7");
       ss5.setValue(new Integer(100));
       return new ContextEvent(ss5, DimmerController.PROP_HAS_VALUE);
     case 5:
       // 6 temperature measured
       TemperatureSensor ts6 = new TemperatureSensor(URIROOT + "tempsensor8");
       ts6.setValue(30);
       return new ContextEvent(ts6, TemperatureSensor.PROP_HAS_VALUE);
     case 6:
       // 7 window closed
       WindowController w7 = new WindowController(URIROOT + "window9");
       w7.setValue(StatusValue.Activated);
       return new ContextEvent(w7, WindowController.PROP_HAS_VALUE);
     default:
       // 10 situation
       PanicButtonSensor p10 = new PanicButtonSensor(URIROOT + "panic10");
       p10.setProperty(PhysicalThing.PROP_CARRIED_BY, new User(URIROOT + "user" + new Integer(5)));
       p10.setProperty(PhysicalThing.PROP_IS_PORTABLE, new Boolean(true));
       p10.setLocation(new Location(URIROOT + "location" + new Integer(10)));
       return new ContextEvent(p10, PhysicalThing.PROP_PHYSICAL_LOCATION);
   }
 }