/** * 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 ${prefix}.${module}.${Assembly}BaseImpl; import alma.ACS.ROboolean; import alma.ACS.RObooleanHelper; import alma.ACS.RObooleanPOATie; import alma.ACS.impl.RObooleanImpl; import alma.ACS.ROdouble; import alma.ACS.ROdoubleHelper; import alma.ACS.ROdoublePOATie; import alma.ACS.impl.ROdoubleImpl; import alma.ACS.ROfloat; import alma.ACS.ROfloatHelper; import alma.ACS.ROfloatPOATie; import alma.ACS.impl.ROfloatImpl; import alma.ACS.ROlong; import alma.ACS.ROlongHelper; import alma.ACS.ROlongPOATie; import alma.ACS.impl.ROlongImpl; import alma.ACS.ROlongLong; import alma.ACS.ROlongLongHelper; import alma.ACS.ROlongLongPOATie; import alma.ACS.impl.ROlongLongImpl; import alma.ACS.ROstring; import alma.ACS.ROstringHelper; import alma.ACS.ROstringPOATie; import alma.ACS.impl.ROstringImpl; import alma.ACS.RWboolean; import alma.ACS.RWbooleanHelper; import alma.ACS.RWbooleanPOATie; import alma.ACS.impl.RWbooleanImpl; import alma.ACS.RWdouble; import alma.ACS.RWdoubleHelper; import alma.ACS.RWdoublePOATie; import alma.ACS.impl.RWdoubleImpl; import alma.ACS.RWfloat; import alma.ACS.RWfloatHelper; import alma.ACS.RWfloatPOATie; import alma.ACS.impl.RWfloatImpl; import alma.ACS.RWlong; import alma.ACS.RWlongHelper; import alma.ACS.RWlongPOATie; import alma.ACS.impl.RWlongImpl; import alma.ACS.RWlongLong; import alma.ACS.RWlongLongHelper; import alma.ACS.RWlongLongPOATie; import alma.ACS.impl.RWlongLongImpl; import alma.ACS.RWstring; import alma.ACS.RWstringHelper; import alma.ACS.RWstringPOATie; import alma.ACS.impl.RWstringImpl; import alma.ACS.ROdoubleSeq; import alma.ACS.ROdoubleSeqHelper; import alma.ACS.ROdoubleSeqPOATie; import alma.ACS.impl.ROdoubleSeqImpl; import alma.ACS.ROfloatSeq; import alma.ACS.ROfloatSeqHelper; import alma.ACS.ROfloatSeqPOATie; import alma.ACS.impl.ROfloatSeqImpl; import alma.ACS.ROlongSeq; import alma.ACS.ROlongSeqHelper; import alma.ACS.ROlongSeqPOATie; import alma.ACS.impl.ROlongSeqImpl; import alma.ACS.ROstringSeq; import alma.ACS.ROstringSeqHelper; import alma.ACS.ROstringSeqPOATie; import alma.ACS.impl.ROstringSeqImpl; import alma.ACS.RWdoubleSeq; import alma.ACS.RWdoubleSeqHelper; import alma.ACS.RWdoubleSeqPOATie; import alma.ACS.impl.RWdoubleSeqImpl; import alma.ACS.RWfloatSeq; import alma.ACS.RWfloatSeqHelper; import alma.ACS.RWfloatSeqPOATie; import alma.ACS.impl.RWfloatSeqImpl; import alma.ACS.RWlongSeq; import alma.ACS.RWlongSeqHelper; import alma.ACS.RWlongSeqPOATie; import alma.ACS.impl.RWlongSeqImpl; import alma.ACS.ROuLongLong; import alma.ACS.ROuLongLongHelper; import alma.ACS.ROuLongLongPOATie; import alma.ACS.impl.ROuLongLongImpl; import alma.ACS.RWuLongLong; import alma.ACS.RWuLongLongHelper; import alma.ACS.RWuLongLongPOATie; import alma.ACS.impl.RWuLongLongImpl; import org.omg.CORBA.LongHolder; import cta.acs.opcua.da.UaDataSupport; import astri.cta.acs.opcua.da.UaDataSupport.extensions.UaDataSupportInt16; import cta.acs.opcua.da.extension.UaDataSupportUInt16; import cta.acs.opcua.da.extension.UaDataSupportUInt32; import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; import java.util.logging.Level; import java.io.IOException; import alma.ACS.NoSuchCharacteristic; import alma.ACS.jbaci.PropertyInitializationFailed; import alma.ACSErr.CompletionHolder; import alma.acs.component.ComponentLifecycleException; import alma.JavaContainerError.wrappers.AcsJContainerServicesEx; import alma.acs.container.ContainerServices; import alma.maciErrType.wrappers.AcsJComponentCleanUpEx; import ${prefix}.${module}.${Assembly}BaseOperations; import ${prefix}.${module}.TCSHardwareDeviceImpl.TCSHardwareDeviceImpl; import ${prefix}.${module}.TCSHardwareDevicePackage.tcshwState; import ${prefix}.TCSControlExceptions.INACTErrorEx; import ${prefix}.TCSControlExceptions.OPCUAErrorEx; import ${prefix}.TCSControlExceptions.IllegalParameterErrorEx; import alma.acs.exceptions.AcsJCompletion; import alma.acs.exceptions.AcsJException; import alma.acs.util.UTCUtility; import com.prosysopc.ua.ServiceException; import com.prosysopc.ua.StatusException; import cta.acs.opcua.da.UaClientPool; import alma.ACSErr.Completion; /** * @author Generated by: $Author * @Date: $Date * @Description: $Description * */ public class ${Assembly}BaseImpl extends TCSHardwareDeviceImpl implements ${Assembly}BaseOperations { // OPC-UA server url key in CDB private static final String KEY_OPC_URL = "opc_url"; private static final String KEY_SERIAL_NUMBER = "SerialNumber"; private static final String KEY_MONITOR_COLLECTOR = "MonitoringCollectorName"; private String opc_url; private String serial_number; private String monitor_collector_name; #silent L=[] #for $idx in $range(0,$x.GetSheet["NRows"]) #silent L.append($x.GetSheet["Short name"][$idx]) #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 private RO$y[$type][0] $x.GetSheet["Short name"][$idx]; #end for #for $idx in $range(0,$x.SetSheet["NRows"]) #silent L.append($x.SetSheet["Short name"][$idx]) #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]+"[]" #else #set $type=$x.SetSheet["OPC UA Data type"][$idx].upper() #end if private RW$y[$type][0] $x.SetSheet["Short name"][$idx]; #end for #for $idx in $range(0,$x.ModeSheet["NRows"]) #set $name=($x.ModeSheet["OPC_UA node"][$idx].split(";")[1]).split("=")[1].replace(".","_") #if not $name in L private RW$y[$x.ModeSheet["OPC UA Data type"][$idx].upper()][0] $name; #silent L.append($name) #end if #end for #for $idx in $range(0,$x.CmdSheet["NRows"]) #set $name=($x.CmdSheet["OPC_UA node"][$idx].split(";")[1]).split("=")[1].replace(".","_") #if not $name in L private RW$y[$x.CmdSheet["OPC UA Data type"][$idx].upper()][0] $name; #silent L.append($name) #end if #end for /* * ACS Properties and DataAccess */ private Map dataAccess = new HashMap(); /* (non-Javadoc) * @see alma.ACS.impl.CharacteristicComponentImpl#initialize(alma.acs.container.ContainerServices) */ public void initialize(ContainerServices cs) throws ComponentLifecycleException { if (cs != null) { m_logger=cs.getLogger(); m_logger.info("Inizializing ${Assembly} component"); super.initialize(cs); } /* * Loading OPC-UA configuration from CDB */ try { opc_url = loadFromCDB(KEY_OPC_URL); } catch (NoSuchCharacteristic e) { m_logger.log(Level.SEVERE, "No OPC-UA server url found in CDB "+e); } try { monitor_collector_name = loadFromCDB(KEY_MONITOR_COLLECTOR); if(!monitor_collector_name.equals("TDB")){ setMonitoringCollectorName(monitor_collector_name); }else{ m_logger.log(Level.SEVERE, "MONITOR_COLLECTOR_NAME is not defined in CDB "); throw new ComponentLifecycleException(); } } catch (NoSuchCharacteristic e) { m_logger.log(Level.SEVERE, "MONITOR_COLLECTOR_NAME found in CDB "+e); } try { serial_number = loadFromCDB(KEY_SERIAL_NUMBER); setSerialNumber(serial_number); } catch (NoSuchCharacteristic e) { m_logger.log(Level.SEVERE, "No SERIAL NUMBER found in CDB "+e); } try { UaClientPool.create(opc_url); UaClientPool.connect(opc_url); } catch (IOException e1) { m_logger.fine(e1.getMessage()); throw new ComponentLifecycleException("Failed to connect to the server:"+opc_url); } if (UaClientPool.isConnected(opc_url)){ try { createDataPoints(); } catch (Exception e){ m_logger.log(Level.SEVERE, "Exception "+e); throw new ComponentLifecycleException("Failed to create properties"+e); } } } @Override public void connectToDevice(String opc_url){ } private void createDataPoints() throws IllegalArgumentException,PropertyInitializationFailed, ServiceException, StatusException{ #silent L=[] #for $idx in $range(0,$x.GetSheet["NRows"]) #silent L.append($x.GetSheet["Short name"][$idx]) #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]+"[]" try { UaDataSupport d = new UaDataSupport(opc_url,"$x.GetSheet["OPC_UA node"][$idx]" ); d.setConversionToPrimitiveArrayEnabled(true); dataAccess.put("$x.GetSheet["Short name"][$idx]", d); $x.GetSheet["Short name"][$idx] = createRO${y[$type][0]}Prop("$x.GetSheet["Short name"][$idx]"); } catch (IllegalArgumentException|PropertyInitializationFailed e){ m_logger.log(Level.SEVERE, "Exception "+e); } #else if ($x.GetSheet["OPC UA Data type"][$idx]).upper()=='INT16' #set $type=$x.GetSheet["OPC UA Data type"][$idx].upper() try { dataAccess.put("$x.GetSheet["Short name"][$idx]", new UaDataSupportInt16(opc_url,"$x.GetSheet["OPC_UA node"][$idx]" )); $x.GetSheet["Short name"][$idx] = createRO${y[$type][0]}Prop("$x.GetSheet["Short name"][$idx]"); } catch (IllegalArgumentException|PropertyInitializationFailed e){ m_logger.log(Level.SEVERE, "Exception "+e); } #else if ($x.GetSheet["OPC UA Data type"][$idx]).upper()=='UINT16' #set $type=$x.GetSheet["OPC UA Data type"][$idx].upper() try { dataAccess.put("$x.GetSheet["Short name"][$idx]", new UaDataSupportUInt16(opc_url,"$x.GetSheet["OPC_UA node"][$idx]" )); $x.GetSheet["Short name"][$idx] = createRO${y[$type][0]}Prop("$x.GetSheet["Short name"][$idx]"); } catch (IllegalArgumentException|PropertyInitializationFailed e){ m_logger.log(Level.SEVERE, "Exception "+e); } #else if ($x.GetSheet["OPC UA Data type"][$idx]).upper()=='UINT32' #set $type=$x.GetSheet["OPC UA Data type"][$idx].upper() try { dataAccess.put("$x.GetSheet["Short name"][$idx]", new UaDataSupportUInt32(opc_url,"$x.GetSheet["OPC_UA node"][$idx]" )); $x.GetSheet["Short name"][$idx] = createRO${y[$type][0]}Prop("$x.GetSheet["Short name"][$idx]"); } catch (IllegalArgumentException|PropertyInitializationFailed e){ m_logger.log(Level.SEVERE, "Exception "+e); } #else #set $type=$x.GetSheet["OPC UA Data type"][$idx].upper() try { dataAccess.put("$x.GetSheet["Short name"][$idx]", new UaDataSupport(opc_url,"$x.GetSheet["OPC_UA node"][$idx]" )); $x.GetSheet["Short name"][$idx] = createRO${y[$type][0]}Prop("$x.GetSheet["Short name"][$idx]"); } catch (IllegalArgumentException|PropertyInitializationFailed e){ m_logger.log(Level.SEVERE, "Exception "+e); } #end if #end for #for $idx in $range(0,$x.SetSheet["NRows"]) #silent L.append($x.SetSheet["Short name"][$idx]) #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]+"[]" try{ UaDataSupport d = new UaDataSupport(opc_url,"$x.SetSheet["OPC_UA node"][$idx]" ); d.setConversionToPrimitiveArrayEnabled(true); dataAccess.put("$x.SetSheet["Short name"][$idx]", d); $x.SetSheet["Short name"][$idx] = createRW${y[$type][0]}Prop("$x.SetSheet["Short name"][$idx]"); } catch (IllegalArgumentException|PropertyInitializationFailed e){ m_logger.log(Level.SEVERE, "Exception "+e); } #else if ($x.SetSheet["OPC UA Data type"][$idx]).upper()=='INT16' #set $type=$x.SetSheet["OPC UA Data type"][$idx].upper() try{ dataAccess.put("$x.SetSheet["Short name"][$idx]", new UaDataSupportInt16(opc_url,"$x.SetSheet["OPC_UA node"][$idx]" )); $x.SetSheet["Short name"][$idx] = createRW${y[$type][0]}Prop("$x.SetSheet["Short name"][$idx]"); } catch (IllegalArgumentException|PropertyInitializationFailed e){ m_logger.log(Level.SEVERE, "Exception "+e); } #else if ($x.SetSheet["OPC UA Data type"][$idx]).upper()=='UINT16' #set $type=$x.SetSheet["OPC UA Data type"][$idx].upper() try{ dataAccess.put("$x.SetSheet["Short name"][$idx]", new UaDataSupportUInt32(opc_url,"$x.SetSheet["OPC_UA node"][$idx]" )); $x.SetSheet["Short name"][$idx] = createRW${y[$type][0]}Prop("$x.SetSheet["Short name"][$idx]"); } catch (IllegalArgumentException|PropertyInitializationFailed e){ m_logger.log(Level.SEVERE, "Exception "+e); } #else if ($x.SetSheet["OPC UA Data type"][$idx]).upper()=='UINT32' #set $type=$x.SetSheet["OPC UA Data type"][$idx].upper() try{ dataAccess.put("$x.SetSheet["Short name"][$idx]", new UaDataSupportUInt32(opc_url,"$x.SetSheet["OPC_UA node"][$idx]" )); $x.SetSheet["Short name"][$idx] = createRW${y[$type][0]}Prop("$x.SetSheet["Short name"][$idx]"); } catch (IllegalArgumentException|PropertyInitializationFailed e){ m_logger.log(Level.SEVERE, "Exception "+e); } #else #set $type=$x.SetSheet["OPC UA Data type"][$idx].upper() try{ dataAccess.put("$x.SetSheet["Short name"][$idx]", new UaDataSupport(opc_url,"$x.SetSheet["OPC_UA node"][$idx]" )); $x.SetSheet["Short name"][$idx] = createRW${y[$type][0]}Prop("$x.SetSheet["Short name"][$idx]"); } catch (IllegalArgumentException|PropertyInitializationFailed e){ m_logger.log(Level.SEVERE, "Exception "+e); } #end if #end for #for $idx in $range(0,$x.ModeSheet["NRows"]) #set $name=($x.ModeSheet["OPC_UA node"][$idx].split(";")[1]).split("=")[1].replace(".","_") #if not $name in L try{ #if ($x.ModeSheet["OPC UA Data type"][$idx]).upper()=='INT16' dataAccess.put("$name", new UaDataSupportInt16(opc_url,"$x.ModeSheet["OPC_UA node"][$idx]" )); #else dataAccess.put("$name", new UaDataSupport(opc_url,"$x.ModeSheet["OPC_UA node"][$idx]" )); #end if $name = createRW${y[$x.ModeSheet["OPC UA Data type"][$idx].upper()][0]}Prop("$name"); } catch (IllegalArgumentException|PropertyInitializationFailed e){ m_logger.log(Level.SEVERE, "Exception "+e); } #silent L.append($name) #end if #end for #for $idx in $range(0,$x.CmdSheet["NRows"]) #set $name=($x.CmdSheet["OPC_UA node"][$idx].split(";")[1]).split("=")[1].replace(".","_") #if not $name in L try{ #if ($x.CmdSheet["OPC UA Data type"][$idx]).upper()=='INT16' dataAccess.put("$name", new UaDataSupportInt16(opc_url,"$x.CmdSheet["OPC_UA node"][$idx]" )); #else dataAccess.put("$name", new UaDataSupport(opc_url,"$x.CmdSheet["OPC_UA node"][$idx]" )); #end if $name = createRW${y[$x.CmdSheet["OPC UA Data type"][$idx].upper()][0]}Prop("$name"); } catch (IllegalArgumentException|PropertyInitializationFailed e){ m_logger.log(Level.SEVERE, "Exception "+e); } #silent L.append($name) #end if #end for } #silent L=[] #for $idx in $range(0,$x.GetSheet["NRows"]) #silent L.append($x.GetSheet["Short name"][$idx]) #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]+"[]" @Override public RO$($y[$type][0]) ${x.GetSheet["Short name"][$idx]}() { return $x.GetSheet["Short name"][$idx]; } #else #set $type=$x.GetSheet["OPC UA Data type"][$idx].upper() @Override public RO$y[$type][0] ${x.GetSheet["Short name"][$idx]}() { return $x.GetSheet["Short name"][$idx]; } #end if #end for #for $idx in $range(0,$x.SetSheet["NRows"]) #silent L.append($x.SetSheet["Short name"][$idx]) #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]+"[]" #else #set $type=$x.SetSheet["OPC UA Data type"][$idx].upper() #end if @Override public RW$y[$type][0] ${x.SetSheet["Short name"][$idx]}() { return $x.SetSheet["Short name"][$idx]; } #end for #for $idx in $range(0,$x.ModeSheet["NRows"]) #set $name=($x.ModeSheet["OPC_UA node"][$idx].split(";")[1]).split("=")[1].replace(".","_") #if not $name in L @Override public RW$y[$x.ModeSheet["OPC UA Data type"][$idx].upper()][0] ${name}() { return $name; } #silent L.append($name) #end if #end for #for $idx in $range(0,$x.CmdSheet["NRows"]) #set $name=($x.CmdSheet["OPC_UA node"][$idx].split(";")[1]).split("=")[1].replace(".","_") #if not $name in L @Override public RW$y[$x.CmdSheet["OPC UA Data type"][$idx].upper()][0] ${name}() { return $name; } #silent L.append($name) #end if #end for private ROdouble createROdoubleProp(String name) throws PropertyInitializationFailed { ROdoubleImpl impl = new ROdoubleImpl(name, this, dataAccess.get(name)); return ROdoubleHelper.narrow(this.registerProperty(impl, new ROdoublePOATie(impl))); } private ROfloat createROfloatProp(String name) throws PropertyInitializationFailed { ROfloatImpl impl = new ROfloatImpl(name, this, dataAccess.get(name)); return ROfloatHelper.narrow(this.registerProperty(impl, new ROfloatPOATie(impl))); } private ROstring createROstringProp(String name) throws PropertyInitializationFailed { ROstringImpl impl = new ROstringImpl(name, this, dataAccess.get(name)); return ROstringHelper.narrow(this.registerProperty(impl, new ROstringPOATie(impl))); } private ROlong createROlongProp(String name) throws PropertyInitializationFailed { ROlongImpl impl = new ROlongImpl(name, this, dataAccess.get(name)); return ROlongHelper.narrow(this.registerProperty(impl, new ROlongPOATie(impl))); } private ROlongLong createROlongLongProp(String name) throws PropertyInitializationFailed { ROlongLongImpl impl = new ROlongLongImpl(name, this, dataAccess.get(name)); return ROlongLongHelper.narrow(this.registerProperty(impl, new ROlongLongPOATie(impl))); } private ROuLongLong createROuLongLongProp(String name) throws PropertyInitializationFailed { ROuLongLongImpl impl = new ROuLongLongImpl(name, this, dataAccess.get(name)); return ROuLongLongHelper.narrow(this.registerProperty(impl, new ROuLongLongPOATie(impl))); } private RWuLongLong createRWuLongLongProp(String name) throws PropertyInitializationFailed { RWuLongLongImpl impl = new RWuLongLongImpl(name, this, dataAccess.get(name)); return RWuLongLongHelper.narrow(this.registerProperty(impl, new RWuLongLongPOATie(impl))); } private ROboolean createRObooleanProp(String name) throws PropertyInitializationFailed { RObooleanImpl impl = new RObooleanImpl(name, this, dataAccess.get(name)); return RObooleanHelper.narrow(this.registerProperty(impl, new RObooleanPOATie(impl))); } private RWdouble createRWdoubleProp(String name) throws PropertyInitializationFailed { RWdoubleImpl impl = new RWdoubleImpl(name, this, dataAccess.get(name)); return RWdoubleHelper.narrow(this.registerProperty(impl, new RWdoublePOATie(impl))); } private RWfloat createRWfloatProp(String name) throws PropertyInitializationFailed { RWfloatImpl impl = new RWfloatImpl(name, this, dataAccess.get(name)); return RWfloatHelper.narrow(this.registerProperty(impl, new RWfloatPOATie(impl))); } private RWstring createRWstringProp(String name) throws PropertyInitializationFailed { RWstringImpl impl = new RWstringImpl(name, this, dataAccess.get(name)); return RWstringHelper.narrow(this.registerProperty(impl, new RWstringPOATie(impl))); } private RWlong createRWlongProp(String name) throws PropertyInitializationFailed { RWlongImpl impl = new RWlongImpl(name, this, dataAccess.get(name)); return RWlongHelper.narrow(this.registerProperty(impl, new RWlongPOATie(impl))); } private RWlongLong createRWlongLongProp(String name) throws PropertyInitializationFailed { RWlongLongImpl impl = new RWlongLongImpl(name, this, dataAccess.get(name)); return RWlongLongHelper.narrow(this.registerProperty(impl, new RWlongLongPOATie(impl))); } private RWboolean createRWbooleanProp(String name) throws PropertyInitializationFailed { RWbooleanImpl impl = new RWbooleanImpl(name, this, dataAccess.get(name)); return RWbooleanHelper.narrow(this.registerProperty(impl, new RWbooleanPOATie(impl))); } private ROlongSeq createROlongSeqProp(String name) throws PropertyInitializationFailed { ROlongSeqImpl impl = new ROlongSeqImpl(name, this, dataAccess.get(name)); return ROlongSeqHelper.narrow(this.registerProperty(impl, new ROlongSeqPOATie(impl))); } private RWlongSeq createRWlongSeqProp(String name) throws PropertyInitializationFailed { RWlongSeqImpl impl = new RWlongSeqImpl(name, this, dataAccess.get(name)); return RWlongSeqHelper.narrow(this.registerProperty(impl, new RWlongSeqPOATie(impl))); } private ROfloatSeq createROfloatSeqProp(String name) throws PropertyInitializationFailed { ROfloatSeqImpl impl = new ROfloatSeqImpl(name, this, dataAccess.get(name)); return ROfloatSeqHelper.narrow(this.registerProperty(impl, new ROfloatSeqPOATie(impl))); } private RWfloatSeq createRWfloatSeqProp(String name) throws PropertyInitializationFailed { RWfloatSeqImpl impl = new RWfloatSeqImpl(name, this, dataAccess.get(name)); return RWfloatSeqHelper.narrow(this.registerProperty(impl, new RWfloatSeqPOATie(impl))); } private ROdoubleSeq createROdoubleSeqProp(String name) throws PropertyInitializationFailed { ROdoubleSeqImpl impl = new ROdoubleSeqImpl(name, this, dataAccess.get(name)); return ROdoubleSeqHelper.narrow(this.registerProperty(impl, new ROdoubleSeqPOATie(impl))); } private RWdoubleSeq createRWdoubleSeqProp(String name) throws PropertyInitializationFailed { RWdoubleSeqImpl impl = new RWdoubleSeqImpl(name, this, dataAccess.get(name)); return RWdoubleSeqHelper.narrow(this.registerProperty(impl, new RWdoubleSeqPOATie(impl))); } private ROstringSeq createROstringSeqProp(String name) throws PropertyInitializationFailed { ROstringSeqImpl impl = new ROstringSeqImpl(name, this, dataAccess.get(name)); return ROstringSeqHelper.narrow(this.registerProperty(impl, new ROstringSeqPOATie(impl))); } #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]+"[]" @Override public $($y[$type][4])$([]) ${x.GetSheet["Name of command"][$idx]}(LongHolder arg0) { CompletionHolder c = new CompletionHolder(); return ${x.GetSheet["Short name"][$idx]}().get_sync(c); } #else #set $type=$x.GetSheet["OPC UA Data type"][$idx].upper() @Override public $($y[$type][4]) ${x.GetSheet["Name of command"][$idx]}(LongHolder arg0) { CompletionHolder c = new CompletionHolder(); #if $y[$type][4] == "boolean" $($y[$type][4]) val = false; #else if $y[$type][4] == "String" $($y[$type][4]) val = null; #else $($y[$type][4]) val = 0; #end if if (${x.GetSheet["Short name"][$idx]}()!=null){ val=${x.GetSheet["Short name"][$idx]}().get_sync(c); if (c.value != null) { AcsJCompletion compl = AcsJCompletion.fromCorbaCompletion(c.value); if (compl.isError()) { m_logger.log(Level.SEVERE,"failed read property!", compl.getAcsJException()); }else{ arg0.value=c.value.timeStamp; m_logger.info("read property: ${x.GetSheet["Short name"][$idx]}:"+val+" at t="+ UTCUtility.getUTCDate(UTCUtility.utcOmgToJava(arg0.value))); } }else{ m_logger.info("read property: ${x.GetSheet["Short name"][$idx]}:"+val+" at t="+ UTCUtility.getUTCDate(arg0.value/10000)); } }else{ m_logger.log(Level.SEVERE,"property ${x.GetSheet["Short name"][$idx]} is not initialized"); } return val; } #end if #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]+"[]" @Override public $($y[$type][4])$([]) G${x.SetSheet["Name of command"][$idx][1:]}(LongHolder arg0) { CompletionHolder c = new CompletionHolder(); $($y[$type][4])$([]) val = null; if (${x.SetSheet["Short name"][$idx]}()!=null){ val = ${x.SetSheet["Short name"][$idx]}().get_sync(c); arg0.value = c.value.timeStamp; m_logger.info("read property: ${x.SetSheet["Short name"][$idx]}:"+val+" at t="+ UTCUtility.getUTCDate(UTCUtility.utcOmgToJava(arg0.value))); } return val; } @Override public void ${x.SetSheet["Name of command"][$idx]}($($y[$type][4])$([]) arg0) throws IllegalParameterErrorEx,INACTErrorEx { if (${x.SetSheet["Short name"][$idx]}()!=null){ ${x.SetSheet["Short name"][$idx]}().set_sync(arg0); m_logger.info("set ${x.SetSheet["Short name"][$idx]} property to '" + arg0 + "'."); }else{ m_logger.log(Level.SEVERE,"Property is not Initialized"); } } #else #set $type=$x.SetSheet["OPC UA Data type"][$idx].upper() @Override public $($y[$type][4]) G${x.SetSheet["Name of command"][$idx][1:]}(LongHolder arg0) { CompletionHolder c = new CompletionHolder(); $($y[$type][4]) val; if (${x.SetSheet["Short name"][$idx]}()!=null){ val = ${x.SetSheet["Short name"][$idx]}().get_sync(c); arg0.value = c.value.timeStamp; m_logger.info("read property: ${x.SetSheet["Short name"][$idx]}:"+val+" at t="+ UTCUtility.getUTCDate(UTCUtility.utcOmgToJava(arg0.value))); return val; } #if $y[$type][4] == "boolean" return false; #else if $y[$type][4] == "String" return null; #else return 0; #end if } @Override public void ${x.SetSheet["Name of command"][$idx]}($($y[$type][4]) arg0) throws IllegalParameterErrorEx,INACTErrorEx { Completion c = new Completion(); if (${x.SetSheet["Short name"][$idx]}()!=null){ c=${x.SetSheet["Short name"][$idx]}().set_sync(arg0); if(c!=null){ AcsJCompletion compl = AcsJCompletion.fromCorbaCompletion(c); if (compl.isError()) { m_logger.log(Level.SEVERE, "failed set property!", compl.getAcsJException()); try { throw compl.getAcsJException(); } catch (AcsJException e) { e.printStackTrace(); } }else{ m_logger.info("set ${x.SetSheet["Short name"][$idx]} property to '" + arg0 + "'."); } }else{ m_logger.info("set ${x.SetSheet["Short name"][$idx]} property to '" + arg0 + "'."); } } } #end if #end for #for $idx in $range(0,$x.ModeSheet["NRows"]) #set $name=($x.ModeSheet["OPC_UA node"][$idx].split(";")[1]).split("=")[1].replace(".","_") #set $type=$x.ModeSheet["OPC UA Data type"][$idx].upper() #if $x.ModeSheet["OPC UA Data type"][$idx].upper()=="INT16" #set $value=int($x.ModeSheet["CMD/MODE value"][$idx]) #else if $x.ModeSheet["OPC UA Data type"][$idx].upper()=="INT32" #set $value=int($x.ModeSheet["CMD/MODE value"][$idx]) #else if $x.ModeSheet["OPC UA Data type"][$idx].upper()=="BOOLEAN" #set $value=str($x.ModeSheet["CMD/MODE value"][$idx]).lower() #else #set $value=str($x.ModeSheet["CMD/MODE value"][$idx]) #end if @Override public void ${x.ModeSheet["Name of command"][$idx]}() throws IllegalParameterErrorEx,INACTErrorEx { Completion c = new Completion(); $($y[$type][4]) val = $value; if (${name}!=null){ c=${name}().set_sync(val); if(c!=null){ AcsJCompletion compl = AcsJCompletion.fromCorbaCompletion(c); if (compl.isError()) { m_logger.log(Level.SEVERE, "failed set property!", compl.getAcsJException()); try { throw compl.getAcsJException(); } catch (AcsJException e) { e.printStackTrace(); } }else{ m_logger.info("${x.ModeSheet["Name of command"][$idx]} sent with value: '" + "$value" + "'."); } }else{ m_logger.info("${x.ModeSheet["Name of command"][$idx]} sent with value: '" + "$value" + "'."); } } } #end for #for $idx in $range(0,$x.CmdSheet["NRows"]) #set $name=($x.CmdSheet["OPC_UA node"][$idx].split(";")[1]).split("=")[1].replace(".","_") #set $type=$x.CmdSheet["OPC UA Data type"][$idx].upper() #if $x.CmdSheet["OPC UA Data type"][$idx].upper()=="INT16" #set $value=int($x.CmdSheet["CMD/MODE value"][$idx]) #else if $x.CmdSheet["OPC UA Data type"][$idx].upper()=="INT32" #set $value=int($x.CmdSheet["CMD/MODE value"][$idx]) #else if $x.CmdSheet["OPC UA Data type"][$idx].upper()=="BOOLEAN" #set $value=str($x.CmdSheet["CMD/MODE value"][$idx]).lower() #else #set $value=str($x.CmdSheet["CMD/MODE value"][$idx]) #end if @Override public void ${x.CmdSheet["Name of command"][$idx]}() throws IllegalParameterErrorEx,INACTErrorEx { Completion c = new Completion(); $($y[$type][4]) val = $value; if (${name}!=null){ c=${name}().set_sync(val); if(c!=null){ AcsJCompletion compl = AcsJCompletion.fromCorbaCompletion(c); if (compl.isError()) { m_logger.log(Level.SEVERE, "failed set property!", compl.getAcsJException()); try { throw compl.getAcsJException(); } catch (AcsJException e) { e.printStackTrace(); } }else{ m_logger.info("${x.CmdSheet["Name of command"][$idx]} sent with value:'" + "$value" + "'."); } }else{ m_logger.info("${x.CmdSheet["Name of command"][$idx]} sent with value: '" + "$value" + "'."); } } } #end for /* (non-Javadoc) * @see astri.TCS.TCSHardwareDeviceImpl.TCSHardwareDeviceImpl\#cleanUp() */ @Override public void cleanUp() throws AcsJComponentCleanUpEx { if (UaClientPool.isConnected(opc_url)){ for (Map.Entry entry : dataAccess.entrySet()) { try { entry.getValue().close(); m_logger.log(Level.FINE, "closing:" ,entry.getKey()); } catch (IOException e) { m_logger.log(Level.SEVERE, "IOException: " , e); } } } try { super.cleanUp(); } catch (AcsJComponentCleanUpEx e) { m_logger.log(Level.SEVERE, "AcsJComponentCleanUpEx: " , e); } UaClientPool.shutdown(); } /* (non-Javadoc) * @see astri.TCS.TCSHardwareDeviceImpl.TCSHardwareDeviceImpl\#getHwState() */ @Override public tcshwState getHwState() { m_logger.info("Calling method: getHwState() "); return super.getHwState(); } /* (non-Javadoc) * @see astri.TCS.TCSHardwareDeviceImpl.TCSHardwareDeviceImpl\#getSerialNumber() */ @Override public String getSerialNumber() { m_logger.info("Calling method: getSerialNumber() "); return super.getSerialNumber(); } /* (non-Javadoc) * @see astri.TCS.TCSHardwareDeviceImpl.TCSHardwareDeviceImpl\#hwConfigureAction() */ @Override protected void hwConfigureAction() { // TODO Auto-generated method stub super.hwConfigureAction(); } /* (non-Javadoc) * @see astri.TCS.TCSHardwareDeviceImpl.TCSHardwareDeviceImpl\#hwDiagnosticAction() */ @Override protected void hwDiagnosticAction() { // TODO Auto-generated method stub super.hwDiagnosticAction(); } /* (non-Javadoc) * @see astri.TCS.TCSHardwareDeviceImpl.TCSHardwareDeviceImpl\#hwInitializeAction() */ @Override protected void hwInitializeAction() { super.hwInitializeAction(); } /* (non-Javadoc) * @see astri.TCS.TCSHardwareDeviceImpl.TCSHardwareDeviceImpl\#hwOperationalAction() */ @Override protected void hwOperationalAction() { // TODO Auto-generated method stub super.hwOperationalAction(); } /* (non-Javadoc) * @see astri.TCS.TCSHardwareDeviceImpl.TCSHardwareDeviceImpl\#hwSimulationAction() */ @Override protected void hwSimulationAction() { super.hwSimulationAction(); } /* (non-Javadoc) * @see astri.TCS.TCSHardwareDeviceImpl.TCSHardwareDeviceImpl\#hwStartAction() */ @Override protected void hwStartAction() { // TODO Auto-generated method stub super.hwStartAction(); } /* (non-Javadoc) * @see astri.TCS.TCSHardwareDeviceImpl.TCSHardwareDeviceImpl\#hwStopAction() */ @Override protected void hwStopAction() { // TODO Auto-generated method stub super.hwStopAction(); } /* (non-Javadoc) * @see astri.TCS.TCSHardwareDeviceImpl.TCSHardwareDeviceImpl\#initialize() */ @Override public void initialize() throws ComponentLifecycleException, AcsJContainerServicesEx { // TODO Auto-generated method stub super.initialize(); } /* (non-Javadoc) * @see astri.TCS.TCSHardwareDeviceImpl.TCSHardwareDeviceImpl\#isMonitoring() */ @Override public boolean isMonitoring() { m_logger.info("Calling method: isMonitoring() "); return super.isMonitoring(); } /* (non-Javadoc) * @see astri.TCS.TCSHardwareDeviceImpl.TCSHardwareDeviceImpl\#monitoringOff() */ @Override public void monitoringOff() { m_logger.info("Calling method: MonitoringOff() "); super.monitoringOff(); } /* (non-Javadoc) * @see astri.TCS.TCSHardwareDeviceImpl.TCSHardwareDeviceImpl#monitoringOn() */ @Override public void monitoringOn() { super.monitoringOn(); } /* (non-Javadoc) * @see astri.TCS.TCSHardwareDeviceImpl.TCSHardwareDeviceImpl#tcshwConfigure() */ @Override public void tcshwConfigure() { m_logger.info("Calling method: tcshwConfigure() "); super.tcshwConfigure(); } /* (non-Javadoc) * @see astri.TCS.TCSHardwareDeviceImpl.TCSHardwareDeviceImpl\#tcshwInitialize() */ @Override public void tcshwInitialize() { m_logger.info("Calling method: tcshwInitialize() "); super.tcshwInitialize(); } /* (non-Javadoc) * @see astri.TCS.TCSHardwareDeviceImpl.TCSHardwareDeviceImpl\#tcshwOperational() */ @Override public void tcshwOperational() { m_logger.info("Calling method: tcshwOperational() "); super.tcshwOperational(); } /* (non-Javadoc) * @see astri.TCS.TCSHardwareDeviceImpl.TCSHardwareDeviceImpl\#tcshwStart() */ @Override public void tcshwStart() { m_logger.info("Calling method: tcshwStart() "); super.tcshwStart(); } /* (non-Javadoc) * @see astri.TCS.TCSHardwareDeviceImpl.TCSHardwareDeviceImpl\#tcshwStop() */ @Override public void tcshwStop() { m_logger.info("Calling method: tcshwStop() "); super.tcshwStop(); } /** * Load a configuration value from CDB * @param cdbKey * @return Value from CDB * @throws NoSuchCharacteristic */ private String loadFromCDB(String cdbKey) throws NoSuchCharacteristic { String s = characteristicModelImpl.getString(cdbKey); if (s == null) { throw new NoSuchCharacteristic(); } return s; } }