@ -157,6 +157,13 @@ RadiosondeGUI::RadiosondeGUI(PluginAPI* pluginAPI, FeatureUISet *featureUISet, F
@@ -157,6 +157,13 @@ RadiosondeGUI::RadiosondeGUI(PluginAPI* pluginAPI, FeatureUISet *featureUISet, F
connect ( getInputMessageQueue ( ) , SIGNAL ( messageEnqueued ( ) ) , this , SLOT ( handleInputMessages ( ) ) ) ;
m_sondeHub = SondeHub : : create ( ) ;
if ( m_sondeHub )
{
connect ( m_sondeHub , & SondeHub : : prediction , this , & RadiosondeGUI : : handlePrediction ) ;
connect ( & m_predicitionTimer , & QTimer : : timeout , this , & RadiosondeGUI : : requestPredictions ) ;
m_predicitionTimer . setInterval ( 60 * 1000 ) ;
m_predicitionTimer . setSingleShot ( false ) ;
}
// Initialise chart
ui - > chart - > setRenderHint ( QPainter : : Antialiasing ) ;
@ -190,6 +197,8 @@ RadiosondeGUI::RadiosondeGUI(PluginAPI* pluginAPI, FeatureUISet *featureUISet, F
@@ -190,6 +197,8 @@ RadiosondeGUI::RadiosondeGUI(PluginAPI* pluginAPI, FeatureUISet *featureUISet, F
// Get updated when position changes
connect ( & MainCore : : instance ( ) - > getSettings ( ) , & MainSettings : : preferenceChanged , this , & RadiosondeGUI : : preferenceChanged ) ;
connect ( & m_positionUpdateTimer , & QTimer : : timeout , this , & RadiosondeGUI : : updatePosition ) ;
m_positionUpdateTimer . setSingleShot ( true ) ;
ui - > radiosondes - > setItemDelegateForColumn ( RADIOSONDE_COL_LATITUDE , new DecimalDelegate ( 5 , ui - > radiosondes ) ) ;
ui - > radiosondes - > setItemDelegateForColumn ( RADIOSONDE_COL_LONGITUDE , new DecimalDelegate ( 5 , ui - > radiosondes ) ) ;
@ -255,12 +264,14 @@ void RadiosondeGUI::displaySettings()
@@ -255,12 +264,14 @@ void RadiosondeGUI::displaySettings()
ui - > y2 - > setCurrentIndex ( ( int ) m_settings . m_y2 ) ;
ui - > feed - > setChecked ( m_settings . m_feedEnabled ) ;
ui - > showPredictedPaths - > setChecked ( m_settings . m_showPredictedPaths ) ;
getRollupContents ( ) - > restoreState ( m_rollupState ) ;
blockApplySettings ( false ) ;
getRollupContents ( ) - > arrangeRollups ( ) ;
updatePosition ( ) ;
applyShowPredictedPaths ( ) ;
}
void RadiosondeGUI : : onMenuDialogCalled ( const QPoint & p )
@ -671,6 +682,10 @@ void RadiosondeGUI::updateRadiosondes(RS41Frame *message, QDateTime dateTime)
@@ -671,6 +682,10 @@ void RadiosondeGUI::updateRadiosondes(RS41Frame *message, QDateTime dateTime)
MainCore : : instance ( ) - > getSettings ( ) . getAltitude ( )
) ;
}
if ( ! found ) {
requestPredictions ( ) ;
}
}
void RadiosondeGUI : : on_radiosondes_itemSelectionChanged ( )
@ -906,16 +921,38 @@ void RadiosondeGUI::on_deleteAll_clicked()
@@ -906,16 +921,38 @@ void RadiosondeGUI::on_deleteAll_clicked()
{
QString serial = ui - > radiosondes - > item ( row , RADIOSONDE_COL_SERIAL ) - > text ( ) ;
// Remove from map
sendToMap ( serial , " " ,
" " , " " ,
" " , 0.0f ,
0.0f , 0.0f , 0.0f , QDateTime ( ) ,
0.0f ) ;
clearFromMapFeature ( serial , 0 ) ;
// Remove from table
ui - > radiosondes - > removeRow ( row ) ;
// Remove from hash and free memory
delete m_radiosondes . take ( serial ) ;
}
deletePredictedPaths ( ) ;
}
void RadiosondeGUI : : deletePredictedPaths ( )
{
for ( const auto & prediction : m_predictions ) {
clearFromMapFeature ( prediction , 3 ) ;
}
m_predictions . clear ( ) ;
}
void RadiosondeGUI : : clearFromMapFeature ( const QString & name , int type )
{
QList < ObjectPipe * > mapPipes ;
MainCore : : instance ( ) - > getMessagePipes ( ) . getMessagePipes ( m_radiosonde , " mapitems " , mapPipes ) ;
for ( const auto & pipe : mapPipes )
{
MessageQueue * messageQueue = qobject_cast < MessageQueue * > ( pipe - > m_element ) ;
SWGSDRangel : : SWGMapItem * swgMapItem = new SWGSDRangel : : SWGMapItem ( ) ;
swgMapItem - > setName ( new QString ( name ) ) ;
swgMapItem - > setImage ( new QString ( " " ) ) ;
swgMapItem - > setType ( type ) ;
MainCore : : MsgMapItem * msg = MainCore : : MsgMapItem : : create ( m_radiosonde , swgMapItem ) ;
messageQueue - > push ( msg ) ;
}
}
void RadiosondeGUI : : makeUIConnections ( )
@ -926,6 +963,7 @@ void RadiosondeGUI::makeUIConnections()
@@ -926,6 +963,7 @@ void RadiosondeGUI::makeUIConnections()
QObject : : connect ( ui - > y2 , qOverload < int > ( & QComboBox : : currentIndexChanged ) , this , & RadiosondeGUI : : on_y2_currentIndexChanged ) ;
QObject : : connect ( ui - > deleteAll , & QPushButton : : clicked , this , & RadiosondeGUI : : on_deleteAll_clicked ) ;
QObject : : connect ( ui - > feed , & ButtonSwitch : : clicked , this , & RadiosondeGUI : : on_feed_clicked ) ;
QObject : : connect ( ui - > showPredictedPaths , & ButtonSwitch : : clicked , this , & RadiosondeGUI : : on_showPredictedPaths_clicked ) ;
}
void RadiosondeGUI : : on_feed_clicked ( bool checked )
@ -954,6 +992,28 @@ void RadiosondeGUI::feedSelect(const QPoint& p)
@@ -954,6 +992,28 @@ void RadiosondeGUI::feedSelect(const QPoint& p)
}
}
void RadiosondeGUI : : on_showPredictedPaths_clicked ( bool checked )
{
m_settings . m_showPredictedPaths = checked ;
m_settingsKeys . append ( " showPredictedPaths " ) ;
applySettings ( ) ;
applyShowPredictedPaths ( ) ;
}
void RadiosondeGUI : : applyShowPredictedPaths ( )
{
if ( m_settings . m_showPredictedPaths )
{
requestPredictions ( ) ;
m_predicitionTimer . start ( ) ;
}
else
{
m_predicitionTimer . stop ( ) ;
deletePredictedPaths ( ) ;
}
}
// Get names of devices with radiosonde demods, for SondeHub Radio string
QStringList RadiosondeGUI : : getRadios ( )
{
@ -963,7 +1023,7 @@ QStringList RadiosondeGUI::getRadios()
@@ -963,7 +1023,7 @@ QStringList RadiosondeGUI::getRadios()
for ( const auto & channel : channels )
{
DeviceAPI * device = mainCore - > getDevice ( channel . m_i ndex ) ;
DeviceAPI * device = mainCore - > getDevice ( channel . m_superI ndex ) ;
if ( device )
{
QString name = device - > getHardwareId ( ) ;
@ -979,22 +1039,106 @@ QStringList RadiosondeGUI::getRadios()
@@ -979,22 +1039,106 @@ QStringList RadiosondeGUI::getRadios()
void RadiosondeGUI : : updatePosition ( )
{
// Limit number of position updates sent to SondeHub
const int updateTime = m_settings . m_mobile ? m_minMobilePositionUpdateTime : m_minFixedPositionUpdateTime ;
if ( m_sondeHub & & m_settings . m_displayPosition )
{
float stationLatitude = MainCore : : instance ( ) - > getSettings ( ) . getLatitude ( ) ;
float stationLongitude = MainCore : : instance ( ) - > getSettings ( ) . getLongitude ( ) ;
float stationAltitude = MainCore : : instance ( ) - > getSettings ( ) . getAltitude ( ) ;
m_sondeHub - > updatePosition (
m_settings . m_callsign ,
stationLatitude ,
stationLongitude ,
stationAltitude ,
getRadios ( ) . join ( " " ) ,
m_settings . m_antenna ,
m_settings . m_email ,
m_settings . m_mobile
) ;
if ( ! m_lastPositionUpdate . isValid ( ) | | ( m_lastPositionUpdate . secsTo ( QDateTime : : currentDateTime ( ) ) > = updateTime ) )
{
float stationLatitude = MainCore : : instance ( ) - > getSettings ( ) . getLatitude ( ) ;
float stationLongitude = MainCore : : instance ( ) - > getSettings ( ) . getLongitude ( ) ;
float stationAltitude = MainCore : : instance ( ) - > getSettings ( ) . getAltitude ( ) ;
m_sondeHub - > updatePosition (
m_settings . m_callsign ,
stationLatitude ,
stationLongitude ,
stationAltitude ,
getRadios ( ) . join ( " " ) ,
m_settings . m_antenna ,
m_settings . m_email ,
m_settings . m_mobile
) ;
m_positionUpdateTimer . stop ( ) ;
m_lastPositionUpdate = QDateTime : : currentDateTime ( ) ;
}
else
{
qint64 msecs = ( updateTime * 1000 ) - m_lastPositionUpdate . msecsTo ( QDateTime : : currentDateTime ( ) ) ;
if ( msecs < 0 ) {
msecs = 0 ;
}
m_positionUpdateTimer . setInterval ( msecs ) ;
m_positionUpdateTimer . start ( ) ;
}
}
}
void RadiosondeGUI : : requestPredictions ( )
{
if ( m_sondeHub & & m_settings . m_showPredictedPaths )
{
for ( int row = 0 ; row < ui - > radiosondes - > rowCount ( ) ; row + + )
{
QString serial = ui - > radiosondes - > item ( row , RADIOSONDE_COL_SERIAL ) - > text ( ) ;
m_sondeHub - > getPrediction ( serial ) ;
}
}
}
void RadiosondeGUI : : handlePrediction ( const QString & serial , const QList < SondeHub : : Position > & positions )
{
if ( positions . size ( ) < 2 ) {
return ;
}
// Send to Map feature
QList < ObjectPipe * > mapPipes ;
MainCore : : instance ( ) - > getMessagePipes ( ) . getMessagePipes ( m_radiosonde , " mapitems " , mapPipes ) ;
if ( mapPipes . size ( ) > 0 )
{
QString name = QString ( " %1_prediction " ) . arg ( serial ) ;
for ( const auto & pipe : mapPipes )
{
MessageQueue * messageQueue = qobject_cast < MessageQueue * > ( pipe - > m_element ) ;
SWGSDRangel : : SWGMapItem * swgMapItem = new SWGSDRangel : : SWGMapItem ( ) ;
swgMapItem - > setName ( new QString ( name ) ) ;
swgMapItem - > setLatitude ( positions [ 0 ] . m_latitude ) ;
swgMapItem - > setLongitude ( positions [ 0 ] . m_longitude ) ;
swgMapItem - > setAltitude ( positions [ 0 ] . m_altitude ) ;
QString image = QString ( " none " ) ;
swgMapItem - > setImage ( new QString ( image ) ) ;
swgMapItem - > setImageRotation ( 0 ) ;
swgMapItem - > setFixedPosition ( true ) ;
swgMapItem - > setLabel ( new QString ( serial ) ) ;
swgMapItem - > setAltitudeReference ( 0 ) ;
QList < SWGSDRangel : : SWGMapCoordinate * > * coords = new QList < SWGSDRangel : : SWGMapCoordinate * > ( ) ;
for ( const auto & position : positions )
{
SWGSDRangel : : SWGMapCoordinate * c = new SWGSDRangel : : SWGMapCoordinate ( ) ;
c - > setLatitude ( position . m_latitude ) ;
c - > setLongitude ( position . m_longitude ) ;
c - > setAltitude ( position . m_altitude ) ;
coords - > append ( c ) ;
}
swgMapItem - > setCoordinates ( coords ) ;
swgMapItem - > setType ( 3 ) ;
MainCore : : MsgMapItem * msg = MainCore : : MsgMapItem : : create ( m_radiosonde , swgMapItem ) ;
messageQueue - > push ( msg ) ;
if ( ! m_predictions . contains ( name ) ) {
m_predictions . append ( name ) ;
}
}
}
}