Skip to content

Commit

Permalink
saving progress 2.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mubshr07 committed Jul 18, 2021
1 parent ed05e65 commit 7addb8d
Show file tree
Hide file tree
Showing 7 changed files with 361 additions and 302 deletions.
114 changes: 97 additions & 17 deletions classes/loggerthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ loggerThread::loggerThread(QObject *parent) : QObject(parent)
readChannelSettingsFile();
qDebug()<<" debug LoggerThread 1 ";

initialize_Dir_FileName();

// ----------------------------------------------------------------
// -------- Set Clock
Expand All @@ -37,7 +38,6 @@ loggerThread::loggerThread(QObject *parent) : QObject(parent)
// ----------------------------------------------------------------


local_logging = false;
local_logTime_MS = 0;
local_log_sec = 0;
local_log_min = 0;
Expand All @@ -46,7 +46,7 @@ loggerThread::loggerThread(QObject *parent) : QObject(parent)
//qDebug()<<" before timer_graph initialize ";
timer_graphValue = new QTimer(this);
connect(timer_graphValue, SIGNAL(timeout()), SLOT(on_timer_graphValue_elapsed()));
//timer_graphValue->start(100);
timer_graphValue->start(200);

//qDebug()<<" debug LoggerThread 3 ";
timer_elapser = new QElapsedTimer();
Expand Down Expand Up @@ -76,7 +76,7 @@ void loggerThread::on_timer_logger_elapsed()
chnlArray[i].Get_RawValue_fromADDRESSAuto();
}
}
if(local_logging)
if(logging_isStarted)
{
// Logging to File
logStr = "";
Expand All @@ -101,7 +101,9 @@ void loggerThread::on_timer_logger_elapsed()
}
} // end of FPGA-Counter Matched

if(local_logging)

/*
if(logging_isStarted)
{
if(local_logTime_MS >= 1000)
{
Expand Down Expand Up @@ -144,7 +146,7 @@ void loggerThread::on_timer_logger_elapsed()
}
//qDebug()<<" local_logTime_MS:: "<<local_logTime_MS;
}

*/



Expand All @@ -159,7 +161,7 @@ void loggerThread::on_timer_logger_elapsed()
chnlArray[i].Get_RawValue_fromADDRESSAuto();
if(!graphWindowIsOpen) {
emit tx_channel_Value(i, chnlArray[i].endResult, chnlArray[i].endResult_Float, chnlArray[i].endResult_Float_Factor);
} else if(graphWindowIsOpen && local_logging) {
} else if(graphWindowIsOpen && logging_isStarted) {
logStr += QString(QString::number(chnlArray[i].endResult_Float_Factor, 'f', 3)+",");
}
}
Expand Down Expand Up @@ -195,6 +197,77 @@ void loggerThread::on_timer_graphValue_elapsed()
chnlArray[settingsCH_id].Get_RawValue_fromADDRESS();
emit tx_channel_Value(settingsCH_id, chnlArray[settingsCH_id].endResult, chnlArray[settingsCH_id].endResult_Float, chnlArray[settingsCH_id].endResult_Float_Factor);
}
else if(!graphWindowIsOpen && !chnlSettingsWindowIsOpen)
{
if(logging_isStarted)
{
for(int i=0; i<TOTAL_CHANNEL; i++)
{
if(chnlArray[i].isChnlEnable())
{
//chnlArray[i].Get_RawValue_fromADDRESSAuto();
emit tx_channel_Value(i, chnlArray[i].autoScheme_endResult, chnlArray[i].autoScheme_endResult_Float, chnlArray[i].autoScheme_endResult_Float_Factor);
}
}
}
else
{
for(int i=0; i<TOTAL_CHANNEL; i++)
{
if(chnlArray[i].isChnlEnable())
{
chnlArray[i].Get_RawValue_fromADDRESS();
emit tx_channel_Value(i, chnlArray[i].endResult, chnlArray[i].endResult_Float, chnlArray[i].endResult_Float_Factor);
}
}
}
}


