|
Post by julian46 on Dec 21, 2013 13:05:25 GMT -8
Im adding some additional buttons and controls to my existing configuration which is working well
I have some questions about what button types are able to perform
For instance: BL-1 and Cpu Load (Freq Modulated LED) - what tells this control to return the CPU Load - The display name? or something else?
(can it report other information - and if so what) (I dont see this documented anywhere)
Same for "Speedometer Type" - what tells this to specify "Processes Running" etc
thanks - great app
|
|
|
Post by SDL on Dec 21, 2013 18:43:37 GMT -8
Julian,
Thank you for your kind words.
All of the controls are "generic", meaning you have to define the function.
In the RasPiConnectServer directory, there is a sub directory called "ExecuteFiles". Look for the "BL-1" code using grep from the command line (if you don't know how to use grep, please learn! It's a fabulous command for the Raspberry Pi).
You will find it in "ExecuteFreqModLED.py". The code for BL-1 looks like this (from the file):
if (objectServerID == "BL-1"):
#check for validate request if (validate == "YES"): outgoingXMLData += Validate.buildValidateResponse("YES") outgoingXMLData += BuildResponse.buildFooter()
return outgoingXMLData
output = subprocess.check_output(["uptime", ""]) list = output.split("average:") list2 = list[1].split(",") if (Config.debug()): print list2 print list2[0] element = list2[0]
FMOutput = 1/(float(element)*4.0+0.01)
responseData = "%3.2f, %3.2f, %s" % (FMOutput, float(element),"CPU Load")
outgoingXMLData += BuildResponse.buildResponse(responseData)
else:
# invalid RaspiConnect Code outgoingXMLData += Validate.buildValidateResponse("NO")
outgoingXMLData += BuildResponse.buildFooter() if (Config.debug()): print outgoingXMLData
return outgoingXMLData
Look under "ExecuteFiles" to find the "ExecuteMeter.py" file. These are all great examples on how to use a control.
Here is the code that finds the number of processes
elif (objectServerID == "M-2"):
#check for validate request if (validate == "YES"): outgoingXMLData += Validate.buildValidateResponse("YES") outgoingXMLData += BuildResponse.buildFooter()
return outgoingXMLData
p1 = subprocess.Popen(['ps', 'xaf'], stdout=subprocess.PIPE) p3 = subprocess.Popen(['wc', '-l'], stdin=p1.stdout,stdout=subprocess.PIPE) p1.stdout.close() # Allow p1 to receive a SIGPIPE if p3 exits. output = p3.communicate()[0] numberofprocesses = int(output) responseData = "%i" % numberofprocesses outgoingXMLData += BuildResponse.buildResponse(responseData) else: # invalid RaspiConnect Code outgoingXMLData += Validate.buildValidateResponse("NO")
outgoingXMLData += BuildResponse.buildFooter()
return outgoingXMLData
Best regards,
BP
|
|
|
Post by raspihawk on Feb 2, 2015 13:47:29 GMT -8
Im adding some additional buttons and controls to my existing configuration which is working well I have some questions about what button types are able to perform For instance: BL-1 and Cpu Load (Freq Modulated LED) - what tells this control to return the CPU Load - The display name? or something else? (can it report other information - and if so what) (I dont see this documented anywhere) Same for "Speedometer Type" - what tells this to specify "Processes Running" etc thanks - great app
|
|