rename jsonHandler to helper, since this is a much better description
This commit is contained in:
		
							parent
							
								
									359012caed
								
							
						
					
					
						commit
						4741960c9c
					
				| @ -6,9 +6,6 @@ from time import sleep, time | |||||||
| import json | import json | ||||||
| import struct | import struct | ||||||
| 
 | 
 | ||||||
| from rgbUtils import effectControllerJsonHandler |  | ||||||
| from rgbUtils import rgbStripControllerJsonHandler |  | ||||||
| 
 |  | ||||||
| class ThreadedUDPServer(threading.Thread): | class ThreadedUDPServer(threading.Thread): | ||||||
|     def __init__(self,effectController,rgbStripController): |     def __init__(self,effectController,rgbStripController): | ||||||
|         threading.Thread.__init__(self) |         threading.Thread.__init__(self) | ||||||
|  | |||||||
| @ -1,11 +1,10 @@ | |||||||
|  | """ | ||||||
|  | Convert the rgbStripController function outputs to json format | ||||||
|  | """ | ||||||
|  | 
 | ||||||
|  | # get the color values of a single led in json format | ||||||
| def getRGBData(rgbStrip,led = 0): | def getRGBData(rgbStrip,led = 0): | ||||||
|     result = {} |     return {'led': led, 'red': rgbStrip.getData()[0][led], 'green': rgbStrip.getData()[1][led], 'blue': rgbStrip.getData()[2][led]} | ||||||
|     data = rgbStrip.getData() |  | ||||||
|     red = data[0] |  | ||||||
|     green = data[1] |  | ||||||
|     blue = data[2] |  | ||||||
|     result[led] = {'led': led, 'red': red[led], 'green': green[led], 'blue': blue[led]} |  | ||||||
|     return result |  | ||||||
| 
 | 
 | ||||||
| # return json of all configured rgbStrips | # return json of all configured rgbStrips | ||||||
| def getRGBStrips(rgbStripController): | def getRGBStrips(rgbStripController): | ||||||
| @ -1,7 +1,7 @@ | |||||||
| import json | import json | ||||||
| 
 | 
 | ||||||
| from rgbUtils import effectControllerJsonHandler | from rgbUtils import effectControllerJsonHelper | ||||||
| from rgbUtils import rgbStripControllerJsonHandler | from rgbUtils import rgbStripControllerJsonHelper | ||||||
| from webserver.SimpleWebSocketServer import WebSocket | from webserver.SimpleWebSocketServer import WebSocket | ||||||
| 
 | 
 | ||||||
| import traceback | import traceback | ||||||
| @ -52,9 +52,9 @@ class HTTPWebSocketsHandler(WebSocket): | |||||||
|                 elif int(data['register_client_type']) is CLIENT_TYPE_RECORDER: |                 elif int(data['register_client_type']) is CLIENT_TYPE_RECORDER: | ||||||
|                     self.client_type = CLIENT_TYPE_RECORDER |                     self.client_type = CLIENT_TYPE_RECORDER | ||||||
| 
 | 
 | ||||||
|             # controller responses are handled by the effectControllerJsonHandler |             # controller responses are handled by the effectControllerJsonHelper | ||||||
|             if self.client_type is CLIENT_TYPE_CONTROLLER: |             if self.client_type is CLIENT_TYPE_CONTROLLER: | ||||||
|                 response = effectControllerJsonHandler.responseHandler(self.effectController, self.rgbStripController, data) |                 response = effectControllerJsonHelper.responseHandler(self.effectController, self.rgbStripController, data) | ||||||
|                 self.sendMessage( |                 self.sendMessage( | ||||||
|                     json.dumps({ |                     json.dumps({ | ||||||
|                         'response': response |                         'response': response | ||||||
| @ -95,9 +95,9 @@ class HTTPWebSocketsHandler(WebSocket): | |||||||
|         if self.client_type is CLIENT_TYPE_CONTROLLER: |         if self.client_type is CLIENT_TYPE_CONTROLLER: | ||||||
|             self.sendMessage( |             self.sendMessage( | ||||||
|                 json.dumps({ |                 json.dumps({ | ||||||
|                     'effects': effectControllerJsonHandler.getEffects(self.effectController), |                     'effects': effectControllerJsonHelper.getEffects(self.effectController), | ||||||
|                     'rgbStrips': rgbStripControllerJsonHandler.getRGBStrips(self.rgbStripController), |                     'rgbStrips': rgbStripControllerJsonHelper.getRGBStrips(self.rgbStripController), | ||||||
|                     'effectThreads': effectControllerJsonHandler.getEffectThreads(self.effectController) |                     'effectThreads': effectControllerJsonHelper.getEffectThreads(self.effectController) | ||||||
|                 }) |                 }) | ||||||
|             ) |             ) | ||||||
|             return |             return | ||||||
| @ -110,6 +110,6 @@ class HTTPWebSocketsHandler(WebSocket): | |||||||
|     def onRGBStripValueUpdate(self,rgbStrip): |     def onRGBStripValueUpdate(self,rgbStrip): | ||||||
|         self.sendMessage( |         self.sendMessage( | ||||||
|             json.dumps({ |             json.dumps({ | ||||||
|                 'data': rgbStripControllerJsonHandler.getRGBData(rgbStrip) |                 'data': rgbStripControllerJsonHelper.getRGBData(rgbStrip) | ||||||
|             }) |             }) | ||||||
|         ) |         ) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user