File tree Expand file tree Collapse file tree 3 files changed +1742
-0
lines changed
tests/lit/single/conversion Expand file tree Collapse file tree 3 files changed +1742
-0
lines changed Original file line number Diff line number Diff line change
1
+ f = open ("to_num.st" , "w" )
2
+
3
+ types = [
4
+ "SINT" ,
5
+ "USINT" ,
6
+ "INT" ,
7
+ "UINT" ,
8
+ "DINT" ,
9
+ "UDINT" ,
10
+ "LINT" ,
11
+ "ULINT" ,
12
+
13
+ "REAL" ,
14
+ "LREAL" ,
15
+
16
+ # "BIT",
17
+ # "BOOL",
18
+ # "BYTE",
19
+ # "WORD",
20
+ # "DWORD",
21
+ # "LWORD",
22
+
23
+ # "STRING",
24
+ # "WSTRING",
25
+
26
+ # "TIME",
27
+ # "LTIME",
28
+ # "DATE",
29
+ # "LDATE",
30
+ # "DT",
31
+ # "LDT",
32
+ # "TOD",
33
+ # "LTOD",
34
+ ]
35
+
36
+ generic = """(********************
37
+ *
38
+ * Converts any other numerical value to {0}
39
+ *
40
+ *********************)
41
+ FUNCTION TO_{0}<T: ANY_NUM> : {0}
42
+ VAR_INPUT
43
+ in : T;
44
+ END_VAR
45
+ END_FUNCTION
46
+ """
47
+
48
+ generic_impl = """(********************
49
+ *
50
+ * Converts {0} to {1}
51
+ *
52
+ *********************)
53
+ FUNCTION TO_{1}__{0} : {1}
54
+ VAR_INPUT
55
+ in : {0};
56
+ END_VAR
57
+
58
+ TO_{1}__{0} := {0}_TO_{1}(in);
59
+ END_FUNCTION
60
+ """
61
+
62
+ generic_impl_same = """(********************
63
+ *
64
+ * Converts {0} to {1}
65
+ *
66
+ *********************)
67
+ FUNCTION TO_{1}__{0} : {1}
68
+ VAR_INPUT
69
+ in : {0};
70
+ END_VAR
71
+
72
+ TO_{1}__{0} := in;
73
+ END_FUNCTION
74
+ """
75
+
76
+ for type_from in types :
77
+ f .write (generic .format (type_from ))
78
+ f .write ("\n " )
79
+
80
+ for type_to in types :
81
+ if type_from == type_to :
82
+ f .write (generic_impl_same .format (type_from , type_to ))
83
+ else :
84
+ f .write (generic_impl .format (type_from , type_to ))
85
+
86
+ f .write ("\n " )
87
+
You can’t perform that action at this time.
0 commit comments