if(logging_isStarted)
{
if(local_logTime_MS >= 1000)
{
local_logTime_MS -= 1000;
local_log_sec++;
if(local_log_hours<100)
local_LogTime_Str = QString("00"+QString::number(local_log_hours)+ ":");
else if(local_log_hours<10)
local_LogTime_Str = QString("0"+QString::number(local_log_hours)+ ":");
else
local_LogTime_Str = QString(QString::number(local_log_hours)+ ":");

if(local_log_min<10)
local_LogTime_Str += QString("0"+QString::number(local_log_min)+ ":");
else
local_LogTime_Str += QString(QString::number(local_log_min)+ ":");

if(local_log_sec<10)
local_LogTime_Str += QString("0"+QString::number(local_log_sec));
else
local_LogTime_Str += QString(QString::number(local_log_sec));

emit tx_ramdomOP(1, 1.0, local_LogTime_Str);
}
if(local_log_sec > 59)
{
local_log_sec = 0;
local_log_min++;
}
if(local_log_min > 59)
{
local_log_min = 0;
local_log_hours++;
}
nanoSec += timer_elapser->nsecsElapsed();
if(nanoSec > 1000000)
{
nanoSec -= 1000000;
local_logTime_MS++;
}
//qDebug()<<" local_logTime_MS:: "<<local_logTime_MS;
}

}


Expand All @@ -215,7 +288,7 @@ void loggerThread::rx_setSampleTime(int mSec)
sampleRate_MS = mSec;

// -------- Set DataRate
uint32_t setRateInt = mSec; // uSec
uint32_t setRateInt = (mSec * 1000); // uSec
setRateInt /= 0.02;
*(local_FPGA_ADDRESS + 14) = 500;
}
Expand All @@ -236,8 +309,7 @@ void loggerThread::rx_loggingStartStop(bool start, QString filePth)
emit tx_ramdomOP(0, 0.0, "");
}

local_logging = start;
emit tx_loggingStarted(logging_isStarted);
emit tx_loggingStarted_andFileOpenSuccess(logging_isStarted);
}


