From 65aee17e606a72daa6653dcd3bf0508e1f0945af Mon Sep 17 00:00:00 2001 From: Maximilien Rigaut Date: Wed, 1 May 2019 16:54:48 +0200 Subject: [PATCH] Refined the Class implementation of messages/parsing --- README.md | 2 +- mapping/GrandMA2.py | 28 +++++++++++++--------------- mapping/mapping.py | 12 +++++++----- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index f2c0fbd..d1dd1cb 100644 --- a/README.md +++ b/README.md @@ -2,4 +2,4 @@ Get/send midi commands to a GrandMA will be configured to remap all custom messages in a near future # Depends -Mostly mido (pip install mido) blessing/curses in a near future +Mostly mido (pip install mido) blessing for the testing (pip install belssings) diff --git a/mapping/GrandMA2.py b/mapping/GrandMA2.py index 9296343..51003af 100644 --- a/mapping/GrandMA2.py +++ b/mapping/GrandMA2.py @@ -1,20 +1,18 @@ -class BasicMessageParse(object): - """Classic System Specific Midi Message as Hex (BasicSyHexParse). - Uses one method, parseMidi to parse the message and return a BasicMapping object with the mapping of the message inside""" +from mapping import BasicMessageParse,BasicAction +import mido - def __init__(self): - '''Basic init''' - self.mapping={"value":None,"type":None} # A barebone initialisation, unusable, it will need to be overridden to work - self.value=None - self. +#A MessageParse object MUST be included in the file, the rest is implementation Specific +class MessageParse(BasicMessageParse): + """Parsing of a gma SyEx message""" - def parseMidi(self,message): - """Take a midi SyxEx message and return a BasicMapping""" - pass + def __init__(self, arg): + #super(Parse, self).__init__() #The init here is irrelevant + self._mapping = arg -class BasicMapping(object): - """A basic reading of the message, propreties are initialised depending on the way the SyEx message is formed, - this objet will need the configuration to read and understand the message - """ +class Action(BasicAction): + """The list of action to perform when a message is read""" def __init__(self): pass + + def resolve(self,config): + pass diff --git a/mapping/mapping.py b/mapping/mapping.py index 1fa4606..af63bf3 100644 --- a/mapping/mapping.py +++ b/mapping/mapping.py @@ -7,15 +7,17 @@ class BasicMessageParse(object): self._mapping={"value":None,"type":None} # A barebone initialisation, unusable, it will need to be overridden to work def parseMidi(self,message): - """Take a midi SyxEx message and return a BasicMapping (there can be many children of BasicMapping to take more properly care of the cases)""" + """Take a midi SyxEx message and return a BasicAction (there can be many children of BasicAction to take more properly care of the cases)""" return BasicMapping(self._mapping) -class BasicMapping(object): +class BasicAction(object): """A basic reading of the message, propreties are initialised depending on the way the SyEx message is formed, - this objet will need the configuration to read and understand the message - """ + this objet will need the configuration to read and understand the message""" + def __init__(self,dictmapping): 'Barebone init' self._mapping=dictmapping - def + def resolve(self,config): + "Resolve the current action, all actions will be performed depending on what's inside the mapping and the config" + pass