Skip to content

Commit

Permalink
Revolution pi (eclipse-4diac#27)
Browse files Browse the repository at this point in the history
Add Kunbus Revolution PI IO support to 4diac FORTE

This PR is based on this original contribution https://git.eclipse.org/r/c/4diac/org.eclipse.4diac.forte/+/153699

It has been updated to the latest Knubus Revolution PI io libraries and to the latest 4diac FORTE FB and IO API

Inclusion of third party content approved:
https://gitlab.eclipse.org/eclipsefdn/emo-team/iplab/-/issues/13374

---------
Also-by: Johannes Meßmer
Also-by: Jose Cabral <[email protected]>
Also-by: Alois Zoitl <[email protected]>
  • Loading branch information
moniwe authored Mar 6, 2024
1 parent 04f3f0e commit 4e7c9db
Show file tree
Hide file tree
Showing 20 changed files with 2,830 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/modules/revolutionPi/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#*******************************************************************************
# * Copyright (c) 2017, 2024 fortiss GmbH, Monika Wenger, Johannes Kepler University Linz
# *
# * All rights reserved. This program and the accompanying materials
# * are made available under the terms of the Eclipse Public License v2.0
# * which accompanies this distribution, and is available at
# * http://www.eclipse.org/legal/epl-v20.html
# *
# * Contributors:
# * Johannes Messmer
# * - initial API and implementation and/or initial documentation
# * Monika Wenger, Alois Zoitl
# * - migration to current runtime
# *******************************************************************************/

forte_add_io(REVOLUTIONPI "Support for Revolution Pi")

if(FORTE_IO_REVOLUTIONPI)
set(FORTE_IO ON CACHE BOOL "Enable IO Modules" FORCE)
message("Set FORTE_IO")
forte_add_include_directories(${CMAKE_CURRENT_SOURCE_DIR})

forte_add_sourcefile_hc( lib/piControlIf )

forte_add_sourcefile_hcpp( RevPiController )
forte_add_sourcefile_hcpp( RevPiHandle )

forte_add_sourcefile_hcpp( fb/IORevPiCore )
forte_add_sourcefile_hcpp( fb/IORevPiBusAdapter )
forte_add_sourcefile_hcpp( fb/IORevPiDIO )
forte_add_sourcefile_hcpp( fb/IORevPiAIO )
endif(FORTE_IO_REVOLUTIONPI)
61 changes: 61 additions & 0 deletions src/modules/revolutionPi/RevPiConfig.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*******************************************************************************
* Copyright (c) 2017, 2024 fortiss GmbH, Monika Wenger, Johannes Kepler University Linz
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* Johannes Messmer - initial API and implementation and/or initial documentation
* Monika Wenger, Alois Zoitl - migration to current runtime
*******************************************************************************/

#include "RevPiConfig.h"
#ifdef FORTE_ENABLE_GENERATED_SOURCE_CPP
#include "RevPiConfig_gen.cpp"
#endif

#include "RevPiController.h"

using namespace forte::core::io;

DEFINE_FIRMWARE_FB(RevPiConfig, g_nStringIdIORevPi)

const CStringDictionary::TStringId RevPiConfig::scm_anDataInputNames[] = {g_nStringIdQI, g_nStringIdDigitalInput_1, g_nStringIdDigitalInput_2, g_nStringIdDigitalInput_3, g_nStringIdDigitalInput_4, g_nStringIdDigitalInput_5, g_nStringIdDigitalInput_6, g_nStringIdDigitalInput_7, g_nStringIdDigitalInput_8, g_nStringIdDigitalInput_9, g_nStringIdDigitalInput_10, g_nStringIdDigitalInput_11, g_nStringIdDigitalInput_12, g_nStringIdDigitalInput_13, g_nStringIdDigitalInput_14, g_nStringIdDigitalOutput_1, g_nStringIdDigitalOutput_2, g_nStringIdDigitalOutput_3, g_nStringIdDigitalOutput_4, g_nStringIdDigitalOutput_5, g_nStringIdDigitalOutput_6, g_nStringIdDigitalOutput_7, g_nStringIdDigitalOutput_8, g_nStringIdDigitalOutput_9, g_nStringIdDigitalOutput_10, g_nStringIdDigitalOutput_11, g_nStringIdDigitalOutput_12, g_nStringIdDigitalOutput_13, g_nStringIdDigitalOutput_14, g_nStringIdUpdateInterval};

const CStringDictionary::TStringId RevPiConfig::scm_anDataInputTypeIds[] = {g_nStringIdBOOL, g_nStringIdWSTRING, g_nStringIdWSTRING, g_nStringIdWSTRING, g_nStringIdWSTRING, g_nStringIdWSTRING, g_nStringIdWSTRING, g_nStringIdWSTRING, g_nStringIdWSTRING, g_nStringIdWSTRING, g_nStringIdWSTRING, g_nStringIdWSTRING, g_nStringIdWSTRING, g_nStringIdWSTRING, g_nStringIdWSTRING, g_nStringIdWSTRING, g_nStringIdWSTRING, g_nStringIdWSTRING, g_nStringIdWSTRING, g_nStringIdWSTRING, g_nStringIdWSTRING, g_nStringIdWSTRING, g_nStringIdWSTRING, g_nStringIdWSTRING, g_nStringIdWSTRING, g_nStringIdWSTRING, g_nStringIdWSTRING, g_nStringIdWSTRING, g_nStringIdWSTRING, g_nStringIdUINT};

const CStringDictionary::TStringId RevPiConfig::scm_anDataOutputNames[] = {g_nStringIdQO, g_nStringIdSTATUS};

const CStringDictionary::TStringId RevPiConfig::scm_anDataOutputTypeIds[] = {g_nStringIdBOOL, g_nStringIdWSTRING};

const TForteInt16 RevPiConfig::scm_anEIWithIndexes[] = {0};
const TDataIOID RevPiConfig::scm_anEIWith[] = {0, 29, 1, 2, 3, 4, 5, 6, 9, 8, 7, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 255};
const CStringDictionary::TStringId RevPiConfig::scm_anEventInputNames[] = {g_nStringIdINIT};

const TDataIOID RevPiConfig::scm_anEOWith[] = {0, 1, 255, 0, 1, 255};
const TForteInt16 RevPiConfig::scm_anEOWithIndexes[] = {0, 3, -1};
const CStringDictionary::TStringId RevPiConfig::scm_anEventOutputNames[] = {g_nStringIdINITO, g_nStringIdIND};

const SFBInterfaceSpec RevPiConfig::scm_stFBInterfaceSpec = {
1, scm_anEventInputNames, scm_anEIWith, scm_anEIWithIndexes,
2, scm_anEventOutputNames, scm_anEOWith, scm_anEOWithIndexes, 30, scm_anDataInputNames, scm_anDataInputTypeIds,
2, scm_anDataOutputNames, scm_anDataOutputTypeIds,
0, 0
};


void RevPiConfig::setInitialValues(){
UpdateInterval() = 25;
}

void RevPiConfig::setConfig(){
RevPiController::Config config;
config.updateInterval = UpdateInterval();
controller->setConfig(&config);
}

IODeviceController* RevPiConfig::createDeviceController(CDeviceExecution& paDeviceExecution){
return new RevPiController(paDeviceExecution);
}
186 changes: 186 additions & 0 deletions src/modules/revolutionPi/RevPiConfig.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
/*******************************************************************************
* Copyright (c) 2017, 2024 fortiss GmbH, Monika Wenger, Johannes Kepler University Linz
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* Johannes Messmer - initial API and implementation and/or initial documentation
* Monika Wenger, Alois Zoitl - migration to current runtime
*******************************************************************************/

#pragma once

#include <funcbloc.h>
#include <forte_bool.h>
#include <forte_uint.h>
#include <forte_wstring.h>

#include <io/configFB/io_configFB_controller.h>

class RevPiConfig: public forte::core::io::IOConfigFBController{
DECLARE_FIRMWARE_FB(RevPiConfig)

private:
static const CStringDictionary::TStringId scm_anDataInputNames[];
static const CStringDictionary::TStringId scm_anDataInputTypeIds[];
CIEC_BOOL &QI() {
return *static_cast<CIEC_BOOL*>(getDI(0));
};

CIEC_WSTRING &DigitalInput_1() {
return *static_cast<CIEC_WSTRING*>(getDI(1));
};

CIEC_WSTRING &DigitalInput_2() {
return *static_cast<CIEC_WSTRING*>(getDI(2));
};

CIEC_WSTRING &DigitalInput_3() {
return *static_cast<CIEC_WSTRING*>(getDI(3));
};

CIEC_WSTRING &DigitalInput_4() {
return *static_cast<CIEC_WSTRING*>(getDI(4));
};

CIEC_WSTRING &DigitalInput_5() {
return *static_cast<CIEC_WSTRING*>(getDI(5));
};

CIEC_WSTRING &DigitalInput_6() {
return *static_cast<CIEC_WSTRING*>(getDI(6));
};

CIEC_WSTRING &DigitalInput_7() {
return *static_cast<CIEC_WSTRING*>(getDI(7));
};

CIEC_WSTRING &DigitalInput_8() {
return *static_cast<CIEC_WSTRING*>(getDI(8));
};

CIEC_WSTRING &DigitalInput_9() {
return *static_cast<CIEC_WSTRING*>(getDI(9));
};

CIEC_WSTRING &DigitalInput_10() {
return *static_cast<CIEC_WSTRING*>(getDI(10));
};

CIEC_WSTRING &DigitalInput_11() {
return *static_cast<CIEC_WSTRING*>(getDI(11));
};

CIEC_WSTRING &DigitalInput_12() {
return *static_cast<CIEC_WSTRING*>(getDI(12));
};

CIEC_WSTRING &DigitalInput_13() {
return *static_cast<CIEC_WSTRING*>(getDI(13));
};

CIEC_WSTRING &DigitalInput_14() {
return *static_cast<CIEC_WSTRING*>(getDI(14));
};

CIEC_WSTRING &DigitalOutput_1() {
return *static_cast<CIEC_WSTRING*>(getDI(15));
};

CIEC_WSTRING &DigitalOutput_2() {
return *static_cast<CIEC_WSTRING*>(getDI(16));
};

CIEC_WSTRING &DigitalOutput_3() {
return *static_cast<CIEC_WSTRING*>(getDI(17));
};

CIEC_WSTRING &DigitalOutput_4() {
return *static_cast<CIEC_WSTRING*>(getDI(18));
};

CIEC_WSTRING &DigitalOutput_5() {
return *static_cast<CIEC_WSTRING*>(getDI(19));
};

CIEC_WSTRING &DigitalOutput_6() {
return *static_cast<CIEC_WSTRING*>(getDI(20));
};

CIEC_WSTRING &DigitalOutput_7() {
return *static_cast<CIEC_WSTRING*>(getDI(21));
};

CIEC_WSTRING &DigitalOutput_8() {
return *static_cast<CIEC_WSTRING*>(getDI(22));
};

CIEC_WSTRING &DigitalOutput_9() {
return *static_cast<CIEC_WSTRING*>(getDI(23));
};

CIEC_WSTRING &DigitalOutput_10() {
return *static_cast<CIEC_WSTRING*>(getDI(24));
};

CIEC_WSTRING &DigitalOutput_11() {
return *static_cast<CIEC_WSTRING*>(getDI(25));
};

CIEC_WSTRING &DigitalOutput_12() {
return *static_cast<CIEC_WSTRING*>(getDI(26));
};

CIEC_WSTRING &DigitalOutput_13() {
return *static_cast<CIEC_WSTRING*>(getDI(27));
};

CIEC_WSTRING &DigitalOutput_14() {
return *static_cast<CIEC_WSTRING*>(getDI(28));
};

CIEC_UINT &UpdateInterval() {
return *static_cast<CIEC_UINT*>(getDI(29));
};

static const CStringDictionary::TStringId scm_anDataOutputNames[];
static const CStringDictionary::TStringId scm_anDataOutputTypeIds[];
CIEC_BOOL &QO() {
return *static_cast<CIEC_BOOL*>(getDO(0));
};

CIEC_WSTRING &STATUS() {
return *static_cast<CIEC_WSTRING*>(getDO(1));
};

static const TEventID scm_nEventINITID = 0;
static const TForteInt16 scm_anEIWithIndexes[];
static const TDataIOID scm_anEIWith[];
static const CStringDictionary::TStringId scm_anEventInputNames[];

static const TEventID scm_nEventINITOID = 0;
static const TEventID scm_nEventINDID = 1;
static const TForteInt16 scm_anEOWithIndexes[];
static const TDataIOID scm_anEOWith[];
static const CStringDictionary::TStringId scm_anEventOutputNames[];

static const SFBInterfaceSpec scm_stFBInterfaceSpec;

FORTE_FB_DATA_ARRAY(2, 30, 2, 0);

virtual void setInitialValues();

public:
FUNCTION_BLOCK_CTOR_WITH_BASE_CLASS(RevPiConfig, forte::core::io::IOConfigFBController){
};

virtual ~RevPiConfig(){};

protected:
forte::core::io::IODeviceController* createDeviceController(CDeviceExecution& paDeviceExecution);
void setConfig ();

};
Loading

0 comments on commit 4e7c9db

Please sign in to comment.