All Downloads are FREE. Search and download functionalities are using the official Maven repository.

fr.esrf.TangoApi.DatabaseDAODefaultImpl Maven / Gradle / Ivy

//+======================================================================
// $Source$
//
// Project:   Tango
//
// Description:  java source code for the TANGO client/server API.
//
// $Author: pascal_verdier $
//
// Copyright (C) :      2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,
//						European Synchrotron Radiation Facility
//                      BP 220, Grenoble 38043
//                      FRANCE
//
// This file is part of Tango.
//
// Tango 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 3 of the License, or
// (at your option) any later version.
// 
// Tango 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 Tango.  If not, see .
//
// $Revision: 30265 $
//
//-======================================================================


package fr.esrf.TangoApi;


import fr.esrf.Tango.DevFailed;
import fr.esrf.Tango.DevVarLongStringArray;
import fr.esrf.TangoApi.events.DbEventImportInfo;
import fr.esrf.TangoDs.Except;
import fr.esrf.TangoDs.TangoConst;

import java.util.*;

/**
 * Class Description:
 * This class is the main class for TANGO database API.
 * The TANGO database is implemented as a TANGO device server.
 * To access it, the user has the CORBA interface command_inout().
 * This expects and returns all parameters as ascii strings thereby making
 * the database laborious to use for retreing device properties and information.
 * In order to simplify this access, a high-level API has been implemented
 * which hides the low-level formatting necessary to convert the
 * command_inout() return values into binary values and all CORBA aspects
 * of the TANGO.
 * All data types are native java types e.g. simple types an arrays.
 *
 * @author verdier
 * @version $Revision: 30265 $
 */

public class DatabaseDAODefaultImpl extends ConnectionDAODefaultImpl implements IDatabaseDAO {

    //===================================================================
    /**
     * Database access constructor.
     */
    //===================================================================
    public DatabaseDAODefaultImpl() {
        super();
    }


    //===================================================================

    /**
     * Database access init method.
     *
     * @throws DevFailed in case of environment not corectly set.
     */
    //===================================================================
    public void init(Database database) throws DevFailed {
        super.init(database);
    }

    //===================================================================
    /**
     * Database access constructor.
     *
     * @throws DevFailed in case of host or port not available
     * @param    host    host where database is running.
     * @param    port    port for database connection.
     */
    //===================================================================
    public void init(Database database, String host, String port) throws DevFailed {
        super.init(database, host, port);
    }

