targets/plc_main_head.c
author |
Andrey Skvortsov <andrej.skvortzov@gmail.com> |
|
Wed, 05 Apr 2017 14:24:52 +0300 |
changeset 1673 |
fab1b8da6eba |
parent 1463 |
de311ffe3961
|
child 1981 |
d0718654d9b0 |
permissions |
-rw-r--r-- |
clean PLC log only if there is something to clean
Otherwise exception happens in Beremiz service.
Traceback (most recent call last):
File "/home/developer/WorkData/PLC/beremiz/beremiz/connectors/PYRO/_init_.py", line 113, in catcher_func
return func(*args, **kwargs)
File "/home/developer/WorkData/PLC/beremiz/beremiz/connectors/PYRO/_init_.py", line 194, in my_local_func
return RemotePLCObjectProxy._getattr_(attrName)(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/Pyro/core.py", line 381, in _call_
return self._send(self._name, args, kwargs)
File "/usr/lib/python2.7/dist-packages/Pyro/core.py", line 456, in _invokePYRO
return self.adapter.remoteInvocation(name, Pyro.constants.RIF_VarargsAndKeywords, vargs, kargs)
File "/usr/lib/python2.7/dist-packages/Pyro/protocol.py", line 457, in remoteInvocation
return self._remoteInvocation(method, flags, *args)
File "/usr/lib/python2.7/dist-packages/Pyro/protocol.py", line 532, in _remoteInvocation
answer.raiseEx()
File "/usr/lib/python2.7/dist-packages/Pyro/errors.py", line 72, in raiseEx
raise self.excObj
AttributeError: 'PLCObject' object has no attribute '_ResetLogCount'
+--- This exception occured remotely (Pyro) - Remote traceback:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/Pyro/protocol.py", line 719, in _handleInvocation2
res = obj.Pyro_dyncall(req[1],flags,req[3]) # (method,flags,args)
File "/usr/lib/python2.7/dist-packages/Pyro/core.py", line 108, in Pyro_dyncall
return getattr(self.delegate or self,method) (args,*keywords)
File "/home/developer/WorkData/PLC/beremiz/beremiz/runtime/PLCObject.py", line 101, in ResetLogCount
if self._ResetLogCount is not None:
AttributeError: 'PLCObject' object has no attribute '_ResetLogCount'
+--- End of remote traceback
/**
* 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;
/*
* 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);