1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-23 10:05:46 -05:00

LimeSDR input: implemented temperature reading

This commit is contained in:
f4exb 2017-07-03 13:42:11 +02:00
parent 8da0464a54
commit 8a19a66af0
5 changed files with 122 additions and 1 deletions

View File

@ -31,9 +31,11 @@
MESSAGE_CLASS_DEFINITION(LimeSDRInput::MsgConfigureLimeSDR, Message)
MESSAGE_CLASS_DEFINITION(LimeSDRInput::MsgGetStreamInfo, Message)
MESSAGE_CLASS_DEFINITION(LimeSDRInput::MsgGetDeviceInfo, Message)
MESSAGE_CLASS_DEFINITION(LimeSDRInput::MsgSetReferenceConfig, Message)
MESSAGE_CLASS_DEFINITION(LimeSDRInput::MsgReportLimeSDRToGUI, Message)
MESSAGE_CLASS_DEFINITION(LimeSDRInput::MsgReportStreamInfo, Message)
MESSAGE_CLASS_DEFINITION(LimeSDRInput::MsgReportDeviceInfo, Message)
LimeSDRInput::LimeSDRInput(DeviceSourceAPI *deviceAPI) :
@ -440,6 +442,46 @@ bool LimeSDRInput::handleMessage(const Message& message)
return true;
}
else if (MsgGetDeviceInfo::match(message))
{
if (m_deviceAPI->isBuddyLeader())
{
double temp = 0.0;
if (m_deviceShared.m_deviceParams->getDevice() && (LMS_GetChipTemperature(m_deviceShared.m_deviceParams->getDevice(), 0, &temp) == 0))
{
qDebug("LimeSDRInput::handleMessage: MsgGetDeviceInfo: temperature: %f", temp);
}
else
{
qDebug("LimeSDRInput::handleMessage: MsgGetDeviceInfo: cannot get temperature");
}
// send to oneself
MsgReportDeviceInfo *report = MsgReportDeviceInfo::create(temp);
m_deviceAPI->getDeviceOutputMessageQueue()->push(report);
// send to source buddies
const std::vector<DeviceSourceAPI*>& sourceBuddies = m_deviceAPI->getSourceBuddies();
std::vector<DeviceSourceAPI*>::const_iterator itSource = sourceBuddies.begin();
for (; itSource != sourceBuddies.end(); ++itSource)
{
MsgReportDeviceInfo *report = MsgReportDeviceInfo::create(temp);
(*itSource)->getDeviceOutputMessageQueue()->push(report);
}
// send to sink buddies
const std::vector<DeviceSinkAPI*>& sinkBuddies = m_deviceAPI->getSinkBuddies();
std::vector<DeviceSinkAPI*>::const_iterator itSink = sinkBuddies.begin();
for (; itSink != sinkBuddies.end(); ++itSink)
{
MsgReportDeviceInfo *report = MsgReportDeviceInfo::create(temp);
(*itSink)->getDeviceOutputMessageQueue()->push(report);
}
}
}
else
{
return false;

View File

@ -86,6 +86,21 @@ public:
{ }
};
class MsgGetDeviceInfo : public Message {
MESSAGE_CLASS_DECLARATION
public:
static MsgGetDeviceInfo* create()
{
return new MsgGetDeviceInfo();
}
private:
MsgGetDeviceInfo() :
Message()
{ }
};
class MsgReportLimeSDRToGUI : public Message {
MESSAGE_CLASS_DECLARATION
@ -193,6 +208,26 @@ public:
{ }
};
class MsgReportDeviceInfo : public Message {
MESSAGE_CLASS_DECLARATION
public:
float getTemperature() const { return m_temperature; }
static MsgReportDeviceInfo* create(float temperature)
{
return new MsgReportDeviceInfo(temperature);
}
private:
float m_temperature;
MsgReportDeviceInfo(float temperature) :
Message(),
m_temperature(temperature)
{ }
};
LimeSDRInput(DeviceSourceAPI *deviceAPI);
virtual ~LimeSDRInput();

View File

@ -36,7 +36,8 @@ LimeSDRInputGUI::LimeSDRInputGUI(DeviceSourceAPI *deviceAPI, QWidget* parent) :
m_sampleRate(0),
m_lastEngineState((DSPDeviceSourceEngine::State)-1),
m_doApplySettings(true),
m_statusCounter(0)
m_statusCounter(0),
m_deviceStatusCounter(0)
{
m_limeSDRInput = new LimeSDRInput(m_deviceAPI);
m_sampleSource = (DeviceSampleSource *) m_limeSDRInput;
@ -235,6 +236,11 @@ void LimeSDRInputGUI::handleMessagesToGUI()
ui->streamStatusLabel->setStyleSheet("QLabel { background:rgb(79,79,79); }");
}
}
else if (LimeSDRInput::MsgReportDeviceInfo::match(*message))
{
LimeSDRInput::MsgReportDeviceInfo *report = (LimeSDRInput::MsgReportDeviceInfo *) message;
ui->temperatureText->setText(tr("%1C").arg(QString::number(report->getTemperature(), 'f', 0)));
}
}
}
@ -335,6 +341,17 @@ void LimeSDRInputGUI::updateStatus()
m_sampleSource->getInputMessageQueue()->push(message);
m_statusCounter = 0;
}
if (m_deviceStatusCounter < 10)
{
m_deviceStatusCounter++;
}
else
{
LimeSDRInput::MsgGetDeviceInfo* message = LimeSDRInput::MsgGetDeviceInfo::create();
m_sampleSource->getInputMessageQueue()->push(message);
m_deviceStatusCounter = 0;
}
}
void LimeSDRInputGUI::blockApplySettings(bool block)

View File

@ -62,6 +62,7 @@ private:
int m_lastEngineState;
bool m_doApplySettings;
int m_statusCounter;
int m_deviceStatusCounter;
void displaySettings();
void setNCODisplay();

View File

@ -874,6 +874,32 @@ QToolTip{background-color: white; color: black;}</string>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="temperatureText">
<property name="minimumSize">
<size>
<width>24</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Board temperature (degrees C)</string>
</property>
<property name="text">
<string>00C</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">