Skip to content
BaseJavaIDL.tmpl 34.1 KiB
Newer Older
Gino Tosti's avatar
Gino Tosti committed
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 43 44 45 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 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914
/**
 * 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<String, UaDataSupport> dataAccess = new HashMap<String, UaDataSupport>();
	/* (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<String, UaDataSupport> 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;
	}
}