Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
benhar-dev committed Feb 27, 2023
0 parents commit d991b3d
Show file tree
Hide file tree
Showing 29 changed files with 1,418 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* -text
91 changes: 91 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Add any directories, files, or patterns you don't want to be tracked by version control #

## Ignore Twincat non-source files ##
Confidential/

### User-specific files (from 4018 tmc should be ignored) ###
*.~u
*.tpy
*.tmc
*.tmcRefac
*.suo
*.user
*.orig
*.tclrs

### Build results ###
.engineering_servers/
*.compileinfo
*.compiled-library
*.bootinfo
*.bootinfo_guids
*.library
*.project.~u
*.tsproj.bak
*.xti.bak
LineIDs.dbg
LineIDs.dbg.bak
_Boot/
_CompileInfo/
_Libraries/
_ModuleInstall/

## Ignore TwinCAT HMI temporary files, build results, and
## files generated by popular TwinCAT HMI add-ons.
liveview_*
*.cache
*.db-shm
*.db-wal
*.pid
.hmiframework/
.hmipkgs/*-*-*-*/
tchmipublish.journal.json

# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# NuGet v3's project.json files produces more ignoreable files
*.nuget.props
*.nuget.targets

### Visual studio files ###
*.obj
*.exe
*.pdb
*.user
*.aps
*.pch
*.vspscc
*_i.c
*_p.c
*.ncb
*.suo
*.tlb
*.tlh
*.bak
*.cache
*.ilk
*.log
*.dll
*.lib
*.sbr
*.crc
*.cid
*.autostart
*.app
*.compileinfo
*.occ
*.tizip
*.plcproj.orig

### VS Code files ###
*.vscode

### Windows files ###
Thumbs.db
*.htm
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 benhar-dev

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<p align="center">
<img width="460" src="./docs/images/logo.svg">
</p>

## The mobject-disposable Library

This is one of the many libraries of mobject. This library focuses on the handling of disposing dynamic objects.

## What is mobject?

Pronounced mob-ject.

A sprinkling of OOP is usually enough to simplify and unclutter procedural code. However, the more you apply OOP, the more you find the need to expand it's scope to accommodate functionality which is missing from the language. Hence, mobject was conceived. It's a framework, library and mindset of how problems such as this can be resolved using both pre-written code and examples.

mobject's goal is to be a lightweight solution to typical oop problems.

## Documentation

