Commit 4c1c93e8 authored by Claes Sjofors's avatar Claes Sjofors

Directory volume wizard: nodename converted to valid objectname

parent d1bc10e3
...@@ -2737,6 +2737,52 @@ int cdh_TypeToMaxStrSize( pwr_eType type, int attr_size, int attr_elements) ...@@ -2737,6 +2737,52 @@ int cdh_TypeToMaxStrSize( pwr_eType type, int attr_size, int attr_elements)
return size; return size;
} }
//! Convert string to valid object name.
/*!
Invalid characters in the string are replaced by '_'. If the first char is invalid
it is replaced by 'O'.
\param t Out string.
\param s In string.
\return Returns t.
*/
char *
cdh_StringToObjectName (
char *t,
const char *s
)
{
static const char valtab[] = "\
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
!!!!$!!!!!!!!!!!0123456789!!!!!!\
!ABCDEFGHIJKLMNOPQRSTUVWXYZ!!!!_\
!^^^^^^^^^^^^^^^^^^^^^^^^^^!!!!!\
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\
!!!\
^^^^^^^^^^^^^^^^!^^^^^^^^^^^^^!!";
char *rs = t;
const char *s1 = s;
if (t == NULL) return NULL;
if (s == NULL) s = t;
while (*s1)
if (valtab[(unsigned char)*s1] == '!') {
if ( s1 == s)
*t++ = 'O';
else
*t++ = '_';
s1++;
}
else
*t++ = *s1++;
*t = *s1; /* Copy the null byte. */
return rs;
}
/*@}*/ /*@}*/
......
...@@ -1031,6 +1031,8 @@ void cdh_SuppressSuperAll( char *out, char *in); ...@@ -1031,6 +1031,8 @@ void cdh_SuppressSuperAll( char *out, char *in);
int cdh_TypeToMaxStrSize( pwr_eType type, int attr_size, int attr_elements); int cdh_TypeToMaxStrSize( pwr_eType type, int attr_size, int attr_elements);
char *cdh_StringToObjectName( char *t, const char *s);
/*@}*/ /*@}*/
#ifdef __cplusplus #ifdef __cplusplus
......
...@@ -126,3 +126,5 @@ ...@@ -126,3 +126,5 @@
090225 cs script Script functions GetClassListAttrRef() and GetNextAttrRef() added. 090225 cs script Script functions GetClassListAttrRef() and GetNextAttrRef() added.
090306 cs wb Crossreferences on Co signals added. 090306 cs wb Crossreferences on Co signals added.
090306 cs plc Default include in ra_plc_user.h added. 090306 cs plc Default include in ra_plc_user.h added.
090507 cs adm In projectlist, the project name in a ProjectReg is changed, also the path is changed.
090507 cs wb Bugfix in directory wizard, for nodenames containing '-' NodeConfig object was not configured correctly.
\ No newline at end of file
...@@ -35,7 +35,6 @@ int main( int argc, char *argv[]) ...@@ -35,7 +35,6 @@ int main( int argc, char *argv[])
char wmg[80]; char wmg[80];
pwr_tFileName file; pwr_tFileName file;
printf( "Argc: %d\n", argc);
if ( argc > 1) { if ( argc > 1) {
for ( i = 1; i < argc; i++) { for ( i = 1; i < argc; i++) {
......
...@@ -144,6 +144,7 @@ main() ...@@ -144,6 +144,7 @@ main()
int first_sim = 1; int first_sim = 1;
string tmp_fname="$pwrp_tmp/wtmp.txt"; string tmp_fname="$pwrp_tmp/wtmp.txt";
int found; int found;
string oname;
verify(0); verify(0);
...@@ -523,11 +524,13 @@ page_4: ...@@ -523,11 +524,13 @@ page_4:
# Create node config objects # Create node config objects
for ( i = 0; i < nodecnt; i++) for ( i = 0; i < nodecnt; i++)
if ( node_busid[i] == 0) if ( node_busid[i] == 0)
create object /class=NodeConfig /dest='prd_bus_name' /name="'node_name[i]'" /last oname = StringToObjectName( node_name[i]);
name = prd_bus_name + "-" + node_name[i]; create object /class=NodeConfig /dest='prd_bus_name' /name="'oname'" /last
name = prd_bus_name + "-" + oname;
else else
create object /class=NodeConfig /dest='sim_bus_name' /name="'node_name[i]'" /last oname = StringToObjectName( node_name[i]);
name = sim_bus_name + "-" + node_name[i]; create object /class=NodeConfig /dest='sim_bus_name' /name="'oname'" /last
name = sim_bus_name + "-" + oname;
endif endif
attr = name + ".Description"; attr = name + ".Description";
SetAttribute( attr, node_description[i]); SetAttribute( attr, node_description[i]);
......
...@@ -1085,6 +1085,29 @@ static int wccm_getcurrentvolume_func( ...@@ -1085,6 +1085,29 @@ static int wccm_getcurrentvolume_func(
return 1; return 1;
} }
static int wccm_stringtoobjectname_func(
void *filectx,
ccm_s_arg *arg_list,
int arg_count,
int *return_decl,
float *return_float,
int *return_int,
char *return_string)
{
if ( arg_count != 1)
return CCM__ARGMISM;
if ( arg_list->value_decl != CCM_DECL_STRING)
return CCM__ARGMISM;
cdh_StringToObjectName( return_string, arg_list->value_string);
*return_decl = CCM_DECL_STRING;
return 1;
}
/************************************************************************* /*************************************************************************
* *
* Name: wccm_register() * Name: wccm_register()
...@@ -1154,6 +1177,8 @@ int wccm_register( ...@@ -1154,6 +1177,8 @@ int wccm_register(
if ( EVEN(sts)) return sts; if ( EVEN(sts)) return sts;
sts = ccm_register_function( "GetCurrentVolume", wccm_getcurrentvolume_func); sts = ccm_register_function( "GetCurrentVolume", wccm_getcurrentvolume_func);
if ( EVEN(sts)) return sts; if ( EVEN(sts)) return sts;
sts = ccm_register_function( "StringToObjectName", wccm_stringtoobjectname_func);
if ( EVEN(sts)) return sts;
sts = ccm_create_external_var( "cmd_status", CCM_DECL_INT, 0, 1, sts = ccm_create_external_var( "cmd_status", CCM_DECL_INT, 0, 1,
NULL); NULL);
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
134 134
22 22
2200 0 2200 0
2201 142 2201 160
2202 wb_wiz_directoryvolume_4 2202 wb_wiz_directoryvolume_4
2203 31 2203 31
2205 0 2205 0
...@@ -9006,5 +9006,446 @@ pwr_exe: ...@@ -9006,5 +9006,446 @@ pwr_exe:
99 99
99 99
99 99
30
3004 O145
3000 5.05
3001 3.95
3002 2.85
3003 2
3008 0
3010 4
3007 0
3006
3005
9
900 4
901 304
904 0
902 on
903
7
700 4.1
701 10.75
99
99
3009
28
2800 1
2801 0
2802 -0.15
2803 0
2804 1
2805 -8.05
2806 0
99
99
35
3500
27
2703 10000
2704 10000
2722 10000
2705 10000
2723 10000
2706 10000
2708 0
2709 0
2710 0
2711 0
2712 0
2713 0
2714 0
2715 0
2720 0
2725 0
2726 0
2702 0
2701
2700
10
1000 Grp146_
1002 Grp146_
1005
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1006 12.55
1007 5.8
1008 2.85
1009 2
1013 12.55
1014 5.8
1015 2.85
1016 2
1003
0
0
0
0
0
0
0
0
0
0
1004
1001
7
700 0
701 0
99
1010
1011
1018
1019
1020
1021
1022
1023
1024
1025
1012 0
1017 9999
1027 9999
1026 33619967
1028 0
1029
99
2707
28
2800 1
2801 0
2802 0
2803 0
2804 1
2805 0
2806 0
99
2716 0
2718
2717
2719 0
2724 0
2727 0
2728 303
2729 9999
2721
1
100 128
101 0
102 33619967
103 0
9
900 !$ccm.dv_node_skip_inv##Boolean
901 0
902 1
903 1
99
99
99
3501
36
3600
3
300 Grp146_
301
2
30
3004 O143
3000 12.55
3001 5.8
3002 2.85
3003 2
3008 0
3010 4
3007 0
3006
3005
9
900 4
901 304
904 0
902 Production bus
903
7
700 4.1
701 10.75
99
99
3009
28
2800 1
2801 0
2802 1.7
2803 0
2804 1
2805 -8.05
2806 0
99
99
99
302 0
304 0
303
305 0
306
307
308 0
321 0
309 0
313 0
322 0
323 0
324 0
325 0
326 0
327 0
310 0
311 0
312
314
315 1
316 1
317 0
318 0
319 0
320 0
328 0
99
99
99
35
3500
27
2703 10000
2704 10000
2722 10000
2705 10000
2723 10000
2706 10000
2708 0
2709 0
2710 0
2711 0
2712 0
2713 0
2714 0
2715 0
2720 0
2725 0
2726 0
2702 0
2701
2700
10
1000 Grp159_
1002 Grp159_
1005
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1006 12.55
1007 6
1008 2.85
1009 2
1013 12.55
1014 6
1015 2.85
1016 2
1003
0
0
0
0
0
0
0
0
0
0
1004
1001
7
700 0
701 0
99
1010
1011
1018
1019
1020
1021
1022
1023
1024
1025
1012 0
1017 9999
1027 9999
1026 33619967
1028 0
1029
99
2707
28
2800 1
2801 0
2802 0.05
2803 0
2804 1
2805 3.8
2806 0
99
2716 0
2718
2717
2719 0
2724 0
2727 0
2728 303
2729 9999
2721
1
100 128
101 0
102 33619967
103 0
9
900 $ccm.dv_node_skip_inv##Boolean
901 0
902 1
903 1
99
99
99
3501
36
3600
3
300 Grp159_
301
2
30
3004 O143
3000 12.5
3001 5.95
3002 -0.95
3003 -1.8
3008 0
3010 4
3007 0
3006
3005
9
900 4
901 304
904 0
902 Simulation bus
903
7
700 4.1
701 10.75
99
99
3009
28
2800 1
2801 0
2802 1.85
2803 0
2804 1
2805 -11.85
2806 0
99
99
99
302 0
304 0
303
305 0
306
307
308 0
321 0
309 0
313 0
322 0
323 0
324 0
325 0
326 0
327 0
310 0
311 0
312
314
315 1
316 1
317 0
318 0
319 0
320 0
328 0
99
99
99
99 99
99 99
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment