connectors/PYRO/dialog.py
author Andrey Skvortsov <andrej.skvortzov@gmail.com>
Sun, 06 Jan 2019 03:11:39 +0300
changeset 2501 eba2bbb2dd9a
parent 2182 eeca1aff0691
permissions -rw-r--r--
Make online debug optional

It could be useful for very small targets like Atmega (Arduino) and
for target bring-up there developer want to have running PLC program,
but has not implemented runtime communication yet.


TARGET_DEBUG_AND_RETAIN_DISABLE - completely disable debug and retain
functionality. Previously named TARGET_DEBUG_DISABLE.

TARGET_ONLINE_DEBUG_DISABLE - can be used to enable retain
functionality (no define TARGET_DEBUG_AND_RETAIN_DISABLE is used), but disable
online debug with corresponding RAM/FLASH overhead.

TARGET_LOGGING_DISABLE - disables logging functionality from runtime and PLC program

TARGET_EXT_SYNC_DISABLE - disables PLC program synchronization with
external events. For example, it could be used to synchronize several
PLCs that control motors for different axes.

By default all these options are off.

To test generate program for Generic target, put following files in
project files directory and run build.sh after generating PLC program.
This is very easy to integrate into makefile (Generic target).

[------------- build.sh --------------------------]
files=$(find $PWD/../build -iname '*.c' | grep -v POUS.c)
arm-none-eabi-gcc \
-DTARGET_DEBUG_AND_RETAIN_DISABLE \
-DTARGET_ONLINE_DEBUG_DISABLE \
-DTARGET_LOGGING_DISABLE \
-DTARGET_EXT_SYNC_DISABLE \
-flto -ffunction-sections -fdata-sections -I../../../../matiec/lib/C \
$files \
main.c \
-Wl,--Map=./program.map,--cref \
-nodefaultlibs --specs=nano.specs -Wl,--static -Wl,--gc-section -Wl,--start-group -lc -lm -lnosys -lgcc -Wl,--end-group
[------------------------------------------------]

[------------- main.c --------------------------]
#ifndef TARGET_DEBUG_AND_RETAIN_DISABLE
void Retain(void){}
void InValidateRetainBuffer(void){}
void ValidateRetainBuffer(void){}
#endif

extern void __run(void);
int main(void)
{
for(;;) {
__run();
// sleep common_ticktime__ ns
// add common_ticktime__ ns to __CURRENT_TIME
}
return 0;
}
[------------------------------------------------]
2007
ef2d479f564f #2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff changeset
     1
#!/usr/bin/env python
ef2d479f564f #2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff changeset
     2
# -*- coding: utf-8 -*-
ef2d479f564f #2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff changeset
     3
2008
1f31a2f61993 #2476 Changes to the comment.
dporopat <denis.poropat@smarteh.si>
parents: 2007
diff changeset
     4
# Copyright (C) 2018: Smarteh
2007
ef2d479f564f #2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff changeset
     5
#
ef2d479f564f #2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff changeset
     6
# See COPYING file for copyrights details.
ef2d479f564f #2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff changeset
     7
ef2d479f564f #2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff changeset
     8
ef2d479f564f #2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff changeset
     9
from __future__ import absolute_import
ef2d479f564f #2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff changeset
    10
from __future__ import print_function
ef2d479f564f #2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff changeset
    11
ef2d479f564f #2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff changeset
    12
import wx
2182
eeca1aff0691 Fix linter errors
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2180
diff changeset
    13
from zope.interface import implementer
eeca1aff0691 Fix linter errors
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2180
diff changeset
    14
2007
ef2d479f564f #2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff changeset
    15
from controls.UriLocationEditor import IConnectorPanel
ef2d479f564f #2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff changeset
    16
ef2d479f564f #2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff changeset
    17
URITypes = ["LOCAL", "PYRO", "PYROS"]
ef2d479f564f #2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff changeset
    18
ef2d479f564f #2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff changeset
    19
ef2d479f564f #2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff changeset
    20
def PYRO_connector_dialog(confnodesroot):
ef2d479f564f #2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff changeset
    21
    [ID_IPTEXT, ID_PORTTEXT] = [wx.NewId() for _init_ctrls in range(2)]
ef2d479f564f #2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff changeset
    22
ef2d479f564f #2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff changeset
    23
    @implementer(IConnectorPanel)
