#!/usr/bin/perl open(IN,"interlock0/interlock0.ino"); while() { s/\s//g; if (/{([^,]*),([^,]*),{([^}]*)},([^,]*),{([^}]*)},([^,]*)}/) { #print " $1|$2| $3|$4|$5|$6\n"; $input=$1; $led=$2; @relais=split(',',$3); $n=$4; @relaisled=split(',',$5); $overwrite=$6; if ($#relais != $#relaisled) { die "element count error in:\n $_\n"; } for ($i=0;$i<=$#relais;$i++) { #print "$relais[$i] $relaisled[$i]\n"; if (!$rlmatch{$relais[$i]}) { $rlmatch{$relais[$i]}=$relaisled[$i]; } if ($rlmatch{$relais[$i]} != $relaisled[$i]) { die "led/relais mismatch: $relais[$i] / $relaisled[$i] \n"; } } print "|$input|$led|".join(',',@relais)."|$n|".join(',',@relaisled)."|$overwrite|\n"; } } # | input | LED | relais| n | relais LED | overwrite | # |-------|-----|-------|---|------------|-----------| # |22|46| | 0| |45| # |23|42|3 | 1|8 |41| # |24|43|3 | 1|8 |42| # |25|44|3 | 1|8 |43| # |26|33|14 | 1|19 |32| # |27|34|12,13,15 | 3|21,20,7 |33| # |28|35|12,13,15 | 3|21,20,7 |34| # |29|36|12,13,15 | 3|21,20,7 |35| # |30|37|12,13, | 2|21,20 |36| # |31|38|11 | 1|22 |37| # |32|39|3,11 | 2|8,22 |38| # |33|47|5,6,7,8,9,10,12,13,14 | 9|5,4,3,2,1,15,21,20,19 |46| # |34|48|5,6,7,8,9,10,12,13 | 8|5,4,3,2,1,15,21,20 |47| # |35|49|11 | 1|22 |48| # |36|50|4,5,6,7,8,9,10,11 | 8|6,5,4,3,2,1,15,22 |49| # |37|29|3,11 | 2|8,22 |28| # |38|30|2,3,12,13,15 | 5|9,8,21,20,7 |29| # |39|31|0,1,3,12,13 | 5|11,10,8,21,20 |30| # |40|32|0,1,3,11 | 4|11,10,8,22 |31| # |41|23|14,15 | 2|19,7 |23| # |42|24|12,13 | 2|21,20 |24| # |43|25|12,13,15 | 3|21,20,7 |25| # |44|26| | 0| |26| # |45|27| | 0| |27| # |46|45|4,5,6,7,8,9,10,12,13,14,15 |11|6,5,8,3,2,1,15,21,20,19,7 |44| # # input LED relais n relais LED overwrite # {22, 46, {}, 0, {}, 45}, # {23, 42, {3}, 1, {8}, 41}, # {24, 43, {3}, 1, {8}, 42}, # {25, 44, {3}, 1, {8}, 43}, # {26, 33, {14}, 1, {19}, 32}, # {27, 34, {12,13,15}, 3, {21,20,7}, 33}, # {28, 35, {12,13,15}, 3, {21,20,7}, 34}, # {29, 36, {12,13,15}, 3, {21,20,7}, 35}, # {30, 37, {12,13}, 2, {21,20}, 36}, # {31, 38, {11}, 1, {22}, 37}, # {32, 39, {3,11}, 2, {8,22}, 38}, # {33, 47, {5,6,7,8,9,10,12,13,14}, 9, {5,4,3,2,1,15,21,20,19}, 46}, # {34, 48, {5,6,7,8,9,10,12,13}, 8, {5,4,3,2,1,15,21,20}, 47}, # {35, 49, {11}, 1, {22}, 48}, # {36, 50, {4,5,6,7,8,9,10,11}, 8, {6,5,4,3,2,1,15,22}, 49}, # {37, 29, {3,11}, 2, {8,22}, 28}, # {38, 30, {2,3,12,13,15}, 5, {9,8,21,20,7}, 29}, # {39, 31, {0,1, 3,12,13}, 5, {11,10,8,21,20}, 30}, # {40, 32, {0,1,3,11}, 4, {11,10,8,22}, 31}, # {41, 23, {14,15}, 2, {19,7}, 23}, # {42, 24, {12,13}, 2, {21,20}, 24}, # {43, 25, {12,13,15}, 3, {21,20, 7}, 25}, # {44, 26, {}, 0, {}, 26}, # {45, 27, {}, 0, {}, 27}, # {46, 45, {4,5,6,7,8,9,10,12,13,14,15}, 11, {6,5,8,3,2,1,15,21,20,19,7}, 44}