The documentation for this project can be found [here](https://benhar-dev.github.io/mobject-disposable/#/).

## Versions

- TcXaeShell 3.1.4024.35
Empty file added docs/.nojekyll
Empty file.
25 changes: 25 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<p align="center">
<img width="460" src="./images/logo.svg">
</p>

> A framework and guide for writing object oriented programs in structured text.
## The mobject-disposable Library

This is one of the many libraries of mobject. This library focuses on the handling of disposing dynamic objects.

## What is mobject?

Pronounced mob-ject.

A sprinkling of OOP is usually enough to simplify and unclutter procedural code. However, the more you apply OOP, the more you find the need to expand it's scope to accommodate functionality which is missing from the language. Hence, mobject was conceived. It's a framework, library and mindset of how problems such as this can be resolved using both pre-written code and examples.

mobject's goal is to be a lightweight solution to typical oop problems.

## Why use mobject-disposable?

The mobject-disposable library provides a consistent way to handle the lifecycle of objects in an industrial control system. It includes an abstract class Disposable and an interface I_Disposable that can be implemented by classes that need to handle the deletion of objects.

Using this library ensures that objects are properly disposed of, which helps to prevent memory leaks and resource allocation issues. The Disposable class provides a consistent implementation of the OnDispose() method, which can be used by derived classes to handle the release of any resources or objects they own. The I_Disposable interface provides a common interface for objects that have a responsibility to delete others. This makes it easy to manage the lifecycle of objects in a complex system.

Overall, the mobject-disposable library helps to improve the reliability and maintainability of industrial control systems by providing a consistent way to handle the deletion of objects.
12 changes: 12 additions & 0 deletions docs/_sidebar.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
- Home

- [Welcome](/)

- mobject-disposable

- [Disposable](disposable.md)
- [I_Disposable](i-disposable.md)

- Guides

- [Coding Guide](https://benhar-dev.github.io/coding-convention/#/)
100 changes: 100 additions & 0 deletions docs/disposable.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Dispose Abstract Class

## Definition

| | |
| ----------- | ------------------------------- |
| Namespace | mobject-disposable |
| Library | mobject-disposable |
| Inheritance | None |
| Implements | [I_Disposable](i-disposable.md) |

## Remarks

The Disposable Abstract Class is a utility class that allows objects to handle being destroyed in a consistent manor.

## Example

```declaration
FUNCTION_BLOCK MyObject EXTENDS Disposable
VAR
END_VAR
```

```body
//... no code should go here.
```

```declaration
METHOD OnDispose : BOOL
VAR_INPUT
CalledExplicitly : BOOL; // true if disposal was triggered from Dispose()
END_VAR
```

```body
// Here you should dispose of any objects your object owns or manages.
// ...
```

## Methods

### Dispose()

Will trigger the object for deletion.

#### Parameters

N/A

#### Return

N/A

#### Usage

```example
myObject.Dispose()
```

### Abstract OnDispose() : BOOL;

This method must be implemented by the concrete class.

OnDispose will be called explicitly by the Dispose() method, or from someone calling \_\_DELETE on the object, or by TwinCAT when it destroys the object.

#### Parameters

| Parameters | Datatype | Description |
| ---------------- | -------- | ---------------------------------------------------------------------- |
| CalledExplicitly | BOOL | This boolean will return True if disposal was triggered from Dispose() |

#### Return

| Datatype | Description |
| -------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| BOOL | Returning true will cancel the disposal. If you cancel it, then you must call Dispose or \_\_DELETE when you are ready for the final disposal. |

#### Usage

```declaration
METHOD OnDispose : BOOL
VAR_INPUT
CalledExplicitly : BOOL; // true if disposal was triggered from Dispose()
END_VAR
```

```body
// your code goes here...
// you should dispose any dynamic objects your object is managing
// in most cases you can simply return from this method.
RETURN;
// however...
// if the releasing of objects is not possible in a single cycle then you must return TRUE
OnDispose := true;
// This will suppress the final deletion and a second call of Dispose() will be required.
// The second call of Dispose() will not re-trigger this method.
```
40 changes: 40 additions & 0 deletions docs/docsify/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

.markdown-section output:after, .markdown-section pre:after {
content: '';
}

pre {
margin : 0px;
}

.markdown-section pre {
padding: 0;
}

.markdown-section pre>code {
padding: 2.2em 2.2em;
}

.markdown-section code {
background-color: #f8f8f8;
padding : 1.3em;
}

.markdown-section pre {
margin: 0em 0;
position: relative;
background-color:white;
}

.markdown-section blockquote {
border-left: 4px solid #929292;
background-color: #f4f4f4;
}

.sidebar ul li.active>a {
color: #29292b;;
}

.github-corner svg {
fill: #383d41;
}
31 changes: 31 additions & 0 deletions docs/docsify/language-st.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
.token.class-name {
color:blue;
}

.token.keyword {
color:blue;
}

.token.variable {
color:blue;
}

.token.comment {
color:green;
}


[data-lang="declaration"] {
margin-bottom: 0px !important;
}

[data-lang="body"] {
border-top: 1px solid lightgrey;
margin-top: 0px !important;
}


[data-lang="body"] + [data-lang="declaration"] {
border-top: 1px solid lightgrey;
margin-top: 0px !important;
}
Loading

0 comments on commit d991b3d

Please sign in to comment.