Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Som devel 20 #65

Merged
merged 17 commits into from
Oct 13, 2024
Merged
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
40 changes: 40 additions & 0 deletions .gitHooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/bash
# use: git config core.hooksPath .gitHooks

py=$(which py || which python || which python3)
if [[ -z $py ]]; then exit 0; fi
echo "Using python: $py"

cd $(git rev-parse --show-toplevel)
echo current directory: $(pwd)
sompy=$(pwd)/sompy/somutil

for file in `git diff-index --cached --name-only HEAD`;
do
if [[ -f $file ]]
then
add=1
echo checking file: $file
if [[ $file == *.mdj ]]
then
echo cleaning mdj file: $file
$py $sompy/cleanMdj.py $file
elif [[ $file == *.svg ]]
then
echo cleaning svg file: $file
$py $sompy/cleanSvg.py $file
elif [[ $file == *.py ]] || [[ $file == *.cpp ]] || [[ $file == *.h ]]
then
echo cleaning text file: $file
$py $sompy/cleanTxt.py $file
else
add=0
fi

if [[ $add -eq 1 ]]
then
git add $file
fi
fi
done

14 changes: 3 additions & 11 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
# all text files unix line endings
* text=auto
* text=auto eol=lf

*.cpp text eol=lf
*.h text eol=lf
*.py text eol=lf
*.sh text eol=lf
*.lua text eol=lf
*.txt text eol=lf
*.cmd eol=crlf
*.bat eol=crlf
*.svg text eol=lf
*.mdj text eol=lf
*.md text eol=lf
*.make text eol=lf
.git* text eol=lf

