Commit 08116e28 authored by Graziano Scalamera's avatar Graziano Scalamera
Browse files

Remove longs

parent 810e8914
......@@ -1250,32 +1250,31 @@ uint16_t PLCslu::plc_swap(uint16_t in)
}
long int PLCslu::calc_timeval(u_char month,u_char year,u_char hour,u_char day,u_char sec,u_char min,u_char wday,u_char msec)
time_t PLCslu::calc_timeval(u_char month,u_char year,u_char hour,u_char day,u_char sec,u_char min,u_char wday,u_char msec)
{
char buffer [10];
tm t2;
time_t tn;
memset (buffer,0,10);
memset (buffer,0,10);
sprintf (buffer, "%x", sec);
t2.tm_sec = atoi(buffer);
memset (buffer,0,10);
memset (buffer,0,10);
sprintf (buffer, "%x", min);
t2.tm_min = atoi(buffer);
memset (buffer,0,10);
memset (buffer,0,10);
sprintf (buffer, "%x", hour);
t2.tm_hour = atoi(buffer);
memset (buffer,0,10);
memset (buffer,0,10);
sprintf (buffer, "%x", day);
t2.tm_mday = atoi(buffer);
memset (buffer,0,10);
memset (buffer,0,10);
sprintf (buffer, "%x", month);
t2.tm_mon = atoi(buffer)-1;
memset (buffer,0,10);
memset (buffer,0,10);
sprintf (buffer, "%x", year);
t2.tm_year = atoi(buffer)+100;
memset (buffer,0,10);
memset (buffer,0,10);
sprintf (buffer, "%x", wday);
t2.tm_wday = atoi(buffer)-1;
//0: consider time to convert never dst, time converted automatically adjusted with dst
......@@ -1285,29 +1284,27 @@ long int PLCslu::calc_timeval(u_char month,u_char year,u_char hour,u_char day,u_
DEBUG_STREAM << __func__<<": year=0x"<<hex<<(int)year<<" month=0x"<<(int)month<<" day=0x"<<(int)day<<" hour=0x"<<(int)hour<<" min=0x"<<(int)min<<" sec=0x"<<(int)sec<<dec<<endl;
tn = mktime(&t2)/*-timezone*/;//with -timezone as if GMT
DEBUG_STREAM << __func__<<": --> tn="<<tn<<" timezone="<<timezone<<" isdst="<<t2.tm_isdst<<endl;
return (long int)tn;
return tn;
}
long int PLCslu::calc_time_ms(u_char wday,u_char msec)
uint32_t PLCslu::calc_time_ms(u_char wday,u_char msec)
{
char buffer [10];
long d = 0;
long ms_new;
int c1, c2;
ms_new = 0;
memset (buffer,0,10);
sprintf (buffer, "%x", msec);
c1 = atoi(buffer);
memset (buffer,0,10);
sprintf (buffer, "%x", wday);
c2 = atoi(buffer);
ms_new = c1*10+(c2>>4);
d = ms_new;
uint32_t ms_new;
int c1, c2;
ms_new = 0;
memset (buffer,0,10);
sprintf (buffer, "%x", msec);
c1 = atoi(buffer);
memset (buffer,0,10);
wday = wday >> 4;
sprintf (buffer, "%x", wday);
c2 = atoi(buffer);
ms_new = c1*10+c2;
return d;
return ms_new;
}
void PLCslu::syncronize()
{
DEBUG_STREAM << "PLCslu::syncronize(): entering... !" << endl;
......
......@@ -507,8 +507,8 @@ public :
Tango::DevBoolean plc_status;
uint16_t plc_swap(uint16_t in);
long int calc_timeval(u_char,u_char,u_char,u_char,u_char,u_char,u_char,u_char);
long int calc_time_ms(u_char,u_char);
time_t calc_timeval(u_char,u_char,u_char,u_char,u_char,u_char,u_char,u_char);
uint32_t calc_time_ms(u_char,u_char);
void syncronize();
struct timeval last_rx_51;
......@@ -522,8 +522,6 @@ protected :
Tango::MultiAttribute * attr_list;
Tango::Util * tg;
string thestatus;
unsigned long timeout_secs;
unsigned long timeout_nanosecs;
void send_frame (unsigned char *query, short query_length);
public:
void write_msg(void);
......
......@@ -121,7 +121,8 @@ class plcsrvthread : public omni_thread, public Tango::LogAdapter{
void Srv_Prepare(void);
uint16_t plc_swap(uint16_t in);
long ll, mm;
time_t ll;
uint32_t mm;
u_short v;
int brk;
......
......@@ -152,11 +152,12 @@ void plctimingthread::log_states(PLCslu_ns::intlck_dbstat m)
else {
gettimeofday(&t_now,NULL); //takes timestamp
date_double = ((double) t_now.tv_sec) + ((double) t_now.tv_usec)/1000000;//change
long int ll, mm;
time_t ll;
uint32_t 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);
// cout << ll << "." << mm << " -> " << (int)m.year << ", " << (int)m.month << ", " << (int)m.day << ", " << (int)m.hour << ", " << (int)m.min << ", " << (int)m.sec << endl;
date_plc = ((double)ll) + mm/1000.0;
date_plc = ((double)ll) + ((double)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
......@@ -306,10 +307,11 @@ void plctimingthread::log_people(PLCslu_ns::intlck_dbacc m)
gettimeofday(&t_now,NULL); //takes timestamp
date_double = ((double) t_now.tv_sec) + ((double) t_now.tv_usec)/1000000;//change
long int ll, mm;
time_t ll;
uint32_t 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);
date_plc = ((double)ll) + mm/1000.0;
date_plc = ((double)ll) + ((double)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);
......@@ -380,10 +382,11 @@ void plctimingthread::log_people(PLCslu_ns::intlck_dbacc m)
{
gettimeofday(&t_now,NULL); //takes timestamp
date_double = ((double) t_now.tv_sec) + ((double) t_now.tv_usec)/1000000;//change
long int ll, mm;
time_t ll;
uint32_t 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);
date_plc = ((double)ll) + mm/1000.0;
date_plc = ((double)ll) + ((double)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);
......@@ -530,10 +533,11 @@ void plctimingthread::log_people2(PLCslu_ns::intlck_dbacc2 m)
gettimeofday(&t_now,NULL); //takes timestamp
date_double = ((double) t_now.tv_sec) + ((double) t_now.tv_usec)/1000000;//change
long int ll, mm;
time_t ll;
uint32_t 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);
date_plc = ((double)ll) + mm/1000.0;
date_plc = ((double)ll) + ((double)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);
......@@ -604,10 +608,11 @@ void plctimingthread::log_people2(PLCslu_ns::intlck_dbacc2 m)
{
gettimeofday(&t_now,NULL); //takes timestamp
date_double = ((double) t_now.tv_sec) + ((double) t_now.tv_usec)/1000000;//change
long int ll, mm;
time_t ll;
uint32_t 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);
date_plc = ((double)ll) + mm/1000.0;
date_plc = ((double)ll) + ((double)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);
......
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