diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..dfda141 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,76 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, sex characteristics, gender identity and expression, +level of experience, education, socio-economic status, nationality, personal +appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at pablo.edronkin@yahoo.com. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see +https://www.contributor-covenant.org/faq diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..21753d0 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,30 @@ +# SQLC - Guidelines for contributors. + + +## Overview: + +Thanks for reading these guidelines; nothing fancy or complicated here, so +please take your time to review the info listed below. + + +## Read first: + +* /~https://github.com/PESchoenberg/SQLC/blob/master/README.md + +* /~https://github.com/PESchoenberg/SQLC/blob/master/CODE_OF_CONDUCT.md + + +## Conventions: + +* Try to be brief and to the point regarding your requests and proposals. + +* Write clear and orderly code while respecting the general coding style of the +project. + +* You need to have a verified signature. See +https://help.github.com/articles/managing-commit-signature-verification/ + +* Nothing is written in stone. New guidelines might come into effect at any +time. Review the docs from time to time to keep up. + + diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..f6dff97 --- /dev/null +++ b/COPYING @@ -0,0 +1,9 @@ +This work is based on the Orbiter Space Flight Simulator and derived code by Dr. Martin Schweiger et al. Hence, all developments and expansions made by myself on these files are based on the work of the aforementioned authors and the applicable terms of use, copyright ownership and licenses applicable to this work are those established by the authors of the original code. + +- Please visit http://orbit.medphys.ucl.ac.uk/ for more info on Orbiter and its terms of use. + +- Email me at pablo.edronkin(at)yahoo.com for questions and comments. + + +Pablo Edronkin + diff --git a/README.md b/README.md new file mode 100644 index 0000000..4f5ba85 --- /dev/null +++ b/README.md @@ -0,0 +1,67 @@ +# SQLC - Multi function display for the DGIIIAI Delta Glider. + + + + +## Overview: + +SQLC is an MFD specfically designed to interact with the onboard expert system +that runs the DGIIIAI Delta Glider for Orbiter Space Flight Simulator. + + +## Dependencies: + +* Orbiter Space Flight Simulator 2010 (OSFS) or newer +- http://orbit.medphys.ucl.ac.uk/ + +* MS Visual Studio 2010 or higher with OpenMP compatibility. + +* Sqlite3 - https://www.sqlite.org/index.html + +* DGIIIAI - /~https://github.com/PESchoenberg/DGIIIAI.git + + +## Installation: + +* Backup your original Orbiter installation or install a new one before +installation. + +* Carefully review the contents of the compressed file of this project +in order to see what will be copied. + +* Make sure that you already have installed DGIIIAI + +* Copy the contents of \orbiter folder into your Orbiter simulator main folder. + + +## Uninstall: + +* You will have to manually remove the files provided. Therefore it is +advisable that you install this project on a development installation of +Orbiter instead of you main one. + + +## Usage: + +* Enable this MFD as any other standard MFD or dll for OSFS. + +* Load one of the provided scenarios. The ship will soon start acting on its +own. + + +## Credits and Sources: + +* Dr. Martin Schweiger, for OSFS. + +* Credits for the original DGIII and MFD template files are kept as in the +original versions. + +* Please notify me in case that I have missed some credits. + + + +## License: + +* Please read the contents of file COPYING for license info. + + diff --git a/orbiter/databases/SQLC/SQLC b/orbiter/databases/SQLC/SQLC new file mode 100644 index 0000000..69dcaf2 Binary files /dev/null and b/orbiter/databases/SQLC/SQLC differ diff --git a/orbiter/orbitersdk/samples/SQLC/Debug/SQLC.dll b/orbiter/orbitersdk/samples/SQLC/Debug/SQLC.dll new file mode 100644 index 0000000..0f77ef7 Binary files /dev/null and b/orbiter/orbitersdk/samples/SQLC/Debug/SQLC.dll differ diff --git a/orbiter/orbitersdk/samples/SQLC/SQLC/mfdparams.h b/orbiter/orbitersdk/samples/SQLC/SQLC/mfdparams.h new file mode 100644 index 0000000..1561575 --- /dev/null +++ b/orbiter/orbitersdk/samples/SQLC/SQLC/mfdparams.h @@ -0,0 +1,9 @@ +#ifndef __MFDPARAMS_H +#define __MFDPARAMS_H + +//MFD API params + +const int NUM_BUTTONS = 11; +//const int MAX_NUMBER_OF_PAGES=55; + +#endif // !__MFDPARAMS_H \ No newline at end of file diff --git a/orbiter/orbitersdk/samples/SQLC/SQLC/sqlc.cpp b/orbiter/orbitersdk/samples/SQLC/SQLC/sqlc.cpp new file mode 100644 index 0000000..150c90d --- /dev/null +++ b/orbiter/orbitersdk/samples/SQLC/SQLC/sqlc.cpp @@ -0,0 +1,607 @@ +// ============================================================== +// ORBITER MODULE: DialogTemplate +// Part of the ORBITER SDK +// Copyright (C) 2003-2016 Martin Schweiger +// All rights reserved +// +// SQLC.cpp +// +// This module demonstrates how to build an Orbiter plugin which +// inserts a new MFD (multi-functional display) mode. The code +// is not very useful in itself, but it can be used as a starting +// point for your own MFD developments. +// ============================================================== +// SQL Console +// Pablo Edronkin, 2017 +// +// sqlc.cpp +// +// ============================================================== + +#define STRICT +#define ORBITER_MODULE +#include "windows.h" +#include "orbitersdk.h" +#include "sqlc.h" + +// ============================================================== +// Global variables. + +// Identifier for new MFD mode. +int g_MFDmode; + +// ============================================================== +// API interface. + +DLLCLBK void InitModule (HINSTANCE hDLL) +{ + static char *name = "SQL Console"; // MFD mode name. + MFDMODESPECEX spec; + spec.name = name; + //spec.key = OAPI_KEY_T; // MFD mode selection key. + spec.key = OAPI_KEY_Q; + spec.context = NULL; + spec.msgproc = SQLC::MsgProc; // MFD mode callback function. + + // Register the new MFD mode with Orbiter. + g_MFDmode = oapiRegisterMFDMode (spec); +} + +DLLCLBK void ExitModule (HINSTANCE hDLL) +{ + // Unregister the custom MFD mode when the module is unloaded. + oapiUnregisterMFDMode (g_MFDmode); +} + +// ============================================================== +// SQLC Outside MFD class stuff. +// ============================================================== + +//Vectors required to process sqlite query results. +std::vector sql_results(0); + +/** +Looks into a database file and brings results via the sql_results vector. +*/ +static int sql_send_resq(void *data, int argc, char **argv, char **azColName) +{ + for(int i=0; iSetFont (font); + skp->SetTextAlign (oapi::Sketchpad::CENTER, oapi::Sketchpad::BASELINE); + skp->SetTextColor (0x00FFFF); + //skp->Text (W/2, H/2,"Display area", 12); + //skp->Rectangle (W/4, H/4, (3*W)/4, (3*H)/4); + + // Add MFD display routines here. + // Use the device context (hDC) for Windows GDI paint functions. + + skp->Text(1,1,sobject.c_str(),sobject.length()); + + return true; +} + +/** +MFD message parser. +*/ +int SQLC::MsgProc (UINT msg, UINT mfd, WPARAM wparam, LPARAM lparam) +{ + switch (msg) + { + case OAPI_MSG_MFD_OPENED: + // Our new MFD mode has been selected, so we create the MFD and return a pointer to it. + return (int)(new SQLC (LOWORD(wparam), HIWORD(wparam), (VESSEL*)lparam)); + } + + return 0; +} + +/** +Required for user data input using oapiOpenInputBox (see the Orbiter SDK API for details on this particular +aspect of this function); enters the name of the selected database. +*/ +bool SQLC::DBSetInput (char *rstr) +{ + bool result; + + std::string user_input=rstr; + if (user_input.length()>0) + { + result=true; + if (user_input == "DGIIIAI2") + { + database_to_open="C:\\sources\\orbiter1\\Databases\\DGIIIAI\\DGIIIAI.db"; + } + else if (user_input == "SQLC") + { + database_to_open="C:\\sources\\orbiter1\\Databases\\SQLC\\SQLC.db"; + } + sobject=user_input; + } + else + { + result=false; + database_to_open="SQLC"; + sobject=default_sobject; + } + return result; +}; + +/** +Required for user data input using oapiOpenInputBox (see the Orbiter SDK API for details on this particular +aspect of this function); enters the name of the selected database. +*/ +bool SQLC::SQLSetInput (char *rstr) +{ + bool result; + + std::string user_input=rstr; + if (user_input.length()>0) + { + result=true; + command_status=true; + sql_sentence=user_input; + } + else + { + result=false; + command_status=false; + sql_sentence=" "; + } + return result; +}; + +/** +Required for user data input using oapiOpenInputBox (see the Orbiter SDK API for details on this particular +aspect of this function); enters a mode to set on. +*/ +bool SQLC::ModeOnSetInput (char *rstr) +{ + bool result; + + std::string user_input=rstr; + if (user_input.length()>0) + { + result=true; + command_status=true; + sql_sentence="UPDATE sde_facts SET Value=1 WHERE Item='mode_"+user_input+"'"; + } + else + { + result=false; + command_status=false; + sql_sentence=" "; + } + return result; +}; + +/** +Required for user data input using oapiOpenInputBox (see the Orbiter SDK API for details on this particular +aspect of this function); enters a mode to set off. +*/ +bool SQLC::ModeOffSetInput (char *rstr) +{ + bool result; + + std::string user_input=rstr; + if (user_input.length()>0) + { + result=true; + command_status=true; + sql_sentence="UPDATE sde_facts SET Value=0 WHERE Item='mode_"+user_input+"'"; + } + else + { + result=false; + command_status=false; + sql_sentence=" "; + } + return result; +}; + +///////////////////////////////////////////////////////// + +/** +Required for user data input using oapiOpenInputBox (see the Orbiter SDK API for details on this particular +aspect of this function); enters a program to set on. +*/ +bool SQLC::PrgOnSetInput (char *rstr) +{ + bool result; + + std::string user_input=rstr; + if (user_input.length()>0) + { + result=true; + command_status=true; + sql_sentence="UPDATE sde_facts SET Value="+user_input+" WHERE Item='submode_prg_load'"; + } + else + { + result=false; + command_status=false; + sql_sentence=" "; + } + return result; +}; + +/** +Required for user data input using oapiOpenInputBox (see the Orbiter SDK API for details on this particular +aspect of this function); enters a program to set off. +*/ +bool SQLC::PrgOffSetInput (char *rstr) +{ + bool result; + + std::string user_input=rstr; + if (user_input.length()>0) + { + result=true; + command_status=true; + sql_sentence="UPDATE sde_facts SET Value="+user_input+" WHERE Item='submode_prg_end'"; + } + else + { + result=false; + command_status=false; + sql_sentence=" "; + } + return result; +}; + +///////////////////////////////////////////////////////// + +/** +Required for user data input using oapiOpenInputBox (see the Orbiter SDK API for details on this particular +aspect of this function); enters the Item field of an sde file. +*/ +bool SQLC::ItemSetInput (char *rstr) +{ + bool result; + + std::string user_input=rstr; + if (user_input.length()>0) + { + result=true; + //command_status=true; + command_status=false; + sitem=user_input; + sql_sentence="UPDATE sde_facts SET Value="+svalue+" WHERE Item='"+sitem+"'"; + } + else + { + result=false; + command_status=false; + sitem=default_sitem; + sql_sentence=" "; + } + return result; +}; + +/** +Required for user data input using oapiOpenInputBox (see the Orbiter SDK API for details on this particular +aspect of this function); enters the Value field of an sde file. +*/ +bool SQLC::ValueSetInput (char *rstr) +{ + bool result; + + std::string user_input=rstr; + if ( (user_input.length()>0) && (svalue.length()>0) ) + { + result=true; + command_status=true; + svalue=user_input; + sql_sentence="UPDATE sde_facts SET Value="+svalue+" WHERE Item='"+sitem+"'"; + } + else + { + result=false; + command_status=false; + svalue=default_svalue; + sql_sentence=" "; + } + return result; +}; + +/** +Callback function required for user data input using oapiOpenInputBox (see the Orbiter SDK API for details +on this particular aspect of this function). Selects database. +*/ +bool DBInput (void *id, char *str, void *data) +{ + return ((SQLC*)data)->DBSetInput (str); +}; + +/** +Callback function required for user data input using oapiOpenInputBox (see the Orbiter SDK API for details +on this particular aspect of this function). Enters a SQL instruction. +*/ +bool SQLInput (void *id, char *str, void *data) +{ + return ((SQLC*)data)->SQLSetInput (str); +}; + +/** +Callback function required for user data input using oapiOpenInputBox (see the Orbiter SDK API for details +on this particular aspect of this function). Accepts a mode name to set on. +*/ +bool ModeOnInput (void *id, char *str, void *data) +{ + return ((SQLC*)data)->ModeOnSetInput (str); +}; + +/** +Callback function required for user data input using oapiOpenInputBox (see the Orbiter SDK API for details +on this particular aspect of this function). Accepts a mode name to set off. +*/ +bool ModeOffInput (void *id, char *str, void *data) +{ + return ((SQLC*)data)->ModeOffSetInput (str); +}; + +/////////////////////////////////////////////////////////////// +/** +Callback function required for user data input using oapiOpenInputBox (see the Orbiter SDK API for details +on this particular aspect of this function). Accepts a prg name to set on. +*/ +bool PrgOnInput (void *id, char *str, void *data) +{ + return ((SQLC*)data)->PrgOnSetInput (str); +}; + +/** +Callback function required for user data input using oapiOpenInputBox (see the Orbiter SDK API for details +on this particular aspect of this function). Accepts a prg name to set off. +*/ +bool PrgOffInput (void *id, char *str, void *data) +{ + return ((SQLC*)data)->PrgOffSetInput (str); +}; +/////////////////////////////////////////////////////////////// +/** +Callback function required for user data input using oapiOpenInputBox (see the Orbiter SDK API for details +on this particular aspect of this function). Input field name. +*/ +bool ItemInput (void *id, char *str, void *data) +{ + return ((SQLC*)data)->ItemSetInput (str); +}; + +/** +Callback function required for user data input using oapiOpenInputBox (see the Orbiter SDK API for details +on this particular aspect of this function). Input field name. +*/ +bool ValueInput (void *id, char *str, void *data) +{ + return ((SQLC*)data)->ValueSetInput (str); +}; diff --git a/orbiter/orbitersdk/samples/SQLC/SQLC/sqlc.h b/orbiter/orbitersdk/samples/SQLC/SQLC/sqlc.h new file mode 100644 index 0000000..1b83a7f --- /dev/null +++ b/orbiter/orbitersdk/samples/SQLC/SQLC/sqlc.h @@ -0,0 +1,99 @@ +// ============================================================== +// ORBITER MODULE: DialogTemplate +// Part of the ORBITER SDK +// Copyright (C) 2003 Martin Schweiger +// All rights reserved +// +// SQLC.h +// +// This module demonstrates how to build an Orbiter plugin which +// inserts a new MFD (multi-functional display) mode. The code +// is not very useful in itself, but it can be used as a starting +// point for your own MFD developments. +// ============================================================== +// SQL Console +// Pablo Edronkin, 2017 +// +// sqlc.h +// +// ============================================================== + +#ifndef __SQLC_H +#define __SQLC_H + +#include "stdafx.h" + +class SQLC: public MFD2 +{ + public: + + SQLC (DWORD w, DWORD h, VESSEL *vessel); + + ~SQLC (); + + bool ConsumeKeyBuffered (DWORD key); + + bool ConsumeButton (int bt, int event); + + char *ButtonLabel (int bt); + + int ButtonMenu (const MFDBUTTONMENU **menu) const; + + bool Update (oapi::Sketchpad *skp); + + static int MsgProc (UINT msg, UINT mfd, WPARAM wparam, LPARAM lparam); + + bool DBSetInput (char *rstr); + + bool SQLSetInput (char *rstr); + + bool ModeOnSetInput (char *rstr); + + bool ModeOffSetInput (char *rstr); + + bool PrgOnSetInput (char *rstr); + + bool PrgOffSetInput (char *rstr); + + bool ItemSetInput (char *rstr); + + bool ValueSetInput (char *rstr); + + bool DBInput (void *id, char *str, void *data); + + bool SQLInput (void *id, char *str, void *data); + + bool ModeOnInput (void *id, char *str, void *data); + + bool ModeOffInput (void *id, char *str, void *data); + + bool PrgOnInput (void *id, char *str, void *data); + + bool PrgOffInput (void *id, char *str, void *data); + + bool ItemInput (void *id, char *str, void *data); + + bool ValueInput (void *id, char *str, void *data); + + //SQLC + bool database_status; + bool command_status; + std::string sobject; + std::string sitem; + std::string svalue; + std::string default_sobject; + std::string default_sitem; + std::string default_svalue; + std::string database_to_open; + std::string sql_sentence; + sqlite3 *db; + char *zErrMsg; + int rc; + //int num_bt; + const char* data; + + protected: + oapi::Font *font; +}; + +#endif // !__SQLC_H \ No newline at end of file diff --git a/orbiter/orbitersdk/samples/SQLC/SQLC/stdafx.cpp b/orbiter/orbitersdk/samples/SQLC/SQLC/stdafx.cpp new file mode 100644 index 0000000..0012aa6 --- /dev/null +++ b/orbiter/orbitersdk/samples/SQLC/SQLC/stdafx.cpp @@ -0,0 +1,10 @@ +/* +stdafx.cpp + +For + +SQLC MFD + +*/ + +#include "stdafx.h" diff --git a/orbiter/orbitersdk/samples/SQLC/SQLC/stdafx.h b/orbiter/orbitersdk/samples/SQLC/SQLC/stdafx.h new file mode 100644 index 0000000..e691e89 --- /dev/null +++ b/orbiter/orbitersdk/samples/SQLC/SQLC/stdafx.h @@ -0,0 +1,32 @@ +/* +stdafx.h + +For + +SQLC MFD + +*/ + +#pragma once + +//Standard and basic Orbiter. +#include +#include "orbitersdk.h" +//#include +//#include +// +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +// +#include "mfdparams.h" +