Giter VIP home page Giter VIP logo

tcbase's Introduction

GitHub license

TcBase - TwinCAT 3 base framework

Introduction

This is an open-source TwinCAT 3 base framework providing a baseline for developing object-oriented TwinCAT 3 projects. It provides boilerplates of some well-known software design patterns, such as state pattern, and observer pattern. More patterns to come. It aims to provide more advanced types of data collection, for now only a list. Additionally, it has some utilities like an invocation tracker and action, which can be executed iteratively over an I_Enumerable, for example, fbList.ForEach(fbRunAllCyclicTask).

This project is under heavy development, so there will not be any releases any time soon. However, the project is built to be a library, so you can manually produce a library out of this project from the source code. For instructions on how to do this, check here.

How to use the framework

To take full advantage of the framework - being an object-oriented framework itself - every new FB that you create should inherit from FB_Object or its children. Like how FB_State inherits from FB_Object and thus can be stored in FB_List without any extra implementation. At this point, you might be wondering "well that is a helluva lot of coupling", and we applaud such intuition. That is why we try our best to keep the framework as lite as possible, to minimize the coupling.

Being under heavy development, we advise you well to use proxy - or simply put, a wrapper - when using this library, instead of direct usage.

Dependencies

The unit tests for TcBase depends on the TcUnit library version 1.2.0.0.

Acknowledgement

Some elements of the TcBase were based on parts of the open-sourced project TcOpen.

tcbase's People

Contributors

ahuca avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

tcbase's Issues

Fix bug with FB_List.RemoveAt

IF nIdx < THIS^.nLastIdx THEN
    Tc2_System.MEMCPY(destAddr := pTmp,
                      srcAddr := ADR(pBuffer[nIdx + 1]),
                      n := TO_UDINT(THIS^.nLastIdx - nIdx)*THIS^.nItemSize);
END_IF

At line 15, the statement destAddr := pTmp is actually incorrect, this time pTmp should start from an offset whose size is equivalent to the previously copied memory.

Improve test suite for FB_List

  1. Consider breaking down the current FB_List_Test test suite into multiple test suites each dedicated to testing a single method/property
  2. Add more tests. Test ruthlessly, so that bugs like #24 won't happen again

Add documentation

Figure out some auto doc generator for the API based on, for example, comments, or pragmas written inside the source code

Rethink the linking of FB_Object:s

At the moment FB_Objects are able to be bound together via its FB_init "constructor". This property has been taken directly from TcOpen. For their (TcOpenGroup) use-case, objects are instantiated within a context, which has "global" shared resources for all the child objects to access. For instance, a TcoLogger within a context is available for all child objects to use. Here are a few points to mull over:

  1. What are the real benefits of this practice (for our use case)?
  2. Does this increases unnecessary and accidental couplings between objects?
  3. Should this be the default behaviour for FB_Object? If not, should there be another object like FB_LinkedObject? Hence the final implementation would include FB_Object (resembling current FB_OrphanObject) and FB_LinkedObjects (resembling current FB_Object)

Does @Colho have any thoughts on this?

Dictionary as a new Collection type

Dictionary as a new Collection type would be beneficial, as dictionary is a widely used data structure. Basic idea is to have <Key, Value> pair, where a key is always associated with a value.

Dictionary characteristics:

  • Key and value pairs can be added to the dictionary
  • Key and value pairs can be removed from the dictionary
  • Values can be fetched from the dictionary with a key
  • Every key in dictionary must be unique
  • Keys can be tested are they already in the dictionary

Some remarks:

  • Using hash table for fast value lookup?
  • Possibility to enumerate all the key and value pairs? (for looping through the dict?)
  • Equality comparer for generic objects?

Improve FB_List performance by resizing more than needed

Adding an item to the list can be optimized by resizing the list more than needed, reducing the time taken to add.
For deleting an item, consider removing that item alone and leaving the memory area the same most of the time. Only when the spare memory exceeds a certain threshold does the list resize.

example of use

Hello,
create a usage example to understand how to use it.

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.