targets/plc_main_head.c
author |
Andrey Skvortsov <andrej.skvortzov@gmail.com> |
|
Mon, 13 Aug 2018 18:29:07 +0300 |
changeset 2284 |
64bb520009f3 |
parent 1981 |
d0718654d9b0
|
child 2503 |
6ffeffb6d635 |
permissions |
-rw-r--r-- |
Fix wxHMI example after upgrading wxGlade
Newer wxGlade generates code to initialize GridSizer's with empty
elements.
...
grid_sizer_1.Add(self.window_1, 1, wx.ALIGN_CENTER, 0)
sizer_2.Add((0, 0), 0, 0, 0)
sizer_2.Add((0, 0), 0, 0, 0)
sizer_2.Add((0, 0), 0, 0, 0)
sizer_2.Add((0, 0), 0, 0, 0)
...
That causes following traceback, if new buttons are added
to already full sizer.
PLCobject : Traceback (most recent call last):
File "./Beremiz_service.py", line 389, in default_evaluator
res = (tocall(*args, **kwargs), None)
File "/tmp/tmpQS8ct2/runtime_0.py", line 540, in _runtime_0_start
wx.MessageBox(_("Please stop PLC to close"))
File "/tmp/tmpQS8ct2/runtime_0.py", line 504, in Init
lambda axis:( MakeButtonFunc(self, sizer, axis+"axisMinus"),
File "/tmp/tmpQS8ct2/runtime_0.py", line 502, in <lambda>
lambda btname: MakeButtonFunc(self, sizer, btname), ActionButtons)
File "/tmp/tmpQS8ct2/runtime_0.py", line 461, in MakeButtonFunc
print sizer, btname
File "/usr/lib/python2.7/dist-packages/wx-3.0-gtk3/wx/_core.py", line 14453, in Add
return _core_.Sizer_Add(*args, **kwargs)
PyAssertionError: C++ assertion "Assert failure" failed at
../src/common/sizer.cpp(1401) in DoInsert(): too many items (11 > 2*5)
in grid sizer (maybe you should omit the number of either rows or
columns?)
Tested with wxGlade version 0.8.3
Closes #41
/**
* Head of code common to all C targets
**/
#include "beremiz.h"
#include <string.h>
/*
* Prototypes of functions provided by generated C softPLC
**/
void config_run__(unsigned long tick);
void config_init__(void);
/*
* Prototypes of functions provided by generated target C code
* */
long long AtomicCompareExchange64(long long*, long long, long long);
void __init_debug(void);
void __cleanup_debug(void);
/*void __retrieve_debug(void);*/
void __publish_debug(void);
/*
* Variables used by generated C softPLC and plugins
**/
IEC_TIME __CURRENT_TIME;
IEC_BOOL __DEBUG = 0;
unsigned long __tick = 0;
char *PLC_ID = NULL;
/*
* Variable generated by C softPLC and plugins
**/
extern unsigned long greatest_tick_count__;
/* Help to quit cleanly when init fail at a certain level */
static int init_level = 0;
/* Prototype for Logging to help spotting errors at init */
int LogMessage(uint8_t level, char* buf, uint32_t size);
/*
* Prototypes of functions exported by plugins
**/
%(calls_prototypes)s
/*
* Retrieve input variables, run PLC and publish output variables
**/
void __run(void)
{
__tick++;
if (greatest_tick_count__)
__tick %%= greatest_tick_count__;
%(retrieve_calls)s
/*__retrieve_debug();*/
config_run__(__tick);
__publish_debug();
%(publish_calls)s
}
/*
* Initialize variables according to PLC's default values,
* and then init plugins with that values
**/
int __init(int argc,char **argv)
{
int res = 0;
init_level = 0;
/* Effective tick time with 1ms default value */
if(!common_ticktime__)
common_ticktime__ = 1000000;
config_init__();
__init_debug();
%(init_calls)s
return res;
}
/*
* Calls plugin cleanup proc.
**/
void __cleanup(void)
{
%(cleanup_calls)s
__cleanup_debug();
}
void PLC_GetTime(IEC_TIME *CURRENT_TIME);
void PLC_SetTimer(unsigned long long next, unsigned long long period);