Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
157 changes: 157 additions & 0 deletions ActivityDiagramLib/ActivityDiagram/ActivityDiagramAction.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
#ifndef ACTIVITYDIAGRAMACTION_HPP_INCLUDED
#define ACTIVITYDIAGRAMACTION_HPP_INCLUDED

#include <iostream>
#include "ComponentEssentials.h"
#include "ComponentUtilities.h"
#include "math.h"

//!
//! @file ActivityDiagramAction.hpp
//! @author Petter Krus <petter.krus@liu.se>
// co-author/auditor **Not yet audited by a second person**
//! @date Thu 17 Oct 2019 16:57:08
//! @brief State
//! @ingroup ActivityDiagramComponents
//!
//==This code has been autogenerated using Compgen==
//from
/*{, C:, Users, petkr14, Dropbox, HopsanComponents, StateMachine0, \
ActivityDiagram, ActivityDiagram}/ActivityDiagramAction.nb*/

using namespace hopsan;

class ActivityDiagramAction : public ComponentC
{
private:
Port *mpPpn1;
Port *mpPpn2;
int mNstep;
//Port Ppn1 variable
double spn1;
double qpn1;
//Port Ppn2 variable
double spn2;
double qpn2;
//==This code has been autogenerated using Compgen==
//inputVariables
//outputVariables
double state;
//InitialExpressions variables
double stated;
//Expressions variables
//Port Ppn1 pointer
double *mpP_spn1;
double *mpP_qpn1;
//Port Ppn2 pointer
double *mpP_spn2;
double *mpP_qpn2;
//Delay declarations
//==This code has been autogenerated using Compgen==
//inputVariables pointers
//inputParameters pointers
//outputVariables pointers
double *mpstate;
EquationSystemSolver *mpSolver;

public:
static Component *Creator()
{
return new ActivityDiagramAction();
}

void configure()
{
//==This code has been autogenerated using Compgen==

mNstep=9;

//Add ports to the component
mpPpn1=addPowerPort("Ppn1","NodePetriNet");
mpPpn2=addPowerPort("Ppn2","NodePetriNet");
//Add inputVariables to the component

//Add inputParammeters to the component
//Add outputVariables to the component
addOutputVariable("state","State","",0.,&mpstate);

//==This code has been autogenerated using Compgen==
//Add constantParameters
}

void initialize()
{
//Read port variable pointers from nodes
//Port Ppn1
mpP_spn1=getSafeNodeDataPtr(mpPpn1, NodePetriNet::State);
mpP_qpn1=getSafeNodeDataPtr(mpPpn1, NodePetriNet::Flow);
//Port Ppn2
mpP_spn2=getSafeNodeDataPtr(mpPpn2, NodePetriNet::State);
mpP_qpn2=getSafeNodeDataPtr(mpPpn2, NodePetriNet::Flow);

//Read variables from nodes
//Port Ppn1
spn1 = (*mpP_spn1);
qpn1 = (*mpP_qpn1);
//Port Ppn2
spn2 = (*mpP_spn2);
qpn2 = (*mpP_qpn2);

//Read inputVariables from nodes

//Read inputParameters from nodes

//Read outputVariables from nodes
state = (*mpstate);

//==This code has been autogenerated using Compgen==
//InitialExpressions
stated = state;


//Initialize delays


simulateOneTimestep();

}
void simulateOneTimestep()
{
//Read variables from nodes
//Port Ppn1
qpn1 = (*mpP_qpn1);
//Port Ppn2
qpn2 = (*mpP_qpn2);

//Read inputVariables from nodes

//Read inputParameters from nodes

//LocalExpressions

//Expressions
state = onPositive(-0.5 + qpn1 + qpn2 + stated);
spn1 = state;
spn2 = state;
stated = state;

//Calculate the delayed parts


//Write new values to nodes
//Port Ppn1
(*mpP_spn1)=spn1;
//Port Ppn2
(*mpP_spn2)=spn2;
//outputVariables
(*mpstate)=state;

//Update the delayed variabels

}
void deconfigure()
{
delete mpSolver;
}
};
#endif // ACTIVITYDIAGRAMACTION_HPP_INCLUDED
Loading