|
@@ -0,0 +1,52 @@
|
|
|
+initial_state = dict(
|
|
|
+ instrument_list={},
|
|
|
+ connection_list={},
|
|
|
+)
|
|
|
+
|
|
|
+
|
|
|
+class ActionTypes(object):
|
|
|
+ UPDATE_LIST = 'instrument_manager/UPDATE_LIST'
|
|
|
+ CONNECT = 'instrument_manager/CONNECT'
|
|
|
+ DISCONNECT = 'instrument_manager/DISCONNECT'
|
|
|
+
|
|
|
+
|
|
|
+class ActionCreators(object):
|
|
|
+ @staticmethod
|
|
|
+ def update_list():
|
|
|
+ return dict(
|
|
|
+ type=ActionTypes.UPDATE_LIST
|
|
|
+ )
|
|
|
+
|
|
|
+ @staticmethod
|
|
|
+ def connect(id):
|
|
|
+ return dict(
|
|
|
+ type=ActionTypes.CONNECT,
|
|
|
+ id=id
|
|
|
+ )
|
|
|
+
|
|
|
+ @staticmethod
|
|
|
+ def disconnect(id):
|
|
|
+ return dict(
|
|
|
+ type=ActionTypes.DISCONNECT,
|
|
|
+ id=id
|
|
|
+ )
|
|
|
+
|
|
|
+
|
|
|
+def reducer(state=None, action=None):
|
|
|
+ if state is None:
|
|
|
+ state = initial_state
|
|
|
+ if not (isinstance(action, dict) and 'type' in action):
|
|
|
+ return state
|
|
|
+ # if action['type'] == ActionTypes.UPDATE_LIST:
|
|
|
+ # state = action['value']
|
|
|
+ # elif action['type'] == ActionTypes.CONNECT:
|
|
|
+ # state += 1
|
|
|
+ # elif action['type'] == ActionTypes.DISCONNECT:
|
|
|
+ # state -= 1
|
|
|
+ return state
|
|
|
+
|
|
|
+
|
|
|
+if __name__ == '__main__':
|
|
|
+ import unittest
|
|
|
+
|
|
|
+ unittest.main()
|