Commit 100cdb0d authored by Thomas Braun's avatar Thomas Braun
Browse files

Merge branch 'various-improvements' into 'main'

Various improvements

It only accepts two strings, so the second one is Str[1].

See merge request !145
parents 8ab6e894 9cd4cce9
Loading
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@
#include <algorithm>
#include "DatabaseConnectionHandle.h"
#include "Utils.h"
#include "common.h"

/* clang-format off */
/*----- PROTECTED REGION END -----*/	//	DataBase.cpp
@@ -431,7 +432,7 @@ void DataBase::init_device()
    }

    // Load history depth property
    historyDepth = 10;
    historyDepth = DEFAULT_HISTORY_DEPTH;
    try
    {
        Tango::DevVarStringArray *argin = new Tango::DevVarStringArray();
@@ -451,7 +452,7 @@ void DataBase::init_device()
                if(historyDepth == 0)
                {
                    TANGO_LOG << "Warning, Invalid historyDepth property, resetting to default value (10)" << std::endl;
                    historyDepth = 10;
                    historyDepth = DEFAULT_HISTORY_DEPTH;
                }
            }
        }
@@ -5147,7 +5148,7 @@ Tango::DevVarStringArray *DataBase::db_get_property(const Tango::DevVarStringArr
 *	Description: Retrieve object  property history
 *
 *	@param argin Str[0] = Object name
 *	Str[2] = Property name
 *	Str[1] = Property name
 *	@returns Str[0] = Property name
 *	Str[1] = date
 *	Str[2] = Property value number (array case)
+1 −1
Original line number Diff line number Diff line
@@ -933,7 +933,7 @@ public:
	 *	Description: Retrieve object  property history
	 *
	 *	@param argin Str[0] = Object name
	 *	Str[2] = Property name
	 *	Str[1] = Property name
	 *	@returns Str[0] = Property name
	 *	Str[1] = date
	 *	Str[2] = Property value number (array case)
+1 −1
Original line number Diff line number Diff line
@@ -510,7 +510,7 @@
      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
    </commands>
    <commands name="DbGetPropertyHist" description="Retrieve object  property history" execMethod="db_get_property_hist" displayLevel="OPERATOR" polledPeriod="0">
      <argin description="Str[0] = Object name&#xA;Str[2] = Property name">
      <argin description="Str[0] = Object name&#xA;Str[1] = Property name">
        <type xsi:type="pogoDsl:StringArrayType"/>
      </argin>
      <argout description="Str[0] = Property name&#xA;Str[1] = date&#xA;Str[2] = Property value number (array case)&#xA;Str[3] = Property value 1&#xA;Str[n] = Property value n">
+1 −1
Original line number Diff line number Diff line
@@ -2901,7 +2901,7 @@ void DataBaseClass::command_factory()
	DbGetPropertyHistClass	*pDbGetPropertyHistCmd =
		new DbGetPropertyHistClass("DbGetPropertyHist",
			Tango::DEVVAR_STRINGARRAY, Tango::DEVVAR_STRINGARRAY,
			"Str[0] = Object name\nStr[2] = Property name",
			"Str[0] = Object name\nStr[1] = Property name",
			"Str[0] = Property name\nStr[1] = date\nStr[2] = Property value number (array case)\nStr[3] = Property value 1\nStr[n] = Property value n",
			Tango::OPERATOR);
	command_list.push_back(pDbGetPropertyHistCmd);
+7 −0
Original line number Diff line number Diff line
@@ -460,6 +460,9 @@ void DataBase::simple_query(std::string sql_query, const char *method, DatabaseC
    o << "\n.The query was: " << sql_query << std::ends;
    o2 << "DataBase::" << method << std::ends;

    ERROR_STREAM << o.str();
    ERROR_STREAM << o2.str();

    Tango::Except::throw_exception(DB_SQLError, o.str(), o2.str());
}

@@ -512,6 +515,7 @@ void DataBase::purge_property(
    sql_query << "SELECT DISTINCT id,date FROM " << table << " WHERE " << field << "=\"" << object << "\" AND name=\""
              << name << "\" ORDER by date";

    DEBUG_STREAM << "DataBase::purge_property(): sql_query " << sql_query.str() << std::endl;
    result = query(sql_query.str(), "purge_property()", dch);
    int nb_item = mysql_num_rows(result);

@@ -519,6 +523,7 @@ void DataBase::purge_property(
    {
        // Purge
        int toDelete = nb_item - historyDepth;
        DEBUG_STREAM << "Purging " << toDelete << " elements" << std::endl;
        for(int j = 0; j < toDelete; j++)
        {
            row2 = mysql_fetch_row(result);
@@ -820,6 +825,8 @@ AutoLock::AutoLock(DataBase *db) :

AutoLock::~AutoLock()
{
    // see https://mariadb.com/docs/server/server-management/variables-and-modes/server-system-variables#autocommit
    // why this works
    const std::string sql_query{"SET autocommit=1;"}; // or COMMIT
    the_db->simple_query(sql_query, "~AutoLock", m_dch);
}
Loading