Expand Down Expand Up @@ -282,19 +354,18 @@ void loggerThread::rx_GraphWindowIsOpen(bool windOpen)
graphWindowIsOpen = windOpen;
if(windOpen)
{
initialize_Dir_FileName();
logSerialNumber=0;
timer_graphValue->start(100);
chnlSettingsWindowIsOpen = false;
*(local_FPGA_ADDRESS + 0x06) = 0x01;
// *(local_FPGA_ADDRESS + 0x06) = 0x01;

*(local_FPGA_ADDRESS + 0x07) = 0x00;
*(local_FPGA_ADDRESS + 0x07) = 0x01;
*(local_FPGA_ADDRESS + 0x07) = 0x00;
// *(local_FPGA_ADDRESS + 0x07) = 0x00;
// *(local_FPGA_ADDRESS + 0x07) = 0x01;
// *(local_FPGA_ADDRESS + 0x07) = 0x00;
}
else {
timer_graphValue->stop();
*(local_FPGA_ADDRESS + 0x06) = 0x00;
//timer_graphValue->stop();
timer_graphValue->start(200);
//*(local_FPGA_ADDRESS + 0x06) = 0x00;
}
}
void loggerThread::rx_ChannelSettingsWindowIsOpen(bool windOpen)
Expand Down Expand Up @@ -329,13 +400,15 @@ void loggerThread::rx_setChannelNewSettings(int chnl, float fac, CHANNEL_PGA pga
{
qDebug()<<"\n\n##################################################";
qDebug()<<" New Chanel Settings:: ID:"<<chnl<<" fac:"<<fac<<" pgaa:"<<pgaa<<" type:"<<typ<<" ref:"<<ref;
timer_graphValue->stop();
chnlArray[chnl].set_Channel_Factor(fac);
chnlArray[chnl].set_Channel_PGA_Type(pgaa, typ);
chnlArray[chnl].set_Channel_Reference(ref);
chnlArray[chnl].setChannelEnableDisable(Enabled);
chnlArray[chnl].reConfigFPGA_forThisChannel();

rx_saveChannelSettingsToFile();
timer_graphValue->start(200);
}
void loggerThread::rx_giveMechannelSettings(int chnl)
{
Expand Down Expand Up @@ -564,11 +637,18 @@ void loggerThread::initialize_User_FileName()
if(logFile->open(QIODevice::WriteOnly))
{
logging_isStarted = true;
*(local_FPGA_ADDRESS + 0x06) = 0x01;

*(local_FPGA_ADDRESS + 0x07) = 0x00;
*(local_FPGA_ADDRESS + 0x07) = 0x01;
*(local_FPGA_ADDRESS + 0x07) = 0x00;
logFile->write(str.toUtf8());
logFile->close();
}
else
{
// disable automatic system
*(local_FPGA_ADDRESS + 0x06) = 0x00;
qDebug()<<"Error in open File";
}
}
Expand Down
3 changes: 1 addition & 2 deletions classes/loggerthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class loggerThread : public QObject

signals:
void tx_channel_Value(int chnl,uint32_t raw, float fVal, float facVal);
void tx_loggingStarted(bool started);
void tx_loggingStarted_andFileOpenSuccess(bool started);
void tx_graphChnlValue(int chnl, float val);
void tx_channelisEnabled(int chnl, bool enableVal);

Expand Down Expand Up @@ -79,7 +79,6 @@ public slots:
int sampleRate_Sec = 2;
int sampleRate_MS = 100;
int sampleRate_MS_Calculated = 0;
bool local_logging = false;
qint64 elapsed_timeNanoSec = 0;
int elapsed_timeMS = 0;
QString logStr = "";
Expand Down
2 changes: 1 addition & 1 deletion configchwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ void ConfigChWin::rx_ChannelValue(int chnl, uint32_t raw, float fVal, float FacV
{
//qDebug()<<" Value Received : Chnnel = "<<chnl<<" value = "<<val;

float newCalcu = fVal + local_currentCH_Factor;
float newCalcu = fVal * local_currentCH_Factor;
ui->lcd_Ch_Value_Raw->display(QString::number(raw, 16));
ui->lcd_Ch_Value_floating->display(QString::number(fVal, 'f', 2));
ui->lcd_Ch_Value_floatingFactor->display(QString::number(newCalcu, 'f', 2));
Expand Down
10 changes: 5 additions & 5 deletions graphwin.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ private slots:
QString styleLogStop = "font: 600 20pt 'Times New Roman'; padding: 5px; background-color: rgb(255, 255, 255); border: 1px solid black; border-radius:5px; color:red;";
QString styleLogStart = "font: 600 20pt 'Times New Roman'; padding: 5px; background-color: lime; border: 1px solid black; border-radius:5px; color:white;";

QString style_removBtn_0 = "font: 500 16pt 'Times New Roman'; padding: 5px; color:white; background-color:"+ plot0_Color.name()+"; border: 1px solid black; border-radius:5px;";
QString style_removBtn_1 = "font: 500 16pt 'Times New Roman'; padding: 5px; color:white; background-color:"+ plot1_Color.name()+"; border: 1px solid black; border-radius:5px;";
QString style_removBtn_2 = "font: 500 16pt 'Times New Roman'; padding: 5px; color:white; background-color:"+ plot2_Color.name()+"; border: 1px solid black; border-radius:5px;";
QString style_removBtn_3 = QString("font: 500 16pt 'Times New Roman'; padding: 5px; color:white; background-color:"+ plot3_Color.name()+"; border: 1px solid black; border-radius:5px;");
QString style_removBtn_0 = "font: 500 14pt 'Times New Roman'; padding: 5px; color:white; background-color:"+ plot0_Color.name()+"; border: 1px solid black; border-radius:5px;";
QString style_removBtn_1 = "font: 500 14pt 'Times New Roman'; padding: 5px; color:white; background-color:"+ plot1_Color.name()+"; border: 1px solid black; border-radius:5px;";
QString style_removBtn_2 = "font: 500 14pt 'Times New Roman'; padding: 5px; color:white; background-color:"+ plot2_Color.name()+"; border: 1px solid black; border-radius:5px;";
QString style_removBtn_3 = QString("font: 500 14pt 'Times New Roman'; padding: 5px; color:white; background-color:"+ plot3_Color.name()+"; border: 1px solid black; border-radius:5px;");

QString style_removBtn_Disabled = "font: 500 16pt 'Times New Roman'; padding: 5px; color:black; background-color:transparent; border: 1px solid transparent; border-radius:5px;";
QString style_removBtn_Disabled = "font: 500 14pt 'Times New Roman'; padding: 5px; color:black; background-color:transparent; border: 1px solid transparent; border-radius:5px;";

QString logUserFilePath = "";

Expand Down
Loading

0 comments on commit 7addb8d

Please sign in to comment.