Subversion Repositories HomeAutomation

Rev

Rev 945 | Rev 950 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 945 Rev 947
Line 22... Line 22...
22
    print "Options:\n";
22
    print "Options:\n";
23
    print "  -x <xmlfile>           Choose xmlfile to parse\n";
23
    print "  -x <xmlfile>           Choose xmlfile to parse\n";
24
    print "  -c <headerfile>        Choose header file to write\n";
24
    print "  -c <headerfile>        Choose header file to write\n";
25
    print "  -h                 Shows this usage\n";
25
    print "  -h                 Shows this usage\n";
26
    print "\n";
26
    print "\n";
27
    print "example: ./$binaryname -x canId.xml -c canId.h\n";
27
    print "example: ./$binaryname -x data.xml -c moduleid.h\n";
28
 
28
 
29
    exit 0;
29
    exit 0;
30
}
30
}
31
 
31
 
32
my $now = localtime time;
32
my $now = localtime time;
Line 34... Line 34...
34
 
34
 
35
$twig->parsefile($xmlfile);
35
$twig->parsefile($xmlfile);
36
 
36
 
37
my $root = $twig->root;
37
my $root = $twig->root;
38
 
38
 
39
open (MYFILE, '>>' . $cfile);
39
open (MYFILE, '>' . $cfile);
40
 
40
 
41
print MYFILE "// Built on $now by makeCanIdHeader.pl\n\n";
41
print MYFILE "// Built on $now by $binaryname\n";
-
 
42
print MYFILE "// DO NOT CHANGE MANUALLY\n\n";
42
 
43
 
43
print MYFILE "//------------------ //\n";
44
print MYFILE "//------------------ //\n";
44
print MYFILE "// Class definitions //\n";
45
print MYFILE "// Class definitions //\n";
45
print MYFILE "//------------------ //\n";
46
print MYFILE "//------------------ //\n";
46
print MYFILE "\n";
47
print MYFILE "\n";
47
 
48
 
48
foreach my $class ($root->first_child('classes')->children('class'))
49
foreach my $class ($root->first_child('classes')->children('class'))
49
{
50
{
50
    my $className = "\U" . $class->att('name');
51
    my $className = "\U" . $class->att('name');
51
    $className =~ tr/a-z/A-Z/;
52
    $className =~ tr/a-z/A-Z/;
52
    print MYFILE "#define CAN_MODULE_CLASS_$className = " . $class->att('id') . "\n";
53
    print MYFILE "#define CAN_MODULE_CLASS_$className " . $class->att('id') . "\n";
53
}
54
}
54
 
55
 
55
print MYFILE "\n";
56
print MYFILE "\n";
56
print MYFILE "//-------------------- //\n";
57
print MYFILE "//-------------------- //\n";
57
print MYFILE "// Command definitions //\n";
58
print MYFILE "// Command definitions //\n";
Line 62... Line 63...
62
{
63
{
63
    my $commandName = "\U" . $command->att('name');
64
    my $commandName = "\U" . $command->att('name');
64
    $commandName =~ tr/a-z/A-Z/;
65
    $commandName =~ tr/a-z/A-Z/;
65
    my $commandType = "\U" . $command->att('type');
66
    my $commandType = "\U" . $command->att('type');
66
    $commandType =~ tr/a-z/A-Z/;
67
    $commandType =~ tr/a-z/A-Z/;
67
    print MYFILE "#define CAN_MODULE_CMD_" . $commandType . "_" . $commandName . " = " . $command->att('id') . "\n";
68
    print MYFILE "#define CAN_MODULE_CMD_" . $commandType . "_" . $commandName . " " . $command->att('id') . "\n";
68
}
69
}
69
 
70
 
70
print MYFILE "\n";
71
print MYFILE "\n";
71
print MYFILE "//------------------- //\n";
72
print MYFILE "//------------------- //\n";
72
print MYFILE "// Module definitions //\n";
73
print MYFILE "// Module definitions //\n";
Line 77... Line 78...
77
{
78
{
78
    my $className = "\U" . $module->att('class');
79
    my $className = "\U" . $module->att('class');
79
    $className =~ tr/a-z/A-Z/;
80
    $className =~ tr/a-z/A-Z/;
80
    my $moduleName = "\U" . $module->att('name');
81
    my $moduleName = "\U" . $module->att('name');
81
    $moduleName =~ tr/a-z/A-Z/;
82
    $moduleName =~ tr/a-z/A-Z/;
82
    print MYFILE "#define CAN_MODULE_TYPE_" . $className . "_" . $moduleName . " = " . $module->att('id') . "\n";
83
    print MYFILE "#define CAN_MODULE_TYPE_" . $className . "_" . $moduleName . " " . $module->att('id') . "\n";
83
}
84
}
84
 
85
 
85
print MYFILE "\n";
86
print MYFILE "\n";
86
print MYFILE "//----------------- //\n";
87
print MYFILE "//----------------- //\n";
87
print MYFILE "// Misc definitions //\n";
88
print MYFILE "// Misc definitions //\n";
Line 92... Line 93...
92
{
93
{
93
    my $groupName = "\U" . $define->att('group');
94
    my $groupName = "\U" . $define->att('group');
94
    $groupName =~ tr/a-z/A-Z/;
95
    $groupName =~ tr/a-z/A-Z/;
95
    my $defineName = "\U" . $define->att('name');
96
    my $defineName = "\U" . $define->att('name');
96
    $defineName =~ tr/a-z/A-Z/;
97
    $defineName =~ tr/a-z/A-Z/;
97
    print MYFILE "#define " . $groupName . "_" . $defineName . " = " . $define->att('id') . "\n";
98
    print MYFILE "#define " . $groupName . "_" . $defineName . " " . $define->att('id') . "\n";
98
}
99
}
99
 
100
 
100
print MYFILE "\n";
101
print MYFILE "\n";
101
 
102
 
102
close (MYFILE);
103
close (MYFILE);