Esempio n. 1
0
def to_pyvalue( x ) :

    # !!! enum type { BOOLEAN, INTEGER, DOUBLE, STRING, SET, MAP,
    #                 TUPLE, TABLE, XMLTYPE, NIL, MATRIX };

    if x.isBoolean() == True : # BOOLEAN
        val = testDynamics.toBoolean( x )
    elif x.isInteger() == True : # INTEGER
        val = testDynamics.toInteger( x )
    elif x.isDouble() == True : # DOUBLE
        val = testDynamics.toDouble( x )
    elif x.isString() == True : # STRING
        val = testDynamics.toString( x )
    elif x.isSet() == True : # SET
        set = testDynamics.toSetValue( x ).value()
        val = list()
        for v in set:
            val.append( to_pyvalue(v) )
    elif x.isMap() == True : # MAP
        map = testDynamics.toMapValue( x ).value()
        val = dict()
        for k,v in map.iteritems() :
            val[k] = to_pyvalue(v) 

    else:
		raise ValueError(u'Can\'t convert type to pyvalue')

    #print "to_pyvalue, type(val) : ", type( val )
    return val
Esempio n. 2
0
    def output(self,time,events):
        #MySet = testDynamics.Set()
	MyMap = testDynamics.Map.create()
        MySet = testDynamics.Set.create()
        MyDouble = self.buildDouble(2.0)
        MyInteger = self.buildInteger(1)
        MyBoolean = self.buildBoolean(True)
        MyString = self.buildString("String")
        print "********************************************"
	print "Type de MyMap :", type(MyMap)
        print "Type de MyDouble :", type(MyDouble)
        print "********************************************"
        MyMap.addBoolean("Bool1", MyBoolean)
        print "MyMap Boolean 1 :", MyMap.getBoolean("Bool1")
        MyMap.addBoolean("Bool2", False)
        print "MyMap Boolean 2 :", MyMap.getBoolean("Bool2")

        MyMap.addDouble("Double", 2.0)
        print "MyMap Double :",MyMap.getDouble("Double")
        MyMap.addInt("Int", 1)
        print "MyMap Integer :",MyMap.getInt("Int")
        MyMap.addString("Str", "value")
        print "MyMap String :",testDynamics.toString(MyMap.get("Str")) 
        MyMap.addMap("Map")
        print "MyMap Map :",MyMap.getMap("Map")
        MyMap.addSet("Set")
        #print "MyMap Set :",MyMap.getSet("Set")

        #print type(MyInteger)	       
        #print dir(testDynamics)	
        #print "********************************************"
        #print "Test des Value (Double,String,Integer,Boolean)"
        #test = MyDouble.isDouble()
        #print "MyDouble est un double :",test
        #test = MyDouble.isInteger()
        #print "MyDouble est un integer :",test
        #test = MyInteger.isInteger()
        #print "MyInteger est un integer :",test
        #test = MyBoolean.isBoolean()
        #print "MyBoolean est un boolean :",test
        #test = MyString.isString()
        #print "MyString est un string :",test
        print "********************************************"
        print "Creation des evenements"
        eventA= self.buildEvent("PortA")
        eventB= self.buildEventWithAInteger("PortB", "NomAttributB", 1) 
        eventC= self.buildEventWithADouble("PortC", "NomAttributC", 2.2)
        eventD= self.buildEventWithABoolean("PortD", "NomAttributD", False)  
        eventE= self.buildEventWithAString("PortE", "NomAttributE", "value")