- Joined
- Mar 30, 2008
- Messages
- 450
- Reaction score
- 1
- Points
- 18
Hi all,
It’s been a while, due to real life responsibilities, but I’m back, and am starting to get into coding my own vessels. I’m specifically interested in extending the ability of OrbConnect to my vessel in the same manner that it has been extended to XR vessels, so that I can command certain aspects of my vessel via OrbConnect and one day build a simpit.
As a very simple example to get my feet wet, I tried to add into OrbConnect a “ShuttleA API” similar to the XR Control API written by Doug, with two functions: one to extend the landing gear, and another to retract it. Like the “XCTL” prefix which is used for using OrbConnect with an XR vessel, I would extend and retract the landing gear in ship SH-01 by entering into the OrbConnect JAVA client, respectively:
SHA:SH-01:EXTENDLANDINGGEAR
SHA:SH-01:RETRACTLANDINGGEAR
Please forgive my copy paste approach, as I'm no expert C++ programmer. If there'a a better way to do this, I'm certainly open to that.
Starting with the source code available at [ame="http://orbithangar.com/searchid.php?ID=5824"]Orb:Connect v2.1 Project files[/ame], I downloaded, extracted, compiled source code, copied over to Orbiter, and verified functionality (so I know what I’m starting with is working). I did have to make one change: line 347, I changed the end from string.npos to string::npos (not sure why my compiler didn’t like the former).
I then made the following additions to the OrbConnect code base, basing off of the XR Control code, in an attempt to create a very basic “ShuttleA Control API” that only has two functions: one to raise the landing gear, and another to retract it.
Changes to OrbConnect.cpp:
1. Added to line 53:
2. Added into the parseCommandID function, around line 90:
3. Added into parseCommand function, around line 150:
Changes to OrbConnect.h:
1. Added to the top, around line 13:
2. Added the initialization of shaCtrlParser around line 63:
Then I created three new files (again based off of the XR Control API):
File ShuttleAVesselCtrl.h:
File ShuttleACtlCommandParser.h:
File: ShuttleACtlCommandParser.cpp
Here I'm assuming that a SHA:___ command will always be sent when the vessel of focus is a ShuttleA, so no need to check to make sure the vessel in focus is a ShuttleA (I don't think).
I then compiled OrbConnect successfully, and transferred the module over to Orbiter\Modules\Plugin, and activated it. The first problem is that I’m unable to send commands via the client; sending command “SHA:SH-15:RETRACTLANDINGGEAR” in the "ISS Approach" scenario caused Orbiter to crash.
The second issue is more bizarre: the very first time I transfer the newly compiled .dll into the Modules\Plugin folder, the client loads successfully with Orbiter running. All subsequent times I try to open the JAVA client while Orbiter is running, it immediately causes Orbiter to freeze, and the only way to get the client to load again with Orbiter running is to deactivate OrbConnect from the Modules tab in the Launchpad, delete the .dll file from the Modules\Plugin folder, re-copy a fresh copy over, then go into the Modules tab in the Launchpad and reactivate it.
If there's anybody who would be able to point me in the right direction here that would be great!
It’s been a while, due to real life responsibilities, but I’m back, and am starting to get into coding my own vessels. I’m specifically interested in extending the ability of OrbConnect to my vessel in the same manner that it has been extended to XR vessels, so that I can command certain aspects of my vessel via OrbConnect and one day build a simpit.
As a very simple example to get my feet wet, I tried to add into OrbConnect a “ShuttleA API” similar to the XR Control API written by Doug, with two functions: one to extend the landing gear, and another to retract it. Like the “XCTL” prefix which is used for using OrbConnect with an XR vessel, I would extend and retract the landing gear in ship SH-01 by entering into the OrbConnect JAVA client, respectively:
SHA:SH-01:EXTENDLANDINGGEAR
SHA:SH-01:RETRACTLANDINGGEAR
Please forgive my copy paste approach, as I'm no expert C++ programmer. If there'a a better way to do this, I'm certainly open to that.
Starting with the source code available at [ame="http://orbithangar.com/searchid.php?ID=5824"]Orb:Connect v2.1 Project files[/ame], I downloaded, extracted, compiled source code, copied over to Orbiter, and verified functionality (so I know what I’m starting with is working). I did have to make one change: line 347, I changed the end from string.npos to string::npos (not sure why my compiler didn’t like the former).
I then made the following additions to the OrbConnect code base, basing off of the XR Control code, in an attempt to create a very basic “ShuttleA Control API” that only has two functions: one to raise the landing gear, and another to retract it.
Changes to OrbConnect.cpp:
1. Added to line 53:
Code:
ShuttleACtlCommandParser shaCtrlParser; // ShuttleA Addition
Code:
else if ("SHA" == area) // Begin ShuttleA Addition
{
SendText(lParam, IDstring, shaCtrlParser.parse(lParam, Command));
} // End ShuttleA Addition
Code:
else if ("SHA" == area) // Begin ShuttleA Addition
{
SendText(lParam, Command, shaCtrlParser.parse(lParam, Command));
} // End ShuttleA Addition
Changes to OrbConnect.h:
1. Added to the top, around line 13:
Code:
#include "ShuttleACtlCommandParser.h"
Code:
extern ShuttleACtlCommandParser shaCtrlParser; // ShuttleA Addition
Then I created three new files (again based off of the XR Control API):
File ShuttleAVesselCtrl.h:
Code:
//ShuttleAVesselCtrl.h
#pragma once
#include "orbitersdk.h"
class ShuttleAVesselCtrl : public VESSEL3
{
public:
// Constructor
ShuttleAVesselCtrl(OBJHANDLE vessel, int fmodel) : VESSEL3(vessel, fmodel) { }
// Pure virtual functions to retract the landing gear
virtual void RevertLandingGear() = 0;
};
File ShuttleACtlCommandParser.h:
Code:
// File ShuttleACtlCommandParser.h
#ifndef _SHUTTLEACTL_COMMAND_PARSER_H
#define _SHUTTLEACTL_COMMAND_PARSER_H
#define VSEXPRESS 1
#include "VesselCommandParser.h"
#include "ShuttleAVesselCtrl.h"
using namespace std;
class ShuttleACtlCommandParser : public VesselCommandParser
{
public:
string parse(long lparam, string command);
};
string StowLandingGear(ShuttleAVesselCtrl * pVessel);
#endif
File: ShuttleACtlCommandParser.cpp
Here I'm assuming that a SHA:___ command will always be sent when the vessel of focus is a ShuttleA, so no need to check to make sure the vessel in focus is a ShuttleA (I don't think).
Code:
// File: ShuttleACtlCommandParser.cpp
#include "ShuttleACtlCommandParser.h"
string ShuttleACtlCommandParser::parse(long lParam, string command) {
string message = "ERR02";
bool found = false;
VESSEL2* pVessel = 0;
ShuttleAVesselCtrl* pShuttleAVessel;
vector<string> tokens = stringSplit(command, ":");
message = loadVessel(&pVessel, tokens);
if (0 == pVessel) {
return "ERR05";
}
pShuttleAVessel = (ShuttleAVesselCtrl*)pVessel;
if (0 == pShuttleAVessel) {
return "ERR07";
}
string cmd = uCase(tokens.at(2));
if ("RETRACTLANDINGGEAR" == cmd)
{
message = StowLandingGear(pShuttleAVessel);
}
else
{
message = "ERR99";
}
return message;
}
string StowLandingGear(ShuttleAVesselCtrl *pVessel) {
pVessel->RevertLandingGear(); // Function RevertLandingGear is defined in ShuttleA.cpp
return "OK";
}
I then compiled OrbConnect successfully, and transferred the module over to Orbiter\Modules\Plugin, and activated it. The first problem is that I’m unable to send commands via the client; sending command “SHA:SH-15:RETRACTLANDINGGEAR” in the "ISS Approach" scenario caused Orbiter to crash.
The second issue is more bizarre: the very first time I transfer the newly compiled .dll into the Modules\Plugin folder, the client loads successfully with Orbiter running. All subsequent times I try to open the JAVA client while Orbiter is running, it immediately causes Orbiter to freeze, and the only way to get the client to load again with Orbiter running is to deactivate OrbConnect from the Modules tab in the Launchpad, delete the .dll file from the Modules\Plugin folder, re-copy a fresh copy over, then go into the Modules tab in the Launchpad and reactivate it.
If there's anybody who would be able to point me in the right direction here that would be great!
Last edited: