Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
* ASTRI - Template based on ALMA Software Templates
* (c) INAF/UNIPG, 2014
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY, without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
* WARNING! DO NOT MODIFY THIS FILE!
* ---------------------------------------------------------
* | This is generated code! Do not modify this file. |
* | Any changes will be lost when the file is re-generated. |
* ---------------------------------------------------------
*
* Generated by: $Author
* Date: $Date
* Description: $Description
*
*/
package astri.acceptance.generated;
import astri.acceptance.gui.ACSConnector;
import org.omg.CORBA.LongHolder;
import astri.TCSControlExceptions.OPCUAErrorEx;
import astri.TCSControlExceptions.INACTErrorEx;
import java.util.Optional;
import alma.acs.logging.AcsLogger;
import java.util.logging.Level;
import astri.tcs.${Assembly}Helper;
import astri.tcs.${Assembly};
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
public class ${Assembly}GUIBridgeComponent {
public static ${Assembly} component;
private static final String COMPONENTNAME = "${Assembly}";
private ACSConnector connector;
private AcsLogger logger;
public ${Assembly}GUIBridgeComponent(ACSConnector connector) throws Exception{
this.connector=connector;
}
public void connect(){
try{
component = ${Assembly}Helper.narrow(connector.getComponent(COMPONENTNAME));
logger = connector.getLogger();
logger.info("Connected to "+COMPONENTNAME);
}catch(Exception e){
logger.log(Level.SEVERE, "Error connecting to component "+COMPONENTNAME, e);
}
}
public void release(){
try{
logger.info("Trying to release "+COMPONENTNAME);
connector.releaseComponent(COMPONENTNAME);
logger.info(COMPONENTNAME+" released");
}catch(Exception e){
logger.log(Level.SEVERE, "Error releasing "+COMPONENTNAME, e);
}
}
#for $idx in $range(0,$x.GetSheet["NRows"])
#if ($x.GetSheet["OPC UA Data type"][$idx]).upper()[-1]==']' ## test for arrays
#set $type=($x.GetSheet["OPC UA Data type"][$idx].upper()).split("[")[0]+"[]"
#else
#set $type=$x.GetSheet["OPC UA Data type"][$idx].upper()
#end if
public Optional<${y[$type][6]}> get${x.GetSheet["Short name"][$idx]}() {
logger.log(Level.FINEST, "Calling "+COMPONENTNAME+".get${x.GetSheet["Short name"][$idx]}()");
try {
return Optional.ofNullable(component.${x.GetSheet["Name of command"][$idx]}(new LongHolder()));
} catch (OPCUAErrorEx | INACTErrorEx e) {
logger.log(Level.SEVERE, "Error calling "+COMPONENTNAME+".get${x.GetSheet["Short name"][$idx]}()", e);
return Optional.empty();
}
}
#end for
#for $idx in $range(0,$x.SetSheet["NRows"])
#if ($x.SetSheet["OPC UA Data type"][$idx]).upper()[-1]==']' ## test for arrays
#set $type=($x.SetSheet["OPC UA Data type"][$idx].upper()).split("[")[0]+"[]"
public void ${x.SetSheet["Short name"][$idx]}(${y[$type][6]} param) throws Exception {
logger.log(Level.INFO, "Calling "+COMPONENTNAME+".${x.SetSheet["Name of command"][$idx]}("+param+")");
component.${x.SetSheet["Name of command"][$idx]}(param);
}
#else
#set $type=$x.SetSheet["OPC UA Data type"][$idx].upper()
public void ${x.SetSheet["Short name"][$idx]}(${y[$type][4]} param) throws Exception {
logger.log(Level.INFO, "Calling "+COMPONENTNAME+".${x.SetSheet["Name of command"][$idx]}("+param+")");
component.${x.SetSheet["Name of command"][$idx]}(param);
}
#end if
public Optional<${y[$type][6]}> get${x.SetSheet["Short name"][$idx]}() {
logger.log(Level.FINEST, "Calling "+COMPONENTNAME+".get${x.SetSheet["Short name"][$idx]}()");
try {
return Optional.ofNullable(component.G${x.SetSheet["Name of command"][$idx][1:]}(new LongHolder()));
} catch (OPCUAErrorEx | INACTErrorEx e) {
logger.log(Level.SEVERE, "Error calling "+COMPONENTNAME+".get${x.SetSheet["Short name"][$idx]}()", e);
return Optional.empty();
}
}
#end for
#for $idx in $range(0,$x.CmdSheet["NRows"])
public void ${x.CmdSheet["Short name"][$idx]}() throws Exception {
logger.log(Level.INFO, "Calling "+COMPONENTNAME+".${x.CmdSheet["Name of command"][$idx]}()");
component.${x.CmdSheet["Name of command"][$idx]}();
}
#end for
#for $idx in $range(0,$x.ModeSheet["NRows"])
public void ${x.ModeSheet["Short name"][$idx]}() throws Exception {
logger.log(Level.INFO, "Calling "+COMPONENTNAME+".${x.ModeSheet["Name of command"][$idx]}()");
component.${x.ModeSheet["Name of command"][$idx]}();
}
#end for
}