Skip to content

Commit

Permalink
expanded basemanager with signal GetSignals
Browse files Browse the repository at this point in the history
  • Loading branch information
Myron Franze authored Jun 18, 2020
1 parent 326327d commit 1c26780
Show file tree
Hide file tree
Showing 10 changed files with 102 additions and 7 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ add_library(${PRJ_NAME}

unit
signal
hal
protocol
managerbase

Expand Down
25 changes: 25 additions & 0 deletions hal.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* SPDX-License-Identifier: GPLv3-or-later */
/* Copyright (c) 2019 Project WomoLIN */
/* Author Myron Franze <[email protected]> */

#include "hal.h"

namespace siguni
{

CHalUnitInputGetSignals::CHalUnitInputGetSignals( const std::map<std::string_view, interface::ISignal*> & attSignalMap )
: signalMap( attSignalMap )
{

}

void CHalUnitInputGetSignals::Get( std::string & attGetInput )
{
attGetInput.clear();
for(const auto & [key, ignored] : signalMap ){
attGetInput.append( key );
attGetInput.append( "," );
}
}

}
25 changes: 25 additions & 0 deletions hal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* SPDX-License-Identifier: GPLv3-or-later */
/* Copyright (c) 2019 Project WomoLIN */
/* Author Myron Franze <[email protected]> */

#pragma once

#include "interface/isignal.h"
#include "interface/iunit.h"

namespace siguni
{

class CHalUnitInputGetSignals : public interface::IUnitInput
{
public:
CHalUnitInputGetSignals( const std::map<std::string_view, interface::ISignal*> & attSignalMap );
~CHalUnitInputGetSignals() = default;

void Get( std::string & attGetInput ) override final;

private:
const std::map<std::string_view, interface::ISignal*> & signalMap;
};

}
8 changes: 8 additions & 0 deletions interface/isignal.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ namespace siguni::interface
virtual void UpdateUnitSignalGetVersion( std::string & attKey, std::string & attVersion ) = 0;
};

class ISignalGetSignals
{
public:
virtual ~ISignalGetSignals() = default;
virtual void UpdateUnitSignalGetSignals( std::string & attKey, std::string & attVersion ) = 0;
};



}

5 changes: 5 additions & 0 deletions managerbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ namespace siguni
CManagerBase::CManagerBase( interface::IControlbus & attControlbus )
: controlbus( attControlbus )
, protocol( controlbus )
, halUnitInputGetSignals( signalVector )
{

signalVector["GetSignals"] = &GetSignals;
GetSignals.AddUnit( &unitInputGetSignals );

}

void CManagerBase::DoWork()
Expand Down
13 changes: 11 additions & 2 deletions managerbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

#pragma once

#include "interface/isignal.h"
#include "unit.h"
#include "hal.h"
#include "signal.h"
#include "protocol.h"

#include <map>
Expand All @@ -23,10 +25,17 @@ namespace siguni
protected:
std::string message;
std::map<std::string_view, interface::ISignal*> signalVector;

private:
interface::IControlbus & controlbus;
CProtocol protocol;

// units
CHalUnitInputGetSignals halUnitInputGetSignals;
CUnitInput unitInputGetSignals{ halUnitInputGetSignals } ;

// signals
CSignalGetSignals GetSignals { CSignalGetSignals() };

};
}
7 changes: 7 additions & 0 deletions signal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ namespace siguni
}
}

void CSignalGetSignals::UpdateUnit( std::string & attKey, std::string & attValue )
{
for( const auto & unit : units ){
unit->UpdateUnitSignalGetSignals( attKey, attValue );
}
}



}
11 changes: 11 additions & 0 deletions signal.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,15 @@ namespace siguni
};


class CSignalGetSignals final
: public CSignalAddUnit<interface::ISignalGetSignals>
, public interface::ISignal
{
public:
CSignalGetSignals() = default;
~CSignalGetSignals() = default;
void UpdateUnit( std::string & attKey, std::string & attValue ) override final;
};


}
9 changes: 5 additions & 4 deletions unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ namespace siguni

CUnitOutput::CUnitOutput( interface::IUnitOutput & attUnitOutput ) : unitOutput( attUnitOutput ) {}

void CUnitInput::UpdateUnitSignalGetSignals( std::string & /*attKey*/, std::string & attValue )
{
unitInput.Get( attValue );
}

void CUnitOutput::UpdateUnitSignalSetReset( std::string & /*attKey*/, std::string & attValue )
{
unitOutput.Set( attValue );
Expand All @@ -30,8 +35,4 @@ namespace siguni
{
unitInput.Get( attValue );
}




}
5 changes: 4 additions & 1 deletion unit.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,17 @@ namespace siguni
};

class CUnitInput
: public interface::ISignalSetReset
: public interface::ISignalGetSignals
, public interface::ISignalSetReset
, public interface::ISignalGetVersion
, public interface::ISignalGetVoltage
{
public:
CUnitInput( interface::IUnitInput & attUnitInput) ;
~CUnitInput() = default;

void UpdateUnitSignalGetSignals( std::string & attKey, std::string & attValue ) override final;

void UpdateUnitSignalSetReset( std::string & attKey, std::string & attValue ) override final;
void UpdateUnitSignalGetVersion( std::string & attKey, std::string & attValue ) override final;
void UpdateUnitSignalGetVoltage( std::string & attKey, std::string & attValue ) override final;
Expand Down

0 comments on commit 1c26780

Please sign in to comment.