diff options
Diffstat (limited to 'src/command.c')
-rw-r--r-- | src/command.c | 43 |
1 files changed, 39 insertions, 4 deletions
diff --git a/src/command.c b/src/command.c index 7ae36ae..c6b64e7 100644 --- a/src/command.c +++ b/src/command.c @@ -45,10 +45,30 @@ struct token { enum token_type type; int fixture_index; + enum attr_class attribute; int val; }; +/* Tables for converting between attribute class numbers and names */ + +const char *attr_class_names[] = { + "int", + "pan", + "tilt" +}; + +enum attr_class attr_classes[] = { + ATT_INTENSITY, + ATT_PAN, + ATT_TILT +}; + +int n_attr_classes = 3; + +/* (end of attribute tables) */ + + static int stop_char(char c) { if ( c == '@' ) return 1; @@ -110,10 +130,10 @@ static int find_tokens(const char *cmd, struct token *tokens, struct nanolight * } /* Is is an attribute name? */ - for ( i=0; i<nl->n_fixtures; i++ ) { - if ( strcasecmp(nl->fixtures[i].label, word) == 0 ) { - tokens[n].fixture_index = i; - tokens[n++].type = TK_FIXTURE; + for ( i=0; i<n_attr_classes; i++ ) { + if ( strcasecmp(attr_class_names[i], word) == 0 ) { + tokens[n].attribute = attr_classes[i]; + tokens[n++].type = TK_ATTRIBUTE; done = 1; break; } @@ -136,6 +156,16 @@ static int find_tokens(const char *cmd, struct token *tokens, struct nanolight * } +static const char *str_attr(enum attr_class att) +{ + switch ( att ) { + case ATT_INTENSITY : return "intensity"; + case ATT_PAN : return "pan"; + case ATT_TILT : return "tilt"; + } + return "???"; +} + static void show_tokens(struct token *tokens, int n, struct nanolight *nl) { int i; @@ -163,6 +193,11 @@ static void show_tokens(struct token *tokens, int n, struct nanolight *nl) printf(" [value:%i]", tokens[i].val); break; + case TK_ATTRIBUTE: + printf(" [attr:%s]", str_attr(tokens[i].attribute)); + break; + + } } |