4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@
path = CppUTestSteps
url = [email protected]:sorgom/CppUTestSteps.git
branch = dev
[submodule "sompy"]
path = sompy
url = [email protected]:sorgom/sompy.git
branch = dev
24 changes: 12 additions & 12 deletions CLOC.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,50 +4,50 @@
-------------------------------------------------------------------------------
Language files blank comment code
-------------------------------------------------------------------------------
C++ 14 146 26 1174
C/C++ Header 17 167 150 647
C++ 14 155 25 1128
C/C++ Header 17 179 148 646
-------------------------------------------------------------------------------
SUM: 31 313 176 1821
SUM: 31 334 173 1774
-------------------------------------------------------------------------------
```
**testenv**
```
-------------------------------------------------------------------------------
Language files blank comment code
-------------------------------------------------------------------------------
C/C++ Header 24 237 174 1124
C++ 9 37 0 217
C/C++ Header 24 237 174 1116
C++ 9 41 0 217
-------------------------------------------------------------------------------
SUM: 33 274 174 1341
SUM: 33 278 174 1333
-------------------------------------------------------------------------------
```
**moduletests**
```
-------------------------------------------------------------------------------
Language files blank comment code
-------------------------------------------------------------------------------
C++ 14 286 297 2358
C++ 14 302 300 2376
-------------------------------------------------------------------------------
SUM: 14 286 297 2358
SUM: 14 302 300 2376
-------------------------------------------------------------------------------
```
**systemtests**
```
-------------------------------------------------------------------------------
Language files blank comment code
-------------------------------------------------------------------------------
C++ 2 14 22 117
C++ 2 15 22 117
-------------------------------------------------------------------------------
SUM: 2 14 22 117
SUM: 2 15 22 117
-------------------------------------------------------------------------------
```
**specification**
```
-------------------------------------------------------------------------------
Language files blank comment code
-------------------------------------------------------------------------------
C/C++ Header 14 85 143 314
C/C++ Header 14 97 142 309
-------------------------------------------------------------------------------
SUM: 14 85 143 314
SUM: 14 97 142 309
-------------------------------------------------------------------------------
```
4 changes: 2 additions & 2 deletions application/components/BAS/BAS_Provider.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ============================================================
// class BAS_Provider: base class to implement I_Provider
// - provides almost everything to satisfy
// - provides almost everything to satisfy
// an I_Provider derived interface
// To be defined by derived classes:
// - add: to add an element to the provider
Expand Down Expand Up @@ -32,7 +32,7 @@ class BAS_Provider : public I_Provider
}

void load(const ProjItem* data, UINT32 num) final;

protected:
inline BAS_Provider() = default;

Expand Down
14 changes: 7 additions & 7 deletions application/components/BAS/Containers.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
// derived from interface class IF
// ============================================================
template <typename IF>
class PolyVec
class PolyVec
{
public:
template <typename T, typename... Args>
inline void add(Args&&... args)
inline void add(Args&&... args)
{
static_assert(std::is_base_of<IF, T>::value);
mData.emplace_back(std::make_unique<T>(std::forward<Args>(args)...));
Expand All @@ -39,17 +39,17 @@ class PolyVec
inline void clear() { mData.clear(); }

// reserve memory for size objects
inline void reserve(size_t size)
{
mData.reserve(size);
inline void reserve(size_t size)
{
mData.reserve(size);
}

private:
std::vector<std::unique_ptr<IF>> mData;
};

// ============================================================
// class Index allows to
// class Index allows to
// - store const CONT objects with KEY type member
// in the order that the were added
// - index and find objects by KEY type
Expand Down Expand Up @@ -182,7 +182,7 @@ class Index
size_t dups = 0;
for (size_t a = 0, b = 1; b < mIdx.size(); ++a, ++b)
{
if (not gt(b, a))
if (not gt(b, a))
{
++dups;
}
Expand Down
5 changes: 1 addition & 4 deletions application/components/BAS/coding.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@
#include <codebase/BaseTypes.h>
#include <codebase/nocopy.h>

// enable usage of "and", "or"
// enable usage of "and", "or", "not" in place of "&&", "||", "!"
#include <ciso646>

// put into empty if / else branches for coverage
inline void pass() {}

// unified instance declaration
#define INSTANCE_DEC(NAME) \
static NAME& instance();
Expand Down
13 changes: 2 additions & 11 deletions application/components/BAS/src/BAS_Provider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,11 @@ void BAS_Provider::load(const ProjItem* data, const UINT32 num)
for (UINT32 n = 0; ok and (n < num); ++n, ++data)
{
const PosRes res = IL::getDispatcher().assign(data->name, comp(), n);
ok = res.valid;
if (ok)
{
ok = add(res.pos, *data);
}
else
{ pass(); }
ok = res.valid and add(res.pos, *data);
}
if (not ok)
{
clear();
IL::getLog().log(comp(), RET_ERR_STARTUP);
}
else
{ pass(); }

}
}
2 changes: 1 addition & 1 deletion application/components/COM/Com.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ============================================================
// class Com implements I_Com
// ============================================================
// created by Manfred Sorgo
// created by Manfred Sorgo

#pragma once

Expand Down
6 changes: 3 additions & 3 deletions application/components/COM/TCP.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// ============================================================
// implementation TCP base system
// implementation TCP base system
// ============================================================
// created by Manfred Sorgo

Expand Down Expand Up @@ -39,5 +39,5 @@ class TCP : public I_TCP
private:
TCP() = default;
UINT32 mSec = 0;
UINT32 mMicro = 10000;
};
UINT32 mMicro = 10000;
};
12 changes: 6 additions & 6 deletions application/components/COM/TCP_Com.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ class TCP_Com_Base
// ============================================================
// TCP listeners
// ============================================================
class Tcp_Listener_Base :
class Tcp_Listener_Base :
public I_TCP_Listener,
private TCP_Com_Base
{
public:
bool listen(UINT16 port) override;

bool select() override;

void close() override;
Expand Down Expand Up @@ -75,7 +75,7 @@ class TCP_Listener_Ctrl : public Tcp_Listener_Base
// TCP connections
// ============================================================
// base tcp communication client
class TCP_Con_Base :
class TCP_Con_Base :
public I_TCP_Con,
private TCP_Com_Base
{
Expand Down Expand Up @@ -111,8 +111,8 @@ class TCP_Con_Fld : public TCP_Con_Base
class TCP_Con_Gui : public TCP_Con_Base
{
public:
INSTANCE_DEC(TCP_Con_Gui)
NOCOPY(TCP_Con_Gui)
INSTANCE_DEC(TCP_Con_Gui)
NOCOPY(TCP_Con_Gui)
protected:
void onAccept() const override;
void forward(const ComTele& tele) const override;
Expand All @@ -131,4 +131,4 @@ class TCP_Con_Ctrl : public TCP_Con_Base
void forward(const ComTele& tele) const override;
private:
inline TCP_Con_Ctrl() = default;
};
};
8 changes: 4 additions & 4 deletions application/components/COM/src/Com.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ void Com::run()
and clientFld.select()
and clientGui.select()
and clientCtrl.select();

if (not ok)
{
IL::getLog().log(COMP_COM, RET_ERR_COM);
mRunning = false;
}
}
}

listenerFld.close();
listenerGui.close();
listenerCtrl.close();
Expand All @@ -73,4 +73,4 @@ void Com::toFld(const ComTele& tele) const
void Com::toGui(const ComTele& tele) const
{
IL::getTCP_Con_Gui().send(tele);
}
}
4 changes: 1 addition & 3 deletions application/components/COM/src/TCP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ bool TCP::bind(const INT32 socket, const UINT16 port) const
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = INADDR_ANY; // INADDR_LOOPBACK;
addr.sin_port = htons(port);
return ::bind(socket, (const sockaddr*)&addr, sizeof(addr)) >= 0;
return ::bind(socket, (const sockaddr*)&addr, sizeof(addr)) >= 0;
}

bool TCP::listen(const INT32 socket) const
Expand Down Expand Up @@ -95,6 +95,4 @@ void TCP::close(INT32& socket) const
::closesocket(socket);
socket = -1;
}
else
{ pass(); }
}
Loading
Loading