Skip to content

Commit

Permalink
Merge branch 'fltdyn-master'
Browse files Browse the repository at this point in the history
(upstream) Resolve MinGW namespace clash, improve jansfunc and add convert units
  • Loading branch information
alwinw committed Apr 8, 2023
2 parents b7b794c + b07c471 commit 26c0180
Show file tree
Hide file tree
Showing 22 changed files with 1,167 additions and 183 deletions.
10 changes: 5 additions & 5 deletions Janus/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ add_library(Janus STATIC
${CMAKE_CURRENT_SOURCE_DIR}/PropertyDef.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Provenance.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Reference.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Signal.cpp
${CMAKE_CURRENT_SOURCE_DIR}/SignalDef.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Signals.cpp
${CMAKE_CURRENT_SOURCE_DIR}/SignalList.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Sgnl.cpp
${CMAKE_CURRENT_SOURCE_DIR}/SgnlDef.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Sgnls.cpp
${CMAKE_CURRENT_SOURCE_DIR}/SgnlList.cpp
${CMAKE_CURRENT_SOURCE_DIR}/SolveMathML.cpp
${CMAKE_CURRENT_SOURCE_DIR}/StatespaceFn.cpp
${CMAKE_CURRENT_SOURCE_DIR}/StaticShot.cpp
Expand Down Expand Up @@ -157,7 +157,7 @@ endif()

if (MSVC)
set_target_properties(Janus PROPERTIES COMPILE_FLAGS "/bigobj")
elseif (MINGW)
elseif (WIN32)
set_target_properties(Janus PROPERTIES COMPILE_FLAGS "-Wa,-mbig-obj")
endif()

Expand Down
4 changes: 2 additions & 2 deletions Janus/CheckSignal.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
*/

// Local Includes
#include <Janus/SignalList.h>
#include <Janus/Signals.h>
#include <Janus/SgnlList.h>
#include <Janus/Sgnls.h>
#include "XmlElementDefinition.h"

namespace janus
Expand Down
13 changes: 13 additions & 0 deletions Janus/Janus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,19 @@ bool Janus::propertyExists( const dstoute::aString& ptyID)

//------------------------------------------------------------------------//

const BreakpointDef& Janus::getBreakpointDef( const aString& bpId) const
{
for ( const auto& bp : breakpointDef_) {
if ( bp.getBpID() == bpId) return bp;
}
throw_message( std::range_error,
setFunctionName( "Janus::getBreakpointDef()")
<< "\n - Can't find bpID \"" << bpId << "\"."
);
}

//------------------------------------------------------------------------//

SignalDef& Janus::getSignalDef( const aString& sigID)
{
for ( size_t i = 0; i < signalDef_.size(); ++i) {
Expand Down
5 changes: 4 additions & 1 deletion Janus/Janus.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
#include "GriddedTableDef.h"
#include "UngriddedTableDef.h"
#include "Function.h"
#include "SignalDef.h"
#include "SgnlDef.h"
#include "CheckData.h"
#include "Author.h"
#include "Reference.h"
Expand Down Expand Up @@ -718,6 +718,9 @@ namespace janus {
* \return A reference to the list of BreakpointDef instances is returned.
*/
BreakpointDefList& getBreakpointDef() { return breakpointDef_;}
const BreakpointDefList& getBreakpointDef() const { return breakpointDef_;}

const BreakpointDef& getBreakpointDef( const dstoute::aString& bpId) const;

/**
* Within the DOM, a \em griddedTableDef contains points arranged in an
Expand Down
6 changes: 3 additions & 3 deletions Janus/JanusConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#define JANUS_VERSION_HEX "0x020300"
#define JANUS_VERSION_SHORT "2.3.0"
#define JANUS_VERSION_LONG "Janus-2.3.0"
#define JANUS_REVISION "2.3.0.1568"
#define JANUS_REVISION_COUNT 1568
#define JANUS_REVISION_INFO "6688b7c8baf9bea367fed2e78150df7221ae9dd3"
#define JANUS_REVISION "2.3.0.1594"
#define JANUS_REVISION_COUNT 1594
#define JANUS_REVISION_INFO "95cfbbd1403822ea0af5acfda0cf59cdbd873e03"
#endif /* _JANUS_CONFIG_H_ */
33 changes: 33 additions & 0 deletions Janus/JanusVariable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
*/

// C++ Includes
#include <cassert>
#include <iostream>
#include <sstream>
#include <cassert>
Expand Down Expand Up @@ -157,6 +158,38 @@ JanusVariable::JanusVariable( const aString &variableName, JanusVariableType var
requiredValue_ = findUnits( specificUnits);
}

set<aString> JanusVariable::getAllDependencies() const
{
assert( janusFile_);
if ( !janusFile_ || !variableDef_) return {};

set<aOptionalSizeT> workingIndices = { janusFile_->getVariableIndex( variableDef_->getVarID())};
set<aOptionalSizeT> outputIndices;

while ( !workingIndices.empty()) {
const aOptionalSizeT tIndex = *workingIndices.begin();
if ( tIndex.isValid()) {
outputIndices.insert( tIndex);
const vector<size_t>& tIndvarIndices = janusFile_->getVariableDef( tIndex).getIndependentVarRef();
for ( size_t i : tIndvarIndices) {
if ( outputIndices.find( i) == outputIndices.end()) {
workingIndices.insert( i);
}
}
}
workingIndices.erase( tIndex);
}

workingIndices.erase( janusFile_->getVariableIndex( variableDef_->getVarID())); // Remove this

set<aString> indvars;
for ( size_t i : outputIndices) {
indvars.insert( janusFile_->getVariableDef( i).getVarID());
}

return indvars;
}

void JanusVariable::setJanusFile( janus::Janus *janusFile)
{
if ( janusFile_ != janusFile) {
Expand Down
4 changes: 4 additions & 0 deletions Janus/JanusVariable.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
#include <Ute/aUnits.h>
#include <Ute/aOptional.h>

#include <set>

// ----------------
// Class Definition
// ----------------
Expand Down Expand Up @@ -155,6 +157,8 @@ class JanusVariable
bool isStateDeriv() const { return isAvailable() ? variableDef_->isStateDeriv() : false;}
bool isStdAIAA() const { return isAvailable() ? variableDef_->isStdAIAA() : false;}

std::set<dstoute::aString> getAllDependencies() const;

friend class JanusVariableManager;

protected:
Expand Down
2 changes: 1 addition & 1 deletion Janus/Signal.cpp → Janus/Sgnl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
//------------------------------------------------------------------------//

/**
* \file Signal.cpp
* \file Sgnl.cpp
*
* A Signal instance holds in its allocated memory alphanumeric data
* derived from a \em signal element of a DOM corresponding to
Expand Down
4 changes: 2 additions & 2 deletions Janus/SignalDef.cpp → Janus/SgnlDef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
//------------------------------------------------------------------------//

/**
* \file SignalDef.cpp
* \file SgnlDef.cpp
*
* A SignalDef instance holds in its allocated memory alphanumeric data
* derived from a \em signalDef element of a DOM corresponding to
Expand Down Expand Up @@ -72,7 +72,7 @@
// Local Includes
#include "JanusConstants.h"
#include "DomFunctions.h"
#include "SignalDef.h"
#include "SgnlDef.h"

using namespace std;
using namespace dstoute;
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions Janus/SignalList.cpp → Janus/SgnlList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
//------------------------------------------------------------------------//
// Title: Janus/SignalList
// Class: SignalList
// Module: SignalList.cpp
// Module: SgnlList.cpp
// First Date: 2017-09-06
// Reference: Janus Reference Manual
//------------------------------------------------------------------------//
Expand All @@ -53,7 +53,7 @@
*/

// Ute Includes
#include <Janus/SignalList.h>
#include <Janus/SgnlList.h>
#include <Ute/aMessageStream.h>
#include <Ute/aOptional.h>

Expand Down
4 changes: 2 additions & 2 deletions Janus/SignalList.h → Janus/SgnlList.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
//------------------------------------------------------------------------//

/**
* \file SignalList.h
* \file SgnlList.h
*
* A SignalList instance behaves as a container for a list of Signal definition
* elements (either signalDef or signalRef), which provide the properties of
Expand All @@ -61,7 +61,7 @@

// Local Includes
#include "XmlElementDefinition.h"
#include "SignalDef.h"
#include "SgnlDef.h"

namespace janus {

Expand Down
4 changes: 2 additions & 2 deletions Janus/Signals.cpp → Janus/Sgnls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
//------------------------------------------------------------------------//
// Title: Janus/Signals
// Class: Signals
// Module: Signals.cpp
// Module: Sgnls.cpp
// First Date: 2011-11-04
// Reference: Janus Reference Manual
//------------------------------------------------------------------------//
Expand Down Expand Up @@ -63,7 +63,7 @@
*/

// Ute Includes
#include <Janus/Signals.h>
#include <Janus/Sgnls.h>
#include <Ute/aMessageStream.h>

#include "DomFunctions.h"
Expand Down
2 changes: 1 addition & 1 deletion Janus/Signals.h → Janus/Sgnls.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
//------------------------------------------------------------------------//

/**
* \file Signals.h
* \file Sgnls.h
*
* A Signals instance functions as a container for the Signal class, and
* provides the functions that allow a calling StaticShot instance to access
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pip install python-janus

## Resources

- DST Group Janus website: <https://www.dst.defence.gov.au/opportunity/janus-dynamic-aerospace-vehicle-exchange-mark-language-dave-ml-c-interpreter>
- DST Group Janus website: <https://www.dst.defence.gov.au/our-technologies/janus-dynamic-aerospace-vehicle-exchange-mark-language-dave-ml-c-interpreter>

- DAVE-ML website: <http://daveml.org/intro.html>

Expand Down
64 changes: 29 additions & 35 deletions SFunction/JanusSFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

using namespace std;

//#define DEBUG_PRINT( ...) printf( __VA_ARGS__)
// #define DEBUG_PRINT( ...) printf( __VA_ARGS__)
#define DEBUG_PRINT( ...)

template<typename _Kty, class _Pr = std::less<_Kty>, class _Alloc = std::allocator<_Kty>>
Expand Down Expand Up @@ -78,9 +78,9 @@ static void mdlInitializeSizes( SimStruct* S)
ssSetNumSFcnParams( S, PARAM_COUNT);
if ( ssGetNumSFcnParams( S) != ssGetSFcnParamsCount( S)) return;

ssSetSFcnParamTunable( S, PARAM_XML_FILENAME, 0);
ssSetSFcnParamTunable( S, PARAM_INDVARS, 0);
ssSetSFcnParamTunable( S, PARAM_DEPVARS, 0);
ssSetSFcnParamTunable( S, PARAM_XML_FILENAME, SS_PRM_NOT_TUNABLE);
ssSetSFcnParamTunable( S, PARAM_INDVARS, SS_PRM_NOT_TUNABLE);
ssSetSFcnParamTunable( S, PARAM_DEPVARS, SS_PRM_NOT_TUNABLE);

ssSetNumContStates( S, 0);
ssSetNumDiscStates( S, 0);
Expand All @@ -104,7 +104,7 @@ static void mdlInitializeSizes( SimStruct* S)
// Get number of dependent variables
const mxArray* depvarArray = ssGetSFcnParam( S, PARAM_DEPVARS);
if ( mxGetClassID( depvarArray) != mxCHAR_CLASS) {
ssSetErrorStatus( S, "Dependent varIDs must be a string array.");
// ssSetErrorStatus( S, "Dependent varIDs must be a string array.");
return;
}
const int nDepVars = mxGetM( depvarArray);
Expand All @@ -121,17 +121,23 @@ static void mdlInitializeSizes( SimStruct* S)
ssSetNumNonsampledZCs( S, 0);

ssSetOptions( S, 0);
/*ssSetOptions( S, SS_OPTION_USE_TLC_WITH_ACCELERATOR | SS_OPTION_WORKS_WITH_CODE_REUSE);
ssSetSupportedForCodeReuseAcrossModels( S, 1);*/
}

static void mdlInitializeSampleTimes( SimStruct* S)
{
ssSetSampleTime( S, 0, CONTINUOUS_SAMPLE_TIME);
ssSetSampleTime( S, 0, INHERITED_SAMPLE_TIME);
ssSetOffsetTime( S, 0, 0.0);

ssSetModelReferenceSampleTimeInheritanceRule( S, INHERITED_SAMPLE_TIME);
}

#define MDL_START
static void mdlStart( SimStruct* S)
{
if ( ssGetNumOutputPorts( S) == 0) return;

ssGetPWork(S)[JANUS] = new janus::Janus;
janus::Janus* janus = static_cast<janus::Janus*>( ssGetPWork(S)[JANUS]);

Expand All @@ -152,7 +158,7 @@ static void mdlStart( SimStruct* S)
status = mxGetString( filenameArray, filename, filenameLength);
DEBUG_PRINT( "filename: %s\n", filename);
if ( status) {
ssSetErrorStatus( S, "XML filename could not be read");
// ssSetErrorStatus( S, "XML filename could not be read");
return;
}

Expand Down Expand Up @@ -181,21 +187,15 @@ static void mdlStart( SimStruct* S)
}
n = mxGetN( indvarArray);
for ( int var = 0; var < nIndVars; ++var) {
for ( int i = 0; i < n; ++i) {
int iof = var + nIndVars * i;
int len = -1;
if ( indVarBuf[iof] == ' ') len = i + 1;
if ( i + 1 == n) len = i + 2;
if ( len != -1) {
indVarIDs[var] = static_cast<char*>( calloc( len, sizeof( char)));
indVarIDs[var][len-1] = '\0';
for ( int k = 0; k < len - 1; ++k) {
indVarIDs[var][k] = indVarBuf[var + nIndVars * k];
}
DEBUG_PRINT( "indVarIDs[%d]: %s\n", var, indVarIDs[var]);
break;
}
indVarIDs[var] = static_cast<char*>( calloc( n + 1, sizeof( char)));
int i = 0;
for ( ; i < n; ++i) {
if ( indVarBuf[var + nIndVars * i] == ' ') break;
indVarIDs[var][i] = indVarBuf[var + nIndVars * i];
}
DEBUG_PRINT( "%d\t", i);
indVarIDs[var][i] = '\0';
DEBUG_PRINT( "indVarIDs[%d]: %s\n", var, indVarIDs[var]);
}
ssSetPWorkValue( S, INDVARIDS, indVarIDs);
free( indVarBuf);
Expand Down Expand Up @@ -253,21 +253,15 @@ static void mdlStart( SimStruct* S)
}
n = mxGetN( depvarArray);
for ( int var = 0; var < nDepVars; ++var) {
for ( int i = 0; i < n; ++i) {
int iof = var + nDepVars * i;
int len = -1;
if ( depVarBuf[iof] == ' ') len = i + 1;
if ( i + 1 == n) len = i + 2;
if ( len != -1) {
depVarIDs[var] = static_cast<char*>( calloc( len, sizeof( char)));
depVarIDs[var][len-1] = '\0';
for ( int k = 0; k < len - 1; ++k) {
depVarIDs[var][k] = depVarBuf[var + nDepVars * k];
}
DEBUG_PRINT( "depVarIDs[%d]: %s\n", var, depVarIDs[var]);
break;
}
depVarIDs[var] = static_cast<char*>( calloc( n + 1, sizeof( char)));
int i = 0;
for ( ; i < n; ++i) {
if ( depVarBuf[var + nDepVars * i] == ' ') break;
depVarIDs[var][i] = depVarBuf[var + nDepVars * i];
}
DEBUG_PRINT( "%d\t", i);
depVarIDs[var][i] = '\0';
DEBUG_PRINT( "depVarIDs[%d]: %s\n", var, depVarIDs[var]);
}
ssSetPWorkValue( S, DEPVARIDS, depVarIDs);
free( depVarBuf);
Expand Down
Loading

0 comments on commit 26c0180

Please sign in to comment.