@@ -34,7 +34,8 @@ const int CS_BULK = 5;
3434
3535
3636Tsmppt::Tsmppt (const QString &IPAddress, const int port, int interval, int slave, QObject *parent):
37- QObject(parent), mInitialized(false ), mTimer(new QTimer(this )), m_interval(interval), m_cs(0 ), m_t_bulk(1 ), m_t_bulk_ms(0 ), yield_user(0 ), yield_system(0 )
37+ QObject(parent), mInitialized(false ), mTimer(new QTimer(this )), m_interval(interval), m_cs(0 ), m_t_bulk(1 ),
38+ m_t_bulk_ms(0 ), yield_user(0 ), yield_system(0 ), m_model(1 )
3839{
3940 QLOG_DEBUG () << " Tsmppt::Tsmppt(" << IPAddress << " , " << port << " , " << interval << " , " << slave << " )" ;
4041 mCtx = modbus_new_tcp_pi (IPAddress.toStdString ().c_str (), QString::number (port).toStdString ().c_str ());
@@ -54,7 +55,6 @@ QObject(parent), mInitialized(false), mTimer(new QTimer(this)), m_interval(inter
5455#endif
5556 modbus_set_slave (mCtx , slave);
5657 mTimer ->setInterval (m_interval);
57- mTimer ->start ();
5858 connect (mTimer , SIGNAL (timeout ()), this , SLOT (onTimeout ()));
5959}
6060
@@ -98,6 +98,7 @@ bool Tsmppt::initialize()
9898 }
9999
100100 uint16_t regs[6 ];
101+
101102 if (!readInputRegisters (REG_V_PU, 6 , regs))
102103 {
103104 modbus_close (mCtx );
@@ -122,23 +123,23 @@ bool Tsmppt::initialize()
122123 ver += regs[4 ] & 0x0f ;
123124 m_fw_ver = QString::number (ver);
124125
125- // Read hardware version:
126+ // Hardware version:
126127 if (!readInputRegisters (REG_EHW_VERSION, 1 , regs))
127128 {
128129 modbus_close (mCtx );
129130 return false ;
130131 }
131132 m_hw_ver = QString::number (regs[0 ] >> 8 ) + " ." + QString::number (regs[0 ] & 0xff );
132133
133- // Read model
134+ // Model
134135 if (!readInputRegisters (REG_EMODEL, 1 , regs))
135136 {
136137 modbus_close (mCtx );
137138 return false ;
138139 }
139140 m_model = regs[0 ];
140141
141- // Read serial number:
142+ // Serial number:
142143 if (!readInputRegisters (REG_ESERIAL, 4 , regs))
143144 {
144145 modbus_close (mCtx );
@@ -235,7 +236,7 @@ void Tsmppt::updateValues()
235236 // Charge state:
236237 setChargeState (reg[REG_CHARGE_STATE-REG_FIRST_DYN]);
237238
238- if (m_cs == CS_BULK)
239+ if (m_cs == CS_BULK)
239240 m_t_bulk_ms += m_interval;
240241 else if (m_cs == CS_NIGHT)
241242 m_t_bulk_ms = 0 ;
@@ -556,3 +557,7 @@ void Tsmppt::onTimeout()
556557 mTimer ->start ();
557558}
558559
560+ void Tsmppt::startLogging ()
561+ {
562+ mTimer ->start ();
563+ }
0 commit comments