Tellurium Plugins
Python ctypes wrapper documentation
 All Functions Variables Groups Pages
telPluginProperties.py

This example shows

  1. Get a handle to a property in a Plugin
  2. Obtain some info about the property
  3. Getting the value of the property
  4. Setting the value of the property
1 from teplugins import *
2 
3 #Create a plugin manager
5 
6 #Load the 'noise' plugin in order to add some noise to the data
7 plugin = loadPlugin(pm, "tel_add_noise")
8 if not plugin:
9  print getLastError()
10  exit()
11 
12 print getPluginInfo(plugin)
13 
14 #Get a plugins properties as names
15 print getListOfPluginPropertyNames(plugin)
16 
17 paraHandle = getPluginProperty(plugin, "NoiseType")
18 
19 print 'getting some info about the property'
20 print getPropertyInfo(paraHandle)
21 
22 paraValueString = getPropertyValueAsString(paraHandle)
23 print 'property value is ' + paraValueString
24 
25 setPropertyByString(paraHandle, "1")
26 paraValueString = getPropertyValueAsString(paraHandle)
27 print 'Property value is now: ' + paraValueString
28 
29 setIntProperty(paraHandle, 0)
30 test = getIntProperty(paraHandle)
31 print test
32 
33 paraValueString = getPropertyValueAsString(paraHandle)
34 print 'Property value is now: ' + paraValueString
35 
36 ## Retrieve a property handle
37 paraHandle = getPluginProperty(plugin, "Sigma")
38 
39 print 'getting some info about the property'
40 print getPropertyInfo(paraHandle)
41 
42 paraValueString = getPropertyValueAsString(paraHandle)
43 print 'property is ' + paraValueString
44 
45 setPropertyByString(paraHandle, "1.23")
46 paraValueString = getPropertyValueAsString(paraHandle)
47 print 'Property is now: ' + paraValueString
48 
49 var = 2.23
50 setDoubleProperty(paraHandle, var)
51 test = getPropertyValue(paraHandle)
52 print test
53 
54 paraValueString = getPropertyValueAsString(paraHandle)
55 print 'Property is now: ' + paraValueString
56 
57 #======= Test bools
58 boolParaHandle = createProperty("bool", "bool", "Hint", True)
59 print getBoolProperty(boolParaHandle)
60 setBoolProperty(boolParaHandle, False)
61 print getBoolProperty(boolParaHandle)
62 
63 #====Test some strings
64 stringParaHandle = createProperty("myStringProperty", "string", "Hello", "Hello2")
65 print getStringProperty(stringParaHandle)
66 setStringProperty(stringParaHandle, "Setting a string value")
67 print getStringProperty(stringParaHandle)
68 
69 #====Test list of propertys Todo:: clean this up!!
70 lOfP = createProperty("test", "listOfProperties", "Hello1")
71 print 'Names in property list:' + `getNamesFromPropertyList(lOfP)`
72 lOfP2 = createProperty("test", "listOfProperties", "Hello2")
73 
74 addPropertyToList(lOfP, stringParaHandle)
75 addPropertyToList(lOfP, stringParaHandle)
76 addPropertyToList(lOfP2, stringParaHandle)
77 
78 print 'Names in property list:' + `getNamesFromPropertyList(lOfP)`
79 
80 #Assignment
81 setListProperty(lOfP, lOfP2)
82 print 'Names in property list:' + `getNamesFromPropertyList(lOfP)`
83 print 'Names in property list:' + `getNamesFromPropertyList(lOfP2)`
84 
85 
86 
87 listParaHandle = createProperty("myList", "listOfProperties", "a Hint")
88 
89 #Should be empty
90 print getNamesFromPropertyList(listParaHandle)
91 
92 #Add a new parameter
93 aParameterHandle = createProperty("newOne", "double", "the hint")
94 addPropertyToList(listParaHandle, aParameterHandle)
95 
96 setDoubleProperty(aParameterHandle, 34)
97 print getDoubleProperty(aParameterHandle)
98 
99 #Or you can use
100 print getProperty(aParameterHandle)
101 
102 #Should not be empty
103 print getNamesFromPropertyList (listParaHandle)
104 
105 #Get the parameter
106 paraHandle = getFirstProperty(listParaHandle)
107 
108 print getPropertyHint (paraHandle)
109 print getPropertyInfo (paraHandle)
110 print getNamesFromPropertyList (listParaHandle)
111 
112 
113 print clearPropertyList(listParaHandle)
114 #Should be empty
115 print getNamesFromPropertyList (listParaHandle)
116 
117 freeProperty(listParaHandle)
118