Coder Social home page Coder Social logo

sorgom / dstw Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 543 KB

Digital Interlockig (DSTW) Implementation, C++, SIL4, CppUTest

License: GNU General Public License v3.0

C 1.81% C++ 61.14% Python 8.22% Lua 3.80% Makefile 23.07% Shell 1.73% Batchfile 0.23%
cpputests dstw sil4 coverage en61508 sca cplusplus cpp17 cpp20 ai

dstw's Introduction

DSTW

the project

An implementation of an interlocking control logic (ICL) which represents the states of field elements like signals or track switches and communicates with control panels (GUIs) and the real field elements.

It consists of the following components:

  • TSW: track switches
  • SIG: signals
  • LCR: level crossings
  • SEG: track segments
  • SYS: commonly used system
  • COM: TCP communication to field and GUI

goals

The project does not intend an implementation that would work in a real digital interlocking (DSTW).

The aim is to

  • apply and demonstrate techniques to meet security integrity level 4 (SIL4).
  • show a completely different approach than the model driven one I happened to experience.
  • use as much modern C++ as possible
  • gain AI usage experience

components interaction overview

overview

topics

dstw's People

Contributors

sorgom avatar

Watchers

 avatar

dstw's Issues

make the byte order header only

involved:

  • application\components\BAS\src\HN.cpp
  • application\components\BAS\HN.h

current cpp:

#ifdef _WIN32
#include <winsock2.h>
#else
#include <arpa/inet.h>
#endif

UINT32 HN::toN(const UINT32 val)
{
    return htonl(val);
}

UINT32 HN::toH(const UINT32 val)
{
    return ntohl(val);
}

UINT16 HN::toN(const UINT16 val)
{
    return htons(val);
}

UINT16 HN::toH(const UINT16 val)
{
    return ntohs(val);
}
  • move this to header and make it inline
  • resolve VS problems

the great refactoring

changes

  • I_Provider
  • I_Hub
  • one telegram type, 2 derived ones:
    • teleFld
    • teleGui
  • containers:
    • Index non const
    • reserve without return
  • enums
    • one enum for all states
  • testing
    • one mock for all Hubs
    • one mock for all Providers
  • adapt genCode

establish TCP communication

Com

The COM interface has to communicate via TCP:

  • 1 GUI connection
  • 1 FLD connection
  • 1 CTRL connection

new interface methods

  • shutdown
  • run with ComSetup data
    • call Dispatcher recall field

new data

  • ComSetup
  • ComTele for shutdown

other modules

Dispatcher

  • send re-call telegrams to field when
    • field reconnects
  • send UNDEF telegrams to GUI when
    • field disconnects

    TODO ...

improve project readme

## state of implementation

recommendation:

  • get rid of the releases stuff
  • write a project description
    • motivation
    • why this is better and SIL4
    • techniques applied
    • and so on

bug: wrong code in TCP_Client

this code is wrong:

    bool TCP_Client::recv(PTR data, INT32 size) const
    {
        fd_set readfds;
        FD_ZERO(&readfds);
        FD_SET(mSocket, &readfds);
        timeval timeout{0, 50000};
        bool ok = false;
        if (
            (::select(mSocket + 1, &readfds, nullptr, nullptr, &timeout) >= 0) and
            (FD_ISSET(mSocket, &readfds))
        )
        {
            ok = ::recv(mSocket, static_cast<char*>(data), size, 0) == size;
        }
        return ok;
    }

after successful select the client

  • must read as much as possible
  • call on Receive with ComTele with each sizeof(ComTele)

bug #57

Re-design Static Array

The StaticArray class has too many options.

Create dedicated classes:

InterfaceArray

  • not sortable
  • main class virtual
  • add of derived class
  • non const access

FixedDataArray

  • not sortable
  • const access only
  • only main class

Index

  • refers FixedDataArray
  • is sortable
  • virtual is greater

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.