- retrieving home dir and create FsTrack folder
- added adjustable KML update interval - prepared for .kmz git-svn-id: http://moon:8086/svn/software/trunk/projects/FsTrack@125 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
+8
-2
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#define TWO_PWR_16 (65536.0)
|
#define TWO_PWR_16 (65536.0)
|
||||||
#define TWO_PWR_32 (TWO_PWR_16*TWO_PWR_16)
|
#define TWO_PWR_32 (TWO_PWR_16*TWO_PWR_16)
|
||||||
|
#define TIMER_INTEVAL_MS 100
|
||||||
|
|
||||||
const char* FsLink::linkStateString[] = {"Init", "Disconnected", "Connected", "Paused", "Recording"};
|
const char* FsLink::linkStateString[] = {"Init", "Disconnected", "Connected", "Paused", "Recording"};
|
||||||
const char* FsLink::flightStateString[] = {"Init", "Suspend", "Ground", "Take off", "Enroute", "Touch down"};
|
const char* FsLink::flightStateString[] = {"Init", "Suspend", "Ground", "Take off", "Enroute", "Touch down"};
|
||||||
@@ -23,7 +24,7 @@ FsLink::FsLink(const char *pDocRoot)
|
|||||||
, m_kmlUpdateInterval(10)
|
, m_kmlUpdateInterval(10)
|
||||||
, m_kmlUpdateCount(0)
|
, m_kmlUpdateCount(0)
|
||||||
{
|
{
|
||||||
startTimer(100);
|
startTimer(TIMER_INTEVAL_MS);
|
||||||
}
|
}
|
||||||
|
|
||||||
FsLink::FsLink(const FsLink& orig)
|
FsLink::FsLink(const FsLink& orig)
|
||||||
@@ -45,6 +46,11 @@ void FsLink::setKml(IKml *pKml)
|
|||||||
m_pKml = pKml;
|
m_pKml = pKml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FsLink::setUpdateInterval(double seconds)
|
||||||
|
{
|
||||||
|
m_kmlUpdateInterval = (int)(1000*seconds/TIMER_INTEVAL_MS + 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
bool FsLink::open()
|
bool FsLink::open()
|
||||||
{
|
{
|
||||||
unsigned long result;
|
unsigned long result;
|
||||||
@@ -310,7 +316,7 @@ void FsLink::timerCallback()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_pKml->update(m_flightData);
|
m_pKml->update(m_flightData);
|
||||||
m_pKml->export(m_pKml->getPath());
|
m_pKml->exportKml(m_pKml->getPath());
|
||||||
m_kmlUpdateCount = m_kmlUpdateInterval;
|
m_kmlUpdateCount = m_kmlUpdateInterval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ public:
|
|||||||
virtual ~FsLink();
|
virtual ~FsLink();
|
||||||
void addListener(IFsLinkListener *pListener);
|
void addListener(IFsLinkListener *pListener);
|
||||||
void setKml(IKml *pKml);
|
void setKml(IKml *pKml);
|
||||||
|
void setUpdateInterval(double seconds);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ListenerList <IFsLinkListener> m_listeners;
|
ListenerList <IFsLinkListener> m_listeners;
|
||||||
|
|||||||
+13
-7
@@ -1,8 +1,9 @@
|
|||||||
#include "HttpServer.hpp"
|
#include "HttpServer.hpp"
|
||||||
|
|
||||||
|
|
||||||
HttpServer::HttpServer(const char *pDocDir)
|
HttpServer::HttpServer(int port, const char *pDocDir)
|
||||||
: Thread("Http")
|
: Thread("Http")
|
||||||
|
, m_port(port)
|
||||||
, m_docDir(pDocDir)
|
, m_docDir(pDocDir)
|
||||||
{
|
{
|
||||||
startThread();
|
startThread();
|
||||||
@@ -51,16 +52,19 @@ const char* HttpServer::getDocName(char *buffer, int buflen)
|
|||||||
}
|
}
|
||||||
pDocname[i] = 0;
|
pDocname[i] = 0;
|
||||||
|
|
||||||
|
if (i==0)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
return docBuffer;
|
return docBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HttpServer::run()
|
void HttpServer::run()
|
||||||
{
|
{
|
||||||
char buffer[1024];
|
char buffer[1024];
|
||||||
|
char docname[1024];
|
||||||
|
|
||||||
ScopedPointer<StreamingSocket> listenSock = new StreamingSocket();
|
ScopedPointer<StreamingSocket> listenSock = new StreamingSocket();
|
||||||
listenSock->bindToPort(5001);
|
listenSock->createListener(m_port);
|
||||||
listenSock->createListener(5001);
|
|
||||||
|
|
||||||
while(!threadShouldExit())
|
while(!threadShouldExit())
|
||||||
{
|
{
|
||||||
@@ -76,13 +80,15 @@ void HttpServer::run()
|
|||||||
pDoc = getDocName(buffer, numRead);
|
pDoc = getDocName(buffer, numRead);
|
||||||
if (!pDoc)
|
if (!pDoc)
|
||||||
{
|
{
|
||||||
pSock->close();
|
pDoc = docname;
|
||||||
continue;
|
sprintf(docname, "%s\\FsTrack\\welcome.htm", m_docDir);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_listeners.call(&IHttpListener::onUpdate, pDoc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_listeners.call(&IHttpListener::onUpdate, pDoc);
|
|
||||||
|
|
||||||
ScopedPointer<juce::File> file = new juce::File(pDoc);
|
ScopedPointer<juce::File> file = new juce::File(pDoc);
|
||||||
if (!file)
|
if (!file)
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -7,11 +7,12 @@
|
|||||||
class HttpServer : public juce::Thread
|
class HttpServer : public juce::Thread
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
HttpServer(const char *pDocDir);
|
HttpServer(int port, const char *pDocDir);
|
||||||
~HttpServer(void);
|
~HttpServer(void);
|
||||||
void addListener(IHttpListener *pListener);
|
void addListener(IHttpListener *pListener);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
int m_port;
|
||||||
const char *m_docDir;
|
const char *m_docDir;
|
||||||
ListenerList <IHttpListener> m_listeners;
|
ListenerList <IHttpListener> m_listeners;
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -20,7 +20,8 @@ struct IKml
|
|||||||
virtual const char* getPath() = 0;
|
virtual const char* getPath() = 0;
|
||||||
|
|
||||||
virtual void update(FlightData const &flightData) = 0;
|
virtual void update(FlightData const &flightData) = 0;
|
||||||
virtual void export(const char *pPath) = 0;
|
virtual void exportKml(const char *pPath) = 0;
|
||||||
|
virtual void exportKmz(const char *pPath) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* IKML_HPP */
|
#endif /* IKML_HPP */
|
||||||
|
|||||||
+23
-6
@@ -62,13 +62,13 @@ void Kml::destroy()
|
|||||||
|
|
||||||
void Kml::update(FlightData const &flightData)
|
void Kml::update(FlightData const &flightData)
|
||||||
{
|
{
|
||||||
|
const ScopedLock sl (m_lock);
|
||||||
updatePlane(flightData);
|
updatePlane(flightData);
|
||||||
updatePath(flightData);
|
updatePath(flightData);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Kml::updatePlane(FlightData const &flightData)
|
void Kml::updatePlane(FlightData const &flightData)
|
||||||
{
|
{
|
||||||
const ScopedLock sl (m_lock);
|
|
||||||
char temp_str[1024];
|
char temp_str[1024];
|
||||||
|
|
||||||
XmlElement *pDoc = kml->getChildByName("Document");
|
XmlElement *pDoc = kml->getChildByName("Document");
|
||||||
@@ -241,19 +241,36 @@ void Kml::updatePath(FlightData const &flightData)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Kml::export(const char *pPath)
|
void Kml::exportKml(const char *pPath)
|
||||||
{
|
{
|
||||||
|
const ScopedLock sl (m_lock);
|
||||||
|
|
||||||
if (pPath && kml)
|
if (pPath && kml)
|
||||||
{
|
{
|
||||||
const ScopedLock sl (m_lock);
|
|
||||||
|
|
||||||
File file(pPath);
|
File file(pPath);
|
||||||
kml->writeToFile(file, StringRef(""));
|
kml->writeToFile(file, StringRef(""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Kml::onUpdate(const char *pPath)
|
void Kml::exportKmz(const char *pPath)
|
||||||
{
|
{
|
||||||
export(pPath);
|
// ToDo: add Compression if available in Juce
|
||||||
|
const ScopedLock sl (m_lock);
|
||||||
|
|
||||||
|
if (pPath && kml)
|
||||||
|
{
|
||||||
|
File file(pPath);
|
||||||
|
|
||||||
|
file.deleteFile();
|
||||||
|
ScopedPointer<OutputStream> pStream = file.createOutputStream();
|
||||||
|
|
||||||
|
kml->writeToStream(*pStream, StringRef(""));
|
||||||
|
pStream = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Kml::onUpdate(const char *pPath)
|
||||||
|
{
|
||||||
|
exportKmz(pPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -23,7 +23,8 @@ private:
|
|||||||
void destroy();
|
void destroy();
|
||||||
const char* getPath();
|
const char* getPath();
|
||||||
void update(FlightData const &flightData);
|
void update(FlightData const &flightData);
|
||||||
void export(const char *pPath);
|
void exportKml(const char *pPath);
|
||||||
|
void exportKmz(const char *pPath);
|
||||||
void updatePlane(FlightData const &flightData);
|
void updatePlane(FlightData const &flightData);
|
||||||
void updatePath(FlightData const &flightData);
|
void updatePath(FlightData const &flightData);
|
||||||
void onUpdate(const char *pPath);
|
void onUpdate(const char *pPath);
|
||||||
|
|||||||
+7
-2
@@ -7,6 +7,8 @@
|
|||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
*/
|
*/
|
||||||
|
#include <Shlobj.h>
|
||||||
|
#include <Knownfolders.h>
|
||||||
|
|
||||||
#include "../JuceLibraryCode/JuceHeader.h"
|
#include "../JuceLibraryCode/JuceHeader.h"
|
||||||
#include "MainComponent.h"
|
#include "MainComponent.h"
|
||||||
@@ -29,7 +31,6 @@ public:
|
|||||||
(void)commandLine;
|
(void)commandLine;
|
||||||
|
|
||||||
// This method is where you should put your application's initialisation code..
|
// This method is where you should put your application's initialisation code..
|
||||||
|
|
||||||
mainWindow = new MainWindow();
|
mainWindow = new MainWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,7 +69,11 @@ public:
|
|||||||
Colours::lightgrey,
|
Colours::lightgrey,
|
||||||
DocumentWindow::allButtons)
|
DocumentWindow::allButtons)
|
||||||
{
|
{
|
||||||
setContentOwned (new MainComponent(), true);
|
PWSTR path;
|
||||||
|
SHGetKnownFolderPath(FOLDERID_Profile, 0, NULL, &path);
|
||||||
|
|
||||||
|
static String pathStr(path);
|
||||||
|
setContentOwned (new MainComponent(pathStr), true);
|
||||||
|
|
||||||
centreWithSize (getWidth(), getHeight());
|
centreWithSize (getWidth(), getHeight());
|
||||||
setVisible (true);
|
setVisible (true);
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
//[/MiscUserDefs]
|
//[/MiscUserDefs]
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
MainComponent::MainComponent ()
|
MainComponent::MainComponent (String const &homeDir)
|
||||||
{
|
{
|
||||||
addAndMakeVisible (m_fsuipcStatus = new Label ("FSUIP Status",
|
addAndMakeVisible (m_fsuipcStatus = new Label ("FSUIP Status",
|
||||||
TRANS("Unknown")));
|
TRANS("Unknown")));
|
||||||
@@ -45,6 +45,12 @@ MainComponent::MainComponent ()
|
|||||||
m_flightStatus->setColour (TextEditor::textColourId, Colours::black);
|
m_flightStatus->setColour (TextEditor::textColourId, Colours::black);
|
||||||
m_flightStatus->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
|
m_flightStatus->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
|
||||||
|
|
||||||
|
addAndMakeVisible (m_kmlUpdInterval_s = new Slider ("KML Update Interval"));
|
||||||
|
m_kmlUpdInterval_s->setRange (0.1, 10, 0.1);
|
||||||
|
m_kmlUpdInterval_s->setSliderStyle (Slider::LinearHorizontal);
|
||||||
|
m_kmlUpdInterval_s->setTextBoxStyle (Slider::TextBoxLeft, false, 80, 20);
|
||||||
|
m_kmlUpdInterval_s->addListener (this);
|
||||||
|
|
||||||
|
|
||||||
//[UserPreSize]
|
//[UserPreSize]
|
||||||
//[/UserPreSize]
|
//[/UserPreSize]
|
||||||
@@ -53,14 +59,21 @@ MainComponent::MainComponent ()
|
|||||||
|
|
||||||
|
|
||||||
//[Constructor] You can add your own custom stuff here..
|
//[Constructor] You can add your own custom stuff here..
|
||||||
m_kml = new Kml("C:\\Users\\jens");
|
static String workDir(homeDir + String("\\FsTrack"));
|
||||||
|
|
||||||
m_fsLink = new FsLink("C:\\Users\\jens");
|
File file(workDir);
|
||||||
|
file.createDirectory();
|
||||||
|
|
||||||
|
m_kml = new Kml(workDir.getCharPointer());
|
||||||
|
|
||||||
|
m_fsLink = new FsLink(workDir.getCharPointer());
|
||||||
m_fsLink->addListener(this);
|
m_fsLink->addListener(this);
|
||||||
m_fsLink->setKml(m_kml);
|
m_fsLink->setKml(m_kml);
|
||||||
|
|
||||||
m_httpServer = new HttpServer("C:\\Users\\jens");
|
m_httpServer = new HttpServer(5001, workDir.getCharPointer());
|
||||||
m_httpServer->addListener(m_kml);
|
m_httpServer->addListener(m_kml);
|
||||||
|
|
||||||
|
m_kmlUpdInterval_s->setValue(1.0, juce::NotificationType::sendNotification);
|
||||||
//[/Constructor]
|
//[/Constructor]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,6 +84,7 @@ MainComponent::~MainComponent()
|
|||||||
|
|
||||||
m_fsuipcStatus = nullptr;
|
m_fsuipcStatus = nullptr;
|
||||||
m_flightStatus = nullptr;
|
m_flightStatus = nullptr;
|
||||||
|
m_kmlUpdInterval_s = nullptr;
|
||||||
|
|
||||||
|
|
||||||
//[Destructor]. You can add your own custom destruction code here..
|
//[Destructor]. You can add your own custom destruction code here..
|
||||||
@@ -98,10 +112,27 @@ void MainComponent::resized()
|
|||||||
{
|
{
|
||||||
m_fsuipcStatus->setBounds (16, 256, 150, 24);
|
m_fsuipcStatus->setBounds (16, 256, 150, 24);
|
||||||
m_flightStatus->setBounds (216, 256, 150, 24);
|
m_flightStatus->setBounds (216, 256, 150, 24);
|
||||||
|
m_kmlUpdInterval_s->setBounds (16, 216, 184, 24);
|
||||||
//[UserResized] Add your own custom resize handling here..
|
//[UserResized] Add your own custom resize handling here..
|
||||||
//[/UserResized]
|
//[/UserResized]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainComponent::sliderValueChanged (Slider* sliderThatWasMoved)
|
||||||
|
{
|
||||||
|
//[UsersliderValueChanged_Pre]
|
||||||
|
//[/UsersliderValueChanged_Pre]
|
||||||
|
|
||||||
|
if (sliderThatWasMoved == m_kmlUpdInterval_s)
|
||||||
|
{
|
||||||
|
//[UserSliderCode_m_kmlUpdInterval_s] -- add your slider handling code here..
|
||||||
|
m_fsLink->setUpdateInterval(sliderThatWasMoved->getValue());
|
||||||
|
//[/UserSliderCode_m_kmlUpdInterval_s]
|
||||||
|
}
|
||||||
|
|
||||||
|
//[UsersliderValueChanged_Post]
|
||||||
|
//[/UsersliderValueChanged_Post]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//[MiscUserCode] You can add your own definitions of your custom methods or any other code here...
|
//[MiscUserCode] You can add your own definitions of your custom methods or any other code here...
|
||||||
@@ -128,7 +159,7 @@ void MainComponent::onDataChanged(IFsLink &obj)
|
|||||||
BEGIN_JUCER_METADATA
|
BEGIN_JUCER_METADATA
|
||||||
|
|
||||||
<JUCER_COMPONENT documentType="Component" className="MainComponent" componentName=""
|
<JUCER_COMPONENT documentType="Component" className="MainComponent" componentName=""
|
||||||
parentClasses="public Component, public IFsLinkListener" constructorParams=""
|
parentClasses="public Component, public IFsLinkListener" constructorParams="String const &homeDir"
|
||||||
variableInitialisers="" snapPixels="8" snapActive="1" snapShown="1"
|
variableInitialisers="" snapPixels="8" snapActive="1" snapShown="1"
|
||||||
overlayOpacity="0.330" fixedSize="1" initialWidth="400" initialHeight="300">
|
overlayOpacity="0.330" fixedSize="1" initialWidth="400" initialHeight="300">
|
||||||
<BACKGROUND backgroundColour="ffffffff"/>
|
<BACKGROUND backgroundColour="ffffffff"/>
|
||||||
@@ -142,6 +173,10 @@ BEGIN_JUCER_METADATA
|
|||||||
edBkgCol="0" labelText="Unknown" editableSingleClick="0" editableDoubleClick="0"
|
edBkgCol="0" labelText="Unknown" editableSingleClick="0" editableDoubleClick="0"
|
||||||
focusDiscardsChanges="0" fontname="Default font" fontsize="15"
|
focusDiscardsChanges="0" fontname="Default font" fontsize="15"
|
||||||
bold="0" italic="0" justification="33"/>
|
bold="0" italic="0" justification="33"/>
|
||||||
|
<SLIDER name="KML Update Interval" id="c4434642fabdd31c" memberName="m_kmlUpdInterval_s"
|
||||||
|
virtualName="" explicitFocusOrder="0" pos="16 216 184 24" min="0.10000000000000001"
|
||||||
|
max="10" int="0.10000000000000001" style="LinearHorizontal" textBoxPos="TextBoxLeft"
|
||||||
|
textBoxEditable="1" textBoxWidth="80" textBoxHeight="20" skewFactor="1"/>
|
||||||
</JUCER_COMPONENT>
|
</JUCER_COMPONENT>
|
||||||
|
|
||||||
END_JUCER_METADATA
|
END_JUCER_METADATA
|
||||||
|
|||||||
@@ -38,11 +38,12 @@
|
|||||||
//[/Comments]
|
//[/Comments]
|
||||||
*/
|
*/
|
||||||
class MainComponent : public Component,
|
class MainComponent : public Component,
|
||||||
public IFsLinkListener
|
public IFsLinkListener,
|
||||||
|
public SliderListener
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
MainComponent ();
|
MainComponent (String const &homeDir);
|
||||||
~MainComponent();
|
~MainComponent();
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
@@ -51,6 +52,7 @@ public:
|
|||||||
|
|
||||||
void paint (Graphics& g);
|
void paint (Graphics& g);
|
||||||
void resized();
|
void resized();
|
||||||
|
void sliderValueChanged (Slider* sliderThatWasMoved);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -68,6 +70,7 @@ private:
|
|||||||
//==============================================================================
|
//==============================================================================
|
||||||
ScopedPointer<Label> m_fsuipcStatus;
|
ScopedPointer<Label> m_fsuipcStatus;
|
||||||
ScopedPointer<Label> m_flightStatus;
|
ScopedPointer<Label> m_flightStatus;
|
||||||
|
ScopedPointer<Slider> m_kmlUpdInterval_s;
|
||||||
|
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
|||||||
Reference in New Issue
Block a user