Commit 810e8914 authored by Graziano Scalamera's avatar Graziano Scalamera
Browse files

Remove warnings

parent 95bb641d
static const char *RcsId = "$Header: /home/cvsadm/cvsroot/fermi/servers/plcslu/src/ClassFactory.cpp,v 1.1 2012-10-30 09:23:05 graziano Exp $";
//+=============================================================================
//
// file : ClassFactory.cpp
......
static const char *RcsId = "$Header: /home/cvsadm/cvsroot/fermi/servers/plcslu/src/PLCslu.cpp,v 1.11 2019-08-05 08:55:52 graziano Exp $";
//+=============================================================================
//
// file : PLCslu.cpp
......@@ -144,6 +143,7 @@ const log_msg log_list::pop_front(void)
err << "omni_thread_fatal exception waiting on omni_condition, err=" << ex.error << ends;
printf("log_list::pop_front(): %s\n", err.str().c_str());
log_msg a;
a.numDB=0;//FOO
this->unlock();
sleep(1);
return(a);
......@@ -155,6 +155,7 @@ const log_msg log_list::pop_front(void)
printf("log_list::pop_front: %s\n", err.str().c_str());
Tango::Except::print_exception(ex);
log_msg a;
a.numDB=0;//FOO
this->unlock();
sleep(1);
return(a);
......@@ -163,6 +164,7 @@ const log_msg log_list::pop_front(void)
{
printf("log_list::pop_front(): catched unknown exception waiting on omni_condition!!\n");
log_msg a;
a.numDB=0;//FOO
this->unlock();
sleep(1);
return(a);
......@@ -217,7 +219,6 @@ PLCslu::PLCslu(Tango::DeviceClass *cl,const char *s,const char *d)
void PLCslu::delete_device()
{
// Delete device's allocated object
int t_finish = 3000;// h_timeout[0]time in msec to wait for the thread to complete
abortflag = true; //stops thread
//wake log queue with a fake message
log_msg msg;
......@@ -754,14 +755,14 @@ void PLCslu::load_cond(){
int k=0;
int linestatok = 0;
int linealmok = 0;
int lineattrok = 0;
//int lineattrok = 0;
int linecmdok = 0;
int n;
//int n;
while(std::getline(fd, lineread, '\n'))
{ // Read line by line
if(((int)lineread.find("db_")==-1)&&((int)lineread.length()>4))
{// header lines to drop
n = 0;
//n = 0;
k++;
memset(pbuf, 0, 50);
//typ = lineread.substr(0, lineread.find('\t'));
......@@ -1169,10 +1170,10 @@ void PLCslu::write_msg()
memcpy(query, &prepared_cmd, sizeof(intlck_cmd));
DEBUG_STREAM <<__FUNCTION__<<": size: "<< sizeof(intlck_cmd)<< endl;
for(int k=0;k<sizeof(intlck_cmd);)
for(size_t k=0;k<sizeof(intlck_cmd);)
{
stringstream tmp;
int g;
size_t g;
tmp << "dbTX: "<<setw(3)<<setfill(' ')<<k<<" -> ";
for(g=0; g<10; g++)
{
......
static const char *RcsId = "$Header: /home/cvsadm/cvsroot/fermi/servers/plcslu/src/PLCsluStateMachine.cpp,v 1.2 2017-08-09 08:15:35 graziano Exp $";
//+=============================================================================
//
// file : PLCsluStateMachine.cpp
......
static const char *RcsId = "$Header: /home/cvsadm/cvsroot/fermi/servers/plcslu/src/main.cpp,v 1.1 2012-10-30 09:23:05 graziano Exp $";
//+=============================================================================
//
// file : main.cpp
......
......@@ -213,10 +213,10 @@ void plcsrvthread::stat_msg(void)
gettimeofday(&(t_PLCslu->last_rx_51), NULL);
for(int k=0;k<(sizeof(PLCslu_ns::intlck_dbstat));)
for(size_t k=0;k<(sizeof(PLCslu_ns::intlck_dbstat));)
{
stringstream tmp;
int g;
size_t g;
tmp << "db51: "<<setw(3)<<setfill(' ')<<k<<" -> ";
for(g=0; g<10; g++)
{
......@@ -240,10 +240,10 @@ void plcsrvthread::stat_msg(void)
}
u_short b = 0;
for(int j=0;j<sizeof(PLCslu_ns::intlck_dbstat);j++)
for(size_t j=0;j<sizeof(PLCslu_ns::intlck_dbstat);j++)
{//218
b=(int)sbuf3[j];
for(int i=0;i<8;i++)
for(size_t i=0;i<8;i++)
{
t_PLCslu->msg_alm[8*j+i] = (((b&0x00ff)&bmask[i])>>i)==0?false:true;
}
......@@ -397,17 +397,7 @@ void plcsrvthread::acc_msg(void)
t_PLCslu->msg_acc[8*j+i] = (((b&0x00ff)&bmask[i])>>i)==0?false:true;
}
}
//******************************************************
/*for (int i=0; i<(int)(sizeof(PLCslu_ns::intlck_dbacc))/2; i++)
{
// sbuf3[i] = ntohs(sbuf3[i]);///labels accessi
}
//******************************************************
//********SERVE LO SWAP?*****
//******************************************************
for (int i=0; i<((NUM_ACC_BLK*sizeof(u_char))/2); i++){
// sbuf3[i] = plc_swap(sbuf3[i]);
}*/
memcpy(&(t_PLCslu->message_acc), sbuf3, (sizeof(PLCslu_ns::intlck_dbacc)));
DEBUG_STREAM << "plcsrvthread::run() received db 50 "<<endl;
//******************************************************
......@@ -541,17 +531,6 @@ void plcsrvthread::acc_msg2(void)
t_PLCslu->msg_acc2[8*j+i] = (((b&0x00ff)&bmask[i])>>i)==0?false:true;
}
}
//******************************************************
/*for (int i=0; i<(int)(sizeof(PLCslu_ns::intlck_dbacc2))/2; i++)
{
// sbuf3[i] = ntohs(sbuf3[i]);///labels accessi
}
//******************************************************
//********SERVE LO SWAP?*****
//******************************************************
for (int i=0; i<((NUM_ACC_BLK*sizeof(u_char))/2); i++){
// sbuf3[i] = plc_swap(sbuf3[i]);
}*/
memcpy(&(t_PLCslu->message_acc2), sbuf3, (sizeof(PLCslu_ns::intlck_dbacc2)));
DEBUG_STREAM << "plcsrvthread::run() received db 49 "<<endl;
//******************************************************
......
......@@ -23,18 +23,18 @@ void plctimingthread::run(void *)
usleep(pausesec2*1000000+pausenano2/1000);//sleep for heartbeat time, for setup
//for syncronization
int ch_hour, ch_min;
/*int ch_hour, ch_min;
ch_hour = TIMEADJUST_DEF_H;
ch_min = TIMEADJUST_DEF_M;
char ch_today;
ch_today = 0;
ch_today = 0;*/
while (!t_PLCslu->abortflag) {
//for syncronization
time_t tim=time(NULL);
/*time_t tim=time(NULL);
tm *now=localtime(&tim);
/*if((now->tm_hour-ch_hour==0)&&(now->tm_min-ch_min==0)&&((now->tm_mday-ch_today)!=0)){//if it's time to sync
if((now->tm_hour-ch_hour==0)&&(now->tm_min-ch_min==0)&&((now->tm_mday-ch_today)!=0)){//if it's time to sync
t_PLCslu->syncronize();
ch_today = now->tm_mday;//time adjust once a day
}*/
......@@ -120,20 +120,14 @@ void plctimingthread::log_states(PLCslu_ns::intlck_dbstat m)
char query[DB_QUERY_LEN];
memset(query, 0, DB_QUERY_LEN);
MYSQL_STMT *stmt;
MYSQL_BIND log_bind[2];
my_ulonglong affected_rows;
int param_count;
double double_data;
unsigned long blob_length;
double date_double, date_plc;
my_bool is_null;
int y;
//my_bool is_null;
//int y;
timeval t_now;
my_ulonglong id;
// time_t mktime ( struct tm * timeptr );
time_t rawtime, plc_raw;
struct tm * ptm, plc_time;
time_t rawtime;
struct tm * ptm;
time ( &rawtime );
......@@ -144,7 +138,7 @@ void plctimingthread::log_states(PLCslu_ns::intlck_dbstat m)
if (t_PLCslu->blk_db51_buffer == NULL) { // <<<<<<<-----------------------
for (int i=0; i<NUM_DATA_BLK; i++) {
memset(query, 0, DB_QUERY_LEN);
y = snprintf(query, DB_QUERY_LEN, "INSERT INTO %s_db51_%d SET byte=%d, value=%d", t_PLCslu->dbtable, 1900+ptm->tm_year, i+12, blk_db51_pointer[i]);
/*y =*/ snprintf(query, DB_QUERY_LEN, "INSERT INTO %s_db51_%d SET byte=%d, value=%d", t_PLCslu->dbtable, 1900+ptm->tm_year, i+12, blk_db51_pointer[i]);
cout << query << endl;
if (mysql_query(&(t_PLCslu->dbp), query)) {
INFO_STREAM << "Error inserting new DB51 Query='"<<query<<"' err='" <<mysql_error(&(t_PLCslu->dbp)) <<"'"<< endl;
......@@ -162,14 +156,13 @@ void plctimingthread::log_states(PLCslu_ns::intlck_dbstat m)
ll = t_PLCslu->calc_timeval(m.year, m.month, m.day, m.hour, m.min, m.sec, m.wday, m.msec);
mm = t_PLCslu->calc_time_ms(m.wday, m.msec);
// cout << ll << "." << mm << " -> " << (int)m.year << ", " << (int)m.month << ", " << (int)m.day << ", " << (int)m.hour << ", " << (int)m.min << ", " << (int)m.sec << endl;
plc_raw = mktime(&plc_time);
date_plc = ((double)ll) + mm/1000.0;
for (int i=0; i<NUM_DATA_BLK; i++) {
if (i+12>=48 && i+12<62) continue; // skip some int values //TODO
if (i+12>=108 && i+12<116) continue; // skip real values //TODO
if (t_PLCslu->blk_db51_buffer[i] != blk_db51_pointer[i]) {
memset(query, 0, DB_QUERY_LEN);
y = snprintf(query, DB_QUERY_LEN, "INSERT INTO %s_time_%d SET db_time=%13.3f, plc_time=%13.3f, valid='Y'", t_PLCslu->dbtable, 1900+ptm->tm_year, date_double, date_plc);
/*y =*/ snprintf(query, DB_QUERY_LEN, "INSERT INTO %s_time_%d SET db_time=%13.3f, plc_time=%13.3f, valid='Y'", t_PLCslu->dbtable, 1900+ptm->tm_year, date_double, date_plc);
// cout << query << endl;
if (mysql_query(&(t_PLCslu->dbp), query)) {
INFO_STREAM << "Error inserting time. Query='"<<query<<"' err='" << mysql_error(&(t_PLCslu->dbp)) <<"'"<< endl;
......@@ -187,9 +180,8 @@ void plctimingthread::log_states(PLCslu_ns::intlck_dbstat m)
if (i+12>=48 && i+12<62) continue; // skip some int values //TODO
if (i+12>=108 && i+12<116) continue; // skip real values //TODO
if (t_PLCslu->blk_db51_buffer[i] != blk_db51_pointer[i]) {
int myid = id;
memset(query, 0, DB_QUERY_LEN);
y = snprintf(query, DB_QUERY_LEN, "INSERT INTO %s_db51_%d SET time_id=%llu, byte_number=%d, value=%d", t_PLCslu->dbtable, 1900+ptm->tm_year, id, i+12, blk_db51_pointer[i]);
/*y =*/ snprintf(query, DB_QUERY_LEN, "INSERT INTO %s_db51_%d SET time_id=%llu, byte_number=%d, value=%d", t_PLCslu->dbtable, 1900+ptm->tm_year, id, i+12, blk_db51_pointer[i]);
// cout << query << endl;
if (mysql_query(&(t_PLCslu->dbp), query)) {
INFO_STREAM << "Error inserting DB51. Query='"<<query<<"' err='" <<mysql_error(&(t_PLCslu->dbp)) <<"'"<< endl;
......@@ -211,20 +203,15 @@ void plctimingthread::log_people(PLCslu_ns::intlck_dbacc m)
memset(query, 0, DB_QUERY_LEN);
double date_double, date_plc;
my_ulonglong id;
int y;
//int y;
timeval t_now;
time_t rawtime, plc_raw;
struct tm * ptm, plc_time;
time_t rawtime;
struct tm * ptm;
time ( &rawtime );
ptm = gmtime ( &rawtime );
int ret = 0;
stringstream stat_table_name;
stat_table_name << t_PLCslu->dbtable << "_db50_" << (1900+ptm->tm_year);
......@@ -234,7 +221,6 @@ void plctimingthread::log_people(PLCslu_ns::intlck_dbacc m)
string tmp_name_id;
my_ulonglong affected_rows;
int u=0, v=0, found=0;
for(int k=0;k<18;k++)
{
unsigned int name_id;
......@@ -284,7 +270,7 @@ void plctimingthread::log_people(PLCslu_ns::intlck_dbacc m)
DEBUG_STREAM << " num_found="<<num_found<<" after query="<<select_str.str();
//row = mysql_fetch_row(res);
//if(num_found > 0 /*&& (row = mysql_fetch_row(res))*/)
if(row = mysql_fetch_row(res))
if((row = mysql_fetch_row(res)))
{
name_found = true;
tmp_name_id = row[0];
......@@ -323,11 +309,10 @@ void plctimingthread::log_people(PLCslu_ns::intlck_dbacc m)
long int ll, mm;
ll = t_PLCslu->calc_timeval(m.year, m.month, m.day, m.hour, m.min, m.sec, m.wday, m.msec);
mm = t_PLCslu->calc_time_ms(m.wday, m.msec);
plc_raw = mktime(&plc_time);
date_plc = ((double)ll) + mm/1000.0;
memset(query, 0, DB_QUERY_LEN);
y = snprintf(query, DB_QUERY_LEN, "INSERT INTO %s_time_%d SET db_time=%13.3f, plc_time=%13.3f, valid='Y'", t_PLCslu->dbtable, 1900+ptm->tm_year, date_double, date_plc);
/*y =*/ snprintf(query, DB_QUERY_LEN, "INSERT INTO %s_time_%d SET db_time=%13.3f, plc_time=%13.3f, valid='Y'", t_PLCslu->dbtable, 1900+ptm->tm_year, date_double, date_plc);
// cout << query << endl;
if (mysql_query(&(t_PLCslu->dbp), query)) {
INFO_STREAM << "Error inserting time. Query='"<<query<<"' err='" << mysql_error(&(t_PLCslu->dbp)) <<"'"<< endl;
......@@ -338,7 +323,7 @@ void plctimingthread::log_people(PLCslu_ns::intlck_dbacc m)
}
id = mysql_insert_id(&(t_PLCslu->dbp));
y = snprintf(query, DB_QUERY_LEN, "INSERT INTO %s_db50_%d SET time_id=%llu, position=%d, enabled_user_id=%d, present='Y'", t_PLCslu->dbtable, 1900+ptm->tm_year, id, k, name_id);
/*y =*/ snprintf(query, DB_QUERY_LEN, "INSERT INTO %s_db50_%d SET time_id=%llu, position=%d, enabled_user_id=%d, present='Y'", t_PLCslu->dbtable, 1900+ptm->tm_year, id, k, name_id);
if(mysql_query(&t_PLCslu->dbp, query))
{
INFO_STREAM << "plctimingthread::log_people(): ERROR in query=" << query <<"' err='" <<mysql_error(&(t_PLCslu->dbp)) <<"'"<< endl;
......@@ -381,7 +366,7 @@ void plctimingthread::log_people(PLCslu_ns::intlck_dbacc m)
DEBUG_STREAM << " num_found="<<num_found<<" after query="<<select_str.str();
//row = mysql_fetch_row(res);
//if(num_found > 0 /*&& (row = mysql_fetch_row(res))*/)
if(row = mysql_fetch_row(res))
if((row = mysql_fetch_row(res)))
{
name_found = true;
tmp_name_id = row[0];
......@@ -398,11 +383,10 @@ void plctimingthread::log_people(PLCslu_ns::intlck_dbacc m)
long int ll, mm;
ll = t_PLCslu->calc_timeval(m.year, m.month, m.day, m.hour, m.min, m.sec, m.wday, m.msec);
mm = t_PLCslu->calc_time_ms(m.wday, m.msec);
plc_raw = mktime(&plc_time);
date_plc = ((double)ll) + mm/1000.0;
memset(query, 0, DB_QUERY_LEN);
y = snprintf(query, DB_QUERY_LEN, "INSERT INTO %s_time_%d SET db_time=%13.3f, plc_time=%13.3f, valid='Y'", t_PLCslu->dbtable, 1900+ptm->tm_year, date_double, date_plc);
/*y =*/ snprintf(query, DB_QUERY_LEN, "INSERT INTO %s_time_%d SET db_time=%13.3f, plc_time=%13.3f, valid='Y'", t_PLCslu->dbtable, 1900+ptm->tm_year, date_double, date_plc);
// cout << query << endl;
if (mysql_query(&(t_PLCslu->dbp), query)) {
INFO_STREAM << "Error inserting time. Query='"<<query<<"' err='" << mysql_error(&(t_PLCslu->dbp)) <<"'"<< endl;
......@@ -413,7 +397,7 @@ void plctimingthread::log_people(PLCslu_ns::intlck_dbacc m)
}
id = mysql_insert_id(&(t_PLCslu->dbp));
y = snprintf(query, DB_QUERY_LEN, "INSERT INTO %s_db50_%d SET time_id=%llu, position=%d, enabled_user_id=%d, present='N'", t_PLCslu->dbtable, 1900+ptm->tm_year, id, k, name_id);
/*y =*/ snprintf(query, DB_QUERY_LEN, "INSERT INTO %s_db50_%d SET time_id=%llu, position=%d, enabled_user_id=%d, present='N'", t_PLCslu->dbtable, 1900+ptm->tm_year, id, k, name_id);
if(mysql_query(&t_PLCslu->dbp, query))
{
INFO_STREAM << "plctimingthread::log_people(): ERROR in query=" << query <<"' err='" <<mysql_error(&(t_PLCslu->dbp)) <<"'"<< endl;
......@@ -443,21 +427,16 @@ void plctimingthread::log_people2(PLCslu_ns::intlck_dbacc2 m)
memset(query, 0, DB_QUERY_LEN);
double date_double, date_plc;
my_ulonglong id;
int y;
//int y;
timeval t_now;
time_t rawtime, plc_raw;
struct tm * ptm, plc_time;
time_t rawtime;
struct tm * ptm;
time ( &rawtime );
ptm = gmtime ( &rawtime );
int ret = 0;
stringstream stat_table_name;
stat_table_name << t_PLCslu->dbtable << "_db49_" << (1900+ptm->tm_year);
......@@ -466,7 +445,6 @@ void plctimingthread::log_people2(PLCslu_ns::intlck_dbacc2 m)
string tmp_name_id;
my_ulonglong affected_rows;
int u=0, v=0, found=0;
for(int k=0;k<2;k++)
{
unsigned int name_id;
......@@ -516,7 +494,7 @@ void plctimingthread::log_people2(PLCslu_ns::intlck_dbacc2 m)
DEBUG_STREAM << " num_found="<<num_found<<" after query="<<select_str.str();
//row = mysql_fetch_row(res);
//if(num_found > 0 /*&& (row = mysql_fetch_row(res))*/)
if(row = mysql_fetch_row(res))
if((row = mysql_fetch_row(res)))
{
name_found = true;
tmp_name_id = row[0];
......@@ -555,11 +533,10 @@ void plctimingthread::log_people2(PLCslu_ns::intlck_dbacc2 m)
long int ll, mm;
ll = t_PLCslu->calc_timeval(m.year, m.month, m.day, m.hour, m.min, m.sec, m.wday, m.msec);
mm = t_PLCslu->calc_time_ms(m.wday, m.msec);
plc_raw = mktime(&plc_time);
date_plc = ((double)ll) + mm/1000.0;
memset(query, 0, DB_QUERY_LEN);
y = snprintf(query, DB_QUERY_LEN, "INSERT INTO %s_time_%d SET db_time=%13.3f, plc_time=%13.3f, valid='Y'", t_PLCslu->dbtable, 1900+ptm->tm_year, date_double, date_plc);
/*y =*/ snprintf(query, DB_QUERY_LEN, "INSERT INTO %s_time_%d SET db_time=%13.3f, plc_time=%13.3f, valid='Y'", t_PLCslu->dbtable, 1900+ptm->tm_year, date_double, date_plc);
// cout << query << endl;
if (mysql_query(&(t_PLCslu->dbp), query)) {
INFO_STREAM << "Error inserting time. Query='"<<query<<"' err='" << mysql_error(&(t_PLCslu->dbp)) <<"'"<< endl;
......@@ -570,7 +547,7 @@ void plctimingthread::log_people2(PLCslu_ns::intlck_dbacc2 m)
}
id = mysql_insert_id(&(t_PLCslu->dbp));
y = snprintf(query, DB_QUERY_LEN, "INSERT INTO %s_db49_%d SET time_id=%llu, position=%d, enabled_user_id=%d, present='Y'", t_PLCslu->dbtable, 1900+ptm->tm_year, id, k, name_id);
/*y =*/ snprintf(query, DB_QUERY_LEN, "INSERT INTO %s_db49_%d SET time_id=%llu, position=%d, enabled_user_id=%d, present='Y'", t_PLCslu->dbtable, 1900+ptm->tm_year, id, k, name_id);
if(mysql_query(&t_PLCslu->dbp, query))
{
INFO_STREAM << "plctimingthread::log_people2(): ERROR in query=" << query <<"' err='" <<mysql_error(&(t_PLCslu->dbp)) <<"'"<< endl;
......@@ -613,7 +590,7 @@ void plctimingthread::log_people2(PLCslu_ns::intlck_dbacc2 m)
DEBUG_STREAM << " num_found="<<num_found<<" after query="<<select_str.str();
//row = mysql_fetch_row(res);
//if(num_found > 0 /*&& (row = mysql_fetch_row(res))*/)
if(row = mysql_fetch_row(res))
if((row = mysql_fetch_row(res)))
{
name_found = true;
tmp_name_id = row[0];
......@@ -630,11 +607,10 @@ void plctimingthread::log_people2(PLCslu_ns::intlck_dbacc2 m)
long int ll, mm;
ll = t_PLCslu->calc_timeval(m.year, m.month, m.day, m.hour, m.min, m.sec, m.wday, m.msec);
mm = t_PLCslu->calc_time_ms(m.wday, m.msec);
plc_raw = mktime(&plc_time);
date_plc = ((double)ll) + mm/1000.0;
memset(query, 0, DB_QUERY_LEN);
y = snprintf(query, DB_QUERY_LEN, "INSERT INTO %s_time_%d SET db_time=%13.3f, plc_time=%13.3f, valid='Y'", t_PLCslu->dbtable, 1900+ptm->tm_year, date_double, date_plc);
/*y =*/ snprintf(query, DB_QUERY_LEN, "INSERT INTO %s_time_%d SET db_time=%13.3f, plc_time=%13.3f, valid='Y'", t_PLCslu->dbtable, 1900+ptm->tm_year, date_double, date_plc);
// cout << query << endl;
if (mysql_query(&(t_PLCslu->dbp), query)) {
INFO_STREAM << "Error inserting time. Query='"<<query<<"' err='" << mysql_error(&(t_PLCslu->dbp)) <<"'"<< endl;
......@@ -645,7 +621,7 @@ void plctimingthread::log_people2(PLCslu_ns::intlck_dbacc2 m)
}
id = mysql_insert_id(&(t_PLCslu->dbp));
y = snprintf(query, DB_QUERY_LEN, "INSERT INTO %s_db49_%d SET time_id=%llu, position=%d, enabled_user_id=%d, present='N'", t_PLCslu->dbtable, 1900+ptm->tm_year, id, k, name_id);
/*y =*/ snprintf(query, DB_QUERY_LEN, "INSERT INTO %s_db49_%d SET time_id=%llu, position=%d, enabled_user_id=%d, present='N'", t_PLCslu->dbtable, 1900+ptm->tm_year, id, k, name_id);
if(mysql_query(&t_PLCslu->dbp, query))
{
INFO_STREAM << "plctimingthread::log_people2(): ERROR in query=" << query <<"' err='" <<mysql_error(&(t_PLCslu->dbp)) <<"'"<< endl;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment