HEADS-project / training

Training material to get started with the HEADS technologies
10 stars 16 forks source link

"join" and "size-window" #110

Open omidkhodatars opened 8 years ago

omidkhodatars commented 8 years ago

I tried to combine the two feature "join" and "size-window" but it failed . the code can be compiled with the previous version of thingml but the result is not correct

(\ The new version still not working properly ver ThingML 0.7.0.201606071315 org.thingml.eclipse.feature.feature.group SINTEF-9012)

import "datatype.thingml"   
thing HighTemperatureDetection {
    // auto-generated message definition
    message joinCEP (temp : float, pressure : float);
    message temperatureSensor (id : integer, temp : float);
    message temperatureSensorCEP (id : integer, temp : float, msg : string);
    message PressureSensor (id : integer, pressure : float);
    //auto-generated port definition

    internal port eventPort {
    sends  joinCEP, temperatureSensor, temperatureSensorCEP, PressureSensor

    receives  joinCEP, temperatureSensor, temperatureSensorCEP, PressureSensor
    }
    //find stream query
    stream joinStream @TTL "250"
    from res : [ t : eventPort?temperatureSensor ::buffer 1 by 1 
     & p : eventPort?PressureSensor ::buffer 1 by 1 
     -> joinCEP (t.temp, p.pressure) ] 
    select  var ntemp:float = res.temp, var npressure:float = res.pressure
    produce eventPort!joinCEP(ntemp, npressure)
    //auto-generated statechart-------------------------------
    statechart CEPstatechart init Base {      
        state Base {
              on entry do
              //input events simulation 
              eventPort!temperatureSensor(10 , 51)
              eventPort!PressureSensor(10 , 51)
              eventPort!temperatureSensor(11 , 52)
              eventPort!PressureSensor(10 , 52)
              eventPort!temperatureSensor(12 , 15)
              eventPort!PressureSensor(10 , 15)
              eventPort!temperatureSensor(13 , 53)
              eventPort!PressureSensor(10 , 53) 
              end

              internal event jcep: eventPort?joinCEP
                action do
                print 
                "generated join- temp :"+jcep.temp+", pressure : "+jcep.pressure  + "\n "

                end                     
        }   
    }

} // End of thing
//auto-generated configuration 
configuration HighTemperatureDetectionCfg 
    {   
    instance my_instance: HighTemperatureDetection
    //connector my_instance.receivePort => my_instance.sendPort 
    }
skorsky commented 8 years ago

@brice-morin this does also not compile correctly when we omit the 'by 1' for both input streams.

brice-morin commented 8 years ago

Hi, I am not entirely sure we support buffers and windows within join and merge. @AlexandreRio ?

AlexandreRio commented 8 years ago

Hi, What compiler are you using? For arduino maybe you should put the size-window on the join and not on the inputs, i.e:

from res : [ t : eventPort?temperatureSensor
 & p : eventPort?PressureSensor
 -> joinCEP (t.temp, p.pressure) ]::buffer 1 by 1

This should actually to the same thing.

The grammar authorizes lots of combinations, we maintain a list of tested ones here:

https://github.com/SINTEF-9012/ThingML/tree/master/testJar/src/main/resources/tests