    //==========================================================================
    //==========================================================================
    /* (non-Javadoc)
	 * @see fr.esrf.TangoApi.IDatabaseDAO#toString()
	 */
    public String toString(Database database) {
        return database.url.host + ":" + database.url.port;
    }
    //==========================================================================
    /**
     * Convert a String array to a sting.
     *
     * @param array String array to be converted
     * @return string after conversion.
     */
    //==========================================================================
    private String stringArray2String(String[] array) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0 ; i " +
            //		((database.access==TangoConst.ACCESS_READ)? "Read" : "Write"));
        }
    }


    //**************************************
    //       MISCELLANEOUS MANAGEMENT
    //**************************************


    //==========================================================================
	/* (non-Javadoc)
	 * @see fr.esrf.TangoApi.IDatabaseDAO#get_info()
	 */
    //==========================================================================
    public String get_info(Database database) throws DevFailed {
        if (!database.isAccess_checked()) checkAccess(database);

        //	Query info from database
        DeviceData argOut = command_inout(database, "DbInfo");
        String[] info = argOut.extractStringArray();

        //	format result as string
        return stringArray2String(info);
    }

    //==========================================================================
	/* (non-Javadoc)
	 * @see fr.esrf.TangoApi.IDatabaseDAO#get_host_list()
	 */
    //==========================================================================
    public String[] get_host_list(Database database) throws DevFailed {
        if (!database.isAccess_checked()) checkAccess(database);

        //	Query info from database
        DeviceData argIn = new DeviceData();
        argIn.insert("*");
        DeviceData argOut = command_inout(database, "DbGetHostList", argIn);
        return argOut.extractStringArray();
    }

    //==========================================================================
	/* (non-Javadoc)
	 * @see fr.esrf.TangoApi.IDatabaseDAO#get_host_list(java.lang.String)
	 */
    //==========================================================================
    public String[] get_host_list(Database database, String wildcard) throws DevFailed {
        if (!database.isAccess_checked()) checkAccess(database);

        //	Query info from database
        DeviceData argIn = new DeviceData();
        argIn.insert(wildcard);
        DeviceData argOut = command_inout(database, "DbGetHostList", argIn);
        return argOut.extractStringArray();
    }


    //**************************************
    //       SERVERS MANAGEMENT
    //**************************************

    //==========================================================================
	/* (non-Javadoc)
	 * @see fr.esrf.TangoApi.IDatabaseDAO#get_server_class_list(java.lang.String)
	 */
    //==========================================================================
    public String[] get_server_class_list(Database database, String serverName) throws DevFailed {
        if (!database.isAccess_checked()) checkAccess(database);

        DeviceData argIn = new DeviceData();
        argIn.insert(serverName);
        DeviceData argOut = command_inout(database, "DbGetDeviceServerClassList", argIn);
        String[] list = argOut.extractStringArray();
        //	Extract DServer class
        int nb_classes;
        if (list.length==0)
            nb_classes = 0;
        else
            nb_classes = list.length - 1;
        String[] classes = new String[nb_classes];
        for (int i = 0, j = 0 ; i0)
                properties[pnum++] = new DbDatum(strprop[i],
                        strprop, start_val, end_val);
            else {
                //	no property  --> fields do not exist
                properties[pnum++] = new DbDatum(strprop[i]);

                //	If nb property is zero there is a property
                //	set to space char (!!!)
                //	if Object is device it is true but false for a class !!!
                //----------------------------------------------------------
                if (start_val + 1 list = new ArrayList<>();
        while (stk.hasMoreTokens())
            list.add(stk.nextToken());
        if (list.size() < 3)
            throw new CommonDevFailed("TangoApi_DeviceNameNotValid",
                    "Device name not valid", "ATangoApi.Database.getDevices()");

        String domain = list.get(0);
        String family = list.get(1);
        String member = list.get(2);
        list.clear();

        //	Check for specifieddomain
        String[] domains = get_device_domain(database, domain);
        if (domains.length == 0)
            domains = new String[]{domain};

        //	Check for all domains found
        for (String domain_1 : domains) {
            String domain_header = domain_1 + "/";
            //	Get families
            String[] families = get_device_family(database, domain_header + family);
            if (families.length==0)
                families = new String[]{family};

            //	Check for all falilies found
            for (String family_1 : families) {
                String family_header = domain_header + family_1 + "/";
                String[] members = get_device_member(database, family_header + member);

                //	Add all members found
                for (String member_1 : members)
                    list.add(family_header + member_1);
            }
        }
        //	Copy all from list to String array
        return list.toArray(new String[0]);
    }

    //==========================================================================
	/* (non-Javadoc)
	 * @see fr.esrf.TangoApi.IDatabaseDAO#import_event(java.lang.String)
	 */
    //==========================================================================
    public DbEventImportInfo import_event(Database database, String channel_name)
            throws DevFailed {
        if (!database.isAccess_checked()) checkAccess(database);

        //  Check if channel name i a full url
        channel_name = new TangoUrl(channel_name).devname;
        DeviceData argIn = new DeviceData();
        argIn.insert(channel_name);
        DeviceData argOut = command_inout(database, "DbImportEvent", argIn);
        DevVarLongStringArray info = argOut.extractLongStringArray();
        return new DbEventImportInfo(info);
    }

    //==========================================================================
    /**
     * Convert the result of a DbGet...PropertyHist command.
     *
     * @param ret         return value of DebGet...
     * @param isAttribute true if attribute or pipe property
     * @return database history list
     * @throws fr.esrf.Tango.DevFailed incase of invalid format.
     */
    //==========================================================================
    private List convertPropertyHistory(String[] ret, boolean isAttribute)
            throws DevFailed {
        ArrayList list = new ArrayList<>();
        int i = 0;
        int count = 0;
        int offset;
        String aName = "";
        String pName;
        String pDate;
        String pCount;

        while (i dbHistories = convertPropertyHistory(argOut.extractStringArray(), false);
        DbHistory[] array = new DbHistory[dbHistories.size()];
        for (int i=0 ; i dbHistories =  convertPropertyHistory(argOut.extractStringArray(), true);
        DbHistory[] array = new DbHistory[dbHistories.size()];
        for (int i=0 ; i dbHistories =  convertPropertyHistory(argOut.extractStringArray(), false);
        DbHistory[] array = new DbHistory[dbHistories.size()];
        for (int i=0 ; i dbHistories =  convertPropertyHistory(argOut.extractStringArray(), true);
        DbHistory[] array = new DbHistory[dbHistories.size()];
        for (int i=0 ; i dbHistories =  convertPropertyHistory(argOut.extractStringArray(), false);
        DbHistory[] array = new DbHistory[dbHistories.size()];
        for (int i=0 ; i list = new ArrayList<>();
        char separ;

        //	Read Service property
        DbDatum datum = get_property(database, TangoConst.CONTROL_SYSTEM,
                TangoConst.SERVICE_PROP_NAME, true);
        if (!datum.is_empty()) {
            String[] services = datum.extractStringArray();

            //	Build filter
            String target = servicename.toLowerCase();
            if (!instname.equals("*")) {
                target += "/" + instname.toLowerCase();
                separ = ':';
            } else
                separ = '/';

            //	Search with filter
            int start;
            for (String service : services) {
                start = service.indexOf(separ);
                if (start > 0) {
                    String startLine =
                            service.substring(0, start).toLowerCase();
                    if (startLine.equals(target))
                        list.add(service.substring(
                                service.indexOf(':') + 1));
                }
            }
        }
        return list.toArray(new String[0]);
    }

    //===============================================================
	/* (non-Javadoc)
	 * @see fr.esrf.TangoApi.IDatabaseDAO#registerService(java.lang.String, java.lang.String, java.lang.String)
	 */
    //===============================================================
    public void registerService(Database database, String serviceName, String instanceName, String deviceName)
            throws DevFailed {
        String[] services = new String[0];

        //	Get service property
        DbDatum data = get_property(database, TangoConst.CONTROL_SYSTEM,
                TangoConst.SERVICE_PROP_NAME);
        if (!data.is_empty())
            services = data.extractStringArray();

        //	Build what to be inserted and searched
        String new_line = serviceName + "/" + instanceName;
        String target = new_line.toLowerCase();
        new_line += ":" + deviceName;

        //	Search if already exists
        boolean exists = false;
        List list = new ArrayList<>();
        for (String service : services) {
            String line = service.toLowerCase();
            int idx = line.indexOf(':');
            if (idx > 0)
                line = line.substring(0, idx);
            if (line.equals(target)) {
                // Found  -> replace existing by new one
                exists = true;
                list.add(new_line);
            } else
                list.add(service);
        }
        if (!exists)
            list.add(new_line);

        //	Copy list to String array
        services = list.toArray(new String[0]);

        //	And finaly put property
        data = new DbDatum(TangoConst.SERVICE_PROP_NAME);
        data.insert(services);
        put_property(database, TangoConst.CONTROL_SYSTEM, new DbDatum[]{data});
    }

    //===============================================================
	/* (non-Javadoc)
	 * @see fr.esrf.TangoApi.IDatabaseDAO#unregisterService(java.lang.String, java.lang.String, java.lang.String)
	 */
    //===============================================================
    public void unregisterService(Database database, String serviceName, String instanceName, String deviceName)
            throws DevFailed {
        String[] services = new String[0];

        //	Get service property
        DbDatum data = get_property(database, TangoConst.CONTROL_SYSTEM,
                TangoConst.SERVICE_PROP_NAME);
        if (!data.is_empty())
            services = data.extractStringArray();

        //	Build what to be remove and searched
        String target = serviceName + "/" + instanceName;
        target = target.toLowerCase();

        //	Search if already exists
        boolean exists = false;
        List list = new ArrayList<>();
        for (String service : services) {
            String line = service.toLowerCase();
            int idx = line.indexOf(':');
            if (idx > 0)
                line = line.substring(0, idx);

            if (line.equals(target))    // Found
                exists = true;
            else
                list.add(service);
        }
        if (exists) {
            //	Copy list to String array
            services = list.toArray(new String[0]);

            //	And finally put property
            data = new DbDatum(TangoConst.SERVICE_PROP_NAME);
            data.insert(services);
            put_property(database, TangoConst.CONTROL_SYSTEM, new DbDatum[]{data});
        }
    }
    //===================================================================
    //===================================================================


    //===================================================================
    private boolean access_service_read = false;
    private static final Object monitor = new Object();
    //===================================================================
    /**
     * Check Tango Access.
     * - Check if control access is requested.
     * - Check who is the user and the host.
     * - Check access for this user, this host and the specified device.
     *
     * @param database used database object
     * @param deviceName  Specified device name.
     * @param devUrl   Specified device url
     * @return The Tango access control found.
     */
    //===================================================================
    public int checkAccessControl(Database database, String deviceName, TangoUrl devUrl) {
        int access = TangoConst.ACCESS_WRITE;
        synchronized (monitor) {
            if (database.devname==null)
                database.devname = database.device.name();
            if (deviceName.equals(database.devname) && database.isAccess_checked())
                return database.access;
            try {
                //	Else create proxy
                //	Check if AccessProxy object already exists
                if (/*!database.isAccess_checked() &&*/ database.getAccess_proxy()==null) {
                    //	Check if access deviceName is from env (for tests)
                    String access_deviceName = ApiUtil.getAccessDevname();
                    if (access_deviceName==null || access_deviceName.length()==0) {
                        if (access_service_read && !database.check_access)
                                return TangoConst.ACCESS_WRITE;

                        //	Get Access service
                        String[] services =
                                getServices(database, TangoConst.ACCESS_SERVICE, "*");
                        if (services.length > 0) {
                            access_deviceName = services[0];
                        } else {
                            //	if not set --> No check
                            //System.out.println("No Access Service Found !");
                            database.check_access = false;
                            access_service_read = true;
                            return TangoConst.ACCESS_WRITE;
                        }
                    }
                    // If tango_host not from env -> add tango_host as header for access device name
                    //  Check if header not already in access_deviceName :-)
                    if (!devUrl.fromEnv && !access_deviceName.startsWith("tango://"))
                        access_deviceName = "tango://" + devUrl.host + ":" + devUrl.port + "/" + access_deviceName;

                    //	Then build Tango Access Control Proxy
                    database.setAccess_proxy(new AccessProxy(access_deviceName));
                }
                if (database.getAccess_proxy()!=null) {
                    access = database.getAccess_proxy().checkAccessControl(deviceName);
                }

                //	if database access not already checked, and not first import -> do it now
                if (!database.isAccess_checked() && !deviceName.equals(database.device.name()))
                        checkAccess(database);

            } catch (DevFailed e) {
                //	In case of failure, returns always TangoConst.ACCESS_READ
                access = TangoConst.ACCESS_READ;
                //	if cannot import AccessProxy
                //	-> change description to be more explicit
                if (e.errors.length > 1 && e.errors[1].reason.equals("TangoApi_CANNOT_IMPORT_DEVICE"))
                        e.errors[0].desc +=
                                "\nControlled access service defined in Db but unreachable --> Read Only access given to all devices...";

                database.setAccess_devfailed(e);
                //Except.print_exception(e);
            }
        }
        return access;
    }
    //===================================================================

    /**
     * Check for specified device, the specified command is allowed.
     *
     * @param    classname Specified class name.
     * @param    cmd Specified command name.
     */
    //===================================================================
    public boolean isCommandAllowed(Database database, String classname, String cmd)
            throws DevFailed {
        if (database.getAccess_proxy()==null) {
            if (!database.isAccess_checked())
                checkAccess(database);
            return !database.check_access;
        } else
            return database.getAccess_proxy().isCommandAllowed(classname, cmd);
    }

    //===================================================================
    //===================================================================
    public String[] getPossibleTangoHosts(Database database) {
        String[] tangoHosts = null;
        try {
            DeviceData deviceData = database.command_inout("DbGetCSDbServerList");
            tangoHosts = deviceData.extractStringArray();
        } catch (DevFailed e) {
            String desc = e.errors[0].desc.toLowerCase();
            try {
                if (desc.startsWith("command ") && desc.endsWith("not found")) {
                    tangoHosts = new String[]{database.getFullTangoHost()};
                } else
                    System.err.println(e.errors[0].desc);
            } catch (DevFailed e2) {
                System.err.println(e2.errors[0].desc);
            }
        }
        return tangoHosts;
    }
    //===================================================================
    //===================================================================


    //===================================================================
    /**
     * Pipe related methods
     */
    //===================================================================

    // ===================================================================
    /**
     * Query the database for a list of device pipe properties
     * for the specified pipe.
     *	@param database Database object.
     * @param deviceName specified device.
     * @return a list of device pipe properties.
     * @throws DevFailed in case of database access failed
     */
    // ===================================================================
    public DbPipe getDevicePipeProperties(Database database, String deviceName, String pipeName) throws DevFailed {

        DeviceData argIn = new DeviceData();
        argIn.insert(new String[]{deviceName, pipeName});
        DeviceData argOut = database.command_inout("DbGetDevicePipeProperty", argIn);
        return ApiUtil.toDbPipe(pipeName, argOut.extractStringArray());
    }
    // ===================================================================
    /**
     * Query the database for a list of class pipe properties
     * for the specified pipe.
     *	@param database Database object.
     * @param className specified class.
     * @param pipeName specified pipe.
     * @return a list of class pipe properties.
     * @throws DevFailed in case of database access failed
     */
    // ===================================================================
    public DbPipe getClassPipeProperties(Database database, String className, String pipeName) throws DevFailed {

        DeviceData argIn = new DeviceData();
        argIn.insert(new String[]{className, pipeName});
        DeviceData argOut = database.command_inout("DbGetClassPipeProperty", argIn);
        return ApiUtil.toDbPipe(pipeName, argOut.extractStringArray());
    }
    // ==========================================================================
    /**
     * Insert or update a list of pipe properties for the specified device.
     * The property names and their values are specified by the DbAPipe.
     *
     *	@param database Database object.
     * @param deviceName device name.
     * @param dbPipe pipe name, and properties (names and values).
     * @throws DevFailed in case of database access failed
     */
    // ==========================================================================
    public void putDevicePipeProperty(Database database, String deviceName, DbPipe dbPipe) throws DevFailed {
        DeviceData argIn = new DeviceData();
        String[]    array = ApiUtil.toStringArray(deviceName, dbPipe);
        argIn.insert(array);
        database.command_inout("DbPutDevicePipeProperty", argIn);
    }
    // ==========================================================================
    /**
     * Insert or update a list of pipe properties for the specified class.
     * The property names and their values are specified by the DbAPipe.
     *
     *	@param database Database object.
     * @param className class name.
     * @param dbPipe pipe name, and properties (names and values).
     * @throws DevFailed in case of database access failed
     */
    // ==========================================================================
    public void putClassPipeProperty(Database database, String className, DbPipe dbPipe) throws DevFailed {
        DeviceData argIn = new DeviceData();
        String[]    array = ApiUtil.toStringArray(className, dbPipe);
        argIn.insert(array);
        database.command_inout("DbPutClassPipeProperty", argIn);
    }
    // ===================================================================
    /**
     * Query database for a list of pipes for specified device and specified wildcard.
     *
     * @param deviceName specified device name.
     * @param wildcard   specified wildcard.
     * @return a list of pipes defined in database for specified device and specified wildcard.
     * @throws DevFailed in case of database access failed
     */
    // ===================================================================
    public List getDevicePipeList(Database database, String deviceName, String wildcard) throws DevFailed {
        DeviceData argIn = new DeviceData();
        argIn.insert(new String[]{deviceName, wildcard});
        DeviceData argOut = database.command_inout("DbGetDevicePipeList", argIn);
        //System.out.println("database.command_inout(\"DbGetDevicePipeList\", argIn)");

        String[] array = argOut.extractStringArray();
        ArrayList list = new ArrayList<>();
        Collections.addAll(list, array);
        return list;
    }
    // ===================================================================
    /**
     * Query database for a list of pipes for specified class and specified wildcard.
     *
     * @param className specified class name.
     * @param wildcard  specified wildcard.
     * @return a list of pipes defined in database for specified class and specified wildcard.
     * @throws DevFailed in case of database access failed
     */
    // ===================================================================
    public List getClassPipeList(Database database, String className, String wildcard) throws DevFailed {
        DeviceData argIn = new DeviceData();
        argIn.insert(new String[]{className, wildcard});
        DeviceData argOut = database.command_inout("DbGetDevicePipeList", argIn);
        String[] array = argOut.extractStringArray();
        ArrayList list = new ArrayList<>();
        Collections.addAll(list, array);
        return list;
    }
    // ==========================================================================
    /**
     * Delete a pipe property for the specified device.
     *
     *	@param database Database object.
     * @param deviceName Device name.
     * @param pipeName pipe name
     * @param propertyNames property names
     * @throws DevFailed in case of database access failed
     */
    // ==========================================================================
    public void deleteDevicePipeProperties(Database database, String deviceName,
                                         String pipeName, List propertyNames) throws DevFailed {

        String[]    array = new String[propertyNames.size()+2];
        int i=0;
        array[i++] = deviceName;
        array[i++] = pipeName;
        for (String propertyName : propertyNames)
            array[i++] = propertyName;
        DeviceData  argIn = new DeviceData();
        argIn.insert(array);
        database.command_inout("DbDeleteDevicePipeProperty", argIn);
    }
    // ==========================================================================
    /**
     * Delete a pipe property for the specified class.
     *
     *	@param database Database object.
     * @param className class name.
     * @param pipeName pipe name
     * @param propertyNames property names
     * @throws DevFailed in case of database access failed
     */
    // ==========================================================================
    public void deleteClassPipeProperties(Database database, String className,
                                         String pipeName, List propertyNames) throws DevFailed {

        String[]    array = new String[propertyNames.size()+2];
        int i=0;
        array[i++] = className;
        array[i++] = pipeName;
        for (String propertyName : propertyNames)
            array[i++] = propertyName;
        DeviceData  argIn = new DeviceData();
        argIn.insert(array);
        database.command_inout("DbDeleteClassPipeProperty", argIn);
    }
    // ===================================================================
    /**
     * Delete specified pipe for specified device.
     * @param database Database object.
     * @param deviceName    device name
     * @param pipeName      pipe name
     * @throws DevFailed in case of database access failed
     */
    // ===================================================================
    public void deleteDevicePipe(Database database, String deviceName, String pipeName) throws DevFailed {
        String[]    array = new String[] { deviceName, pipeName };
        DeviceData  argIn = new DeviceData();
        argIn.insert(array);
        database.command_inout("DbDeleteDevicePipe", argIn);
    }
    // ===================================================================
    /**
     * Delete specified pipe for specified class.
     * @param database Database object.
     * @param className    class name
     * @param pipeName      pipe name
     * @throws DevFailed in case of database access failed
     */
    // ===================================================================
    public void deleteClassPipe(Database database, String className, String pipeName) throws DevFailed {
        String[]    array = new String[] { className, pipeName };
        DeviceData  argIn = new DeviceData();
        argIn.insert(array);
        database.command_inout("DbDeleteClassPipe", argIn);
    }
    // ===================================================================
    /**
     * Delete all properties for specified pipes
     * @param database Database object.
     * @param deviceName    device name
     * @param pipeNames     pipe names
     * @throws DevFailed  in case of database access failed
     */
    // ===================================================================
    public void deleteAllDevicePipeProperty(Database database, String deviceName,
                                            List pipeNames) throws DevFailed {
        String[]    array = new String[1+pipeNames.size()];
        int i=0;
        array[i++] = deviceName;
        for (String pipeName : pipeNames)
            array[i++] = pipeName;
        DeviceData  argIn = new DeviceData();
        argIn.insert(array);
        database.command_inout("DbDeleteAllDevicePipeProperty", argIn);
    }
    // ===================================================================
    /**
     * Returns the property history for specified pipe.
     * @param database Database object.
     * @param deviceName    device name
     * @param pipeName      pipe name
     * @param propertyName  property Name
     * @return the property history for specified pipe.
     * @throws DevFailed  in case of database access failed
     */
    // ===================================================================
    public List getDevicePipePropertyHistory(Database database, String deviceName,
                                                        String pipeName, String propertyName) throws DevFailed {
        String[]    array = new String[] { deviceName, pipeName, propertyName };
        DeviceData  argIn = new DeviceData();
        argIn.insert(array);
        DeviceData  argOut = database.command_inout("DbGetDevicePipePropertyHist", argIn);
        return convertPropertyHistory(argOut.extractStringArray(), true);
    }
    // ===================================================================
    /**
     * Returns the property history for specified pipe.
     * @param database Database object.
     * @param className    class name
     * @param pipeName      pipe name
     * @param propertyName  property Name
     * @return the property history for specified pipe.
     * @throws DevFailed  in case of database access failed
     */
    // ===================================================================
    public List getClassPipePropertyHistory(Database database, String className,
                                                       String pipeName, String propertyName) throws DevFailed {
        String[]    array = new String[] { className, pipeName, propertyName };
        DeviceData  argIn = new DeviceData();
        argIn.insert(array);
        DeviceData  argOut = database.command_inout("DbGetClassPipePropertyHist", argIn);
        return convertPropertyHistory(argOut.extractStringArray(), true);
    }
    // ===================================================================
    /**
     * Query database to get a list of device using the specified device as
     * 		as root for forwarded attributes
     * @param deviceName the specified device
     * @return a list of device using the specified device as as root for forwarded attributes
     * @throws DevFailed
     */
    // ===================================================================
    public  List getForwardedAttributeDataForDevice(Database database, String deviceName) throws DevFailed {
        DeviceData argIn = new DeviceData();
        argIn.insert(deviceName);
        DeviceData argOut = database.command_inout("DbGetForwardedAttributeListForDevice", argIn);
        String[] array = argOut.extractStringArray();
        ArrayList list = new ArrayList<>();
        for (int i=0 ; i




© 2015 - 2025 Weber Informatics LLC | Privacy Policy