ef2d479f564f #2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff changeset
    24
    class PYROConnectorPanel(wx.Panel):
ef2d479f564f #2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff changeset
    25
        def __init__(self, typeConnector, parrent, *args, **kwargs):
ef2d479f564f #2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff changeset
    26
            self.type = typeConnector
ef2d479f564f #2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff changeset
    27
            self.parrent = parrent
ef2d479f564f #2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff changeset
    28
            wx.Panel.__init__(self, parrent, *args, **kwargs)
ef2d479f564f #2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff changeset
    29
            self._init_ctrls()
ef2d479f564f #2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff changeset
    30
            self._init_sizers()
ef2d479f564f #2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff changeset
    31
            self.uri = None
ef2d479f564f #2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff changeset
    32
ef2d479f564f #2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff changeset
    33
        def _init_ctrls(self):
2182
eeca1aff0691 Fix linter errors
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2180
diff changeset
    34
            self.IpText = wx.TextCtrl(parent=self, id=ID_IPTEXT, size=wx.Size(200, -1))
eeca1aff0691 Fix linter errors
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2180
diff changeset
    35
            self.PortText = wx.TextCtrl(parent=self, id=ID_PORTTEXT, size=wx.Size(200, -1))
2007
ef2d479f564f #2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff changeset
    36
ef2d479f564f #2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff changeset
    37
        def _init_sizers(self):
2180
017ad9cc20b9 Don't use fixed width labels in WAMP and PYRO dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2179
diff changeset
    38
            self.mainSizer = wx.FlexGridSizer(cols=2, hgap=10, rows=5, vgap=10)
017ad9cc20b9 Don't use fixed width labels in WAMP and PYRO dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2179
diff changeset
    39
            self.mainSizer.AddWindow(wx.StaticText(self, label=_("URI host:")),
017ad9cc20b9 Don't use fixed width labels in WAMP and PYRO dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2179
diff changeset
    40
                                     flag=wx.ALIGN_CENTER_VERTICAL)
017ad9cc20b9 Don't use fixed width labels in WAMP and PYRO dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2179
diff changeset
    41
            self.mainSizer.AddWindow(self.IpText, flag=wx.GROW)
2007
ef2d479f564f #2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff changeset
    42
2180
017ad9cc20b9 Don't use fixed width labels in WAMP and PYRO dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2179
diff changeset
    43
            self.mainSizer.AddWindow(wx.StaticText(self, label=_("URI port:")),
017ad9cc20b9 Don't use fixed width labels in WAMP and PYRO dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2179
diff changeset
    44
                                     flag=wx.ALIGN_CENTER_VERTICAL)
017ad9cc20b9 Don't use fixed width labels in WAMP and PYRO dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2179
diff changeset
    45
            self.mainSizer.AddWindow(self.PortText, flag=wx.GROW)
2007
ef2d479f564f #2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff changeset
    46
            self.SetSizer(self.mainSizer)
ef2d479f564f #2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff changeset
    47
ef2d479f564f #2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff changeset
    48
        def SetURI(self, uri):
ef2d479f564f #2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff changeset
    49
            self.uri = uri
ef2d479f564f #2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff changeset
    50
            uri_list = uri.strip().split(":")
ef2d479f564f #2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff changeset
    51
            length = len(uri_list)
ef2d479f564f #2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff changeset
    52
            if length == 3:
ef2d479f564f #2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff changeset
    53
                self.IpText.SetValue(uri_list[1].strip("/"))
ef2d479f564f #2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff changeset
    54
                self.PortText.SetValue(uri_list[2])
ef2d479f564f #2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff changeset
    55
            elif length == 2:
ef2d479f564f #2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff changeset
    56
                self.IpText.SetValue(uri_list[1].strip("/"))
ef2d479f564f #2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff changeset
    57
ef2d479f564f #2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff changeset
    58
        def GetURI(self):
ef2d479f564f #2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff changeset
    59
            self.uri = self.type+"://"+self.IpText.GetValue()+":"+self.PortText.GetValue()
ef2d479f564f #2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff changeset
    60
            return self.uri
ef2d479f564f #2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff changeset
    61
ef2d479f564f #2476 Connectors dialog module added.
dporopat <denis.poropat@smarteh.si>
parents:
diff changeset
    62
    return PYROConnectorPanel("PYRO", confnodesroot)