--- a/Beremiz_service.py Fri Apr 03 17:08:13 2015 +0200
+++ b/Beremiz_service.py Mon Jun 15 10:19:52 2015 +0200
@@ -354,7 +354,7 @@
def __init__(self, servicename, ip_addr, port,
workdir, argv, autostart=False,
statuschange=None, evaluator=default_evaluator,
- website=None):
+ pyruntimevars=None):
self.continueloop = True
self.daemon = None
self.servicename = servicename
@@ -367,7 +367,7 @@
self.autostart = autostart
self.statuschange = statuschange
self.evaluator = evaluator
- self.website = website
+ self.pyruntimevars = pyruntimevars
def Loop(self):
while self.continueloop:
@@ -387,7 +387,7 @@
self.daemon=pyro.Daemon(host=self.ip_addr, port=self.port)
self.plcobj = PLCObject(self.workdir, self.daemon, self.argv,
self.statuschange, self.evaluator,
- self.website)
+ self.pyruntimevars)
uri = self.daemon.connect(self.plcobj,"PLCObject")
print "Pyro port :",self.port
--- a/runtime/PLCObject.py Fri Apr 03 17:08:13 2015 +0200
+++ b/runtime/PLCObject.py Mon Jun 15 10:19:52 2015 +0200
@@ -137,10 +137,15 @@
Load PLC library
Declare all functions, arguments and return values
"""
+ md5 = open(self._GetMD5FileName(), "r").read()
try:
self._PLClibraryHandle = dlopen(self._GetLibFileName())
self.PLClibraryHandle = ctypes.CDLL(self.CurrentPLCFilename, handle=self._PLClibraryHandle)
+ self.PLCID = ctypes.c_char_p.in_dll(self.PLClibraryHandle, "PLCID")
+ if len(md5) == 32 :
+ self.PLCID.value = md5
+
self._startPLC = self.PLClibraryHandle.startPLC
self._startPLC.restype = ctypes.c_int
self._startPLC.argtypes = [ctypes.c_int, ctypes.POINTER(ctypes.c_char_p)]
--- a/targets/Linux/plc_Linux_main.c Fri Apr 03 17:08:13 2015 +0200
+++ b/targets/Linux/plc_Linux_main.c Mon Jun 15 10:19:52 2015 +0200
@@ -232,6 +232,14 @@
pthread_mutex_lock(&python_mutex);
}
+void InitRetain(void)
+{
+}
+
+void CleanupRetain(void)
+{
+}
+
int CheckRetainBuffer(void)
{
return 1;
--- a/targets/Win32/plc_Win32_main.c Fri Apr 03 17:08:13 2015 +0200
+++ b/targets/Win32/plc_Win32_main.c Mon Jun 15 10:19:52 2015 +0200
@@ -244,6 +244,14 @@
WaitForSingleObject(python_sem, INFINITE);
}
+void InitRetain(void)
+{
+}
+
+void CleanupRetain(void)
+{
+}
+
int CheckRetainBuffer(void)
{
return 1;
--- a/targets/Xenomai/plc_Xenomai_main.c Fri Apr 03 17:08:13 2015 +0200
+++ b/targets/Xenomai/plc_Xenomai_main.c Mon Jun 15 10:19:52 2015 +0200
@@ -363,23 +363,3 @@
} /* as plc does not wait for lock. */
}
-int CheckRetainBuffer(void)
-{
- return 1;
-}
-
-void ValidateRetainBuffer(void)
-{
-}
-
-void InValidateRetainBuffer(void)
-{
-}
-
-void Retain(unsigned int offset, unsigned int count, void *p)
-{
-}
-
-void Remind(unsigned int offset, unsigned int count, void *p)
-{
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/targets/Xenomai/plc_Xenomai_noretain.c Mon Jun 15 10:19:52 2015 +0200
@@ -0,0 +1,20 @@
+int CheckRetainBuffer(void)
+{
+ return 1;
+}
+
+void ValidateRetainBuffer(void)
+{
+}
+
+void InValidateRetainBuffer(void)
+{
+}
+
+void Retain(unsigned int offset, unsigned int count, void *p)
+{
+}
+
+void Remind(unsigned int offset, unsigned int count, void *p)
+{
+}
--- a/targets/__init__.py Fri Apr 03 17:08:13 2015 +0200
+++ b/targets/__init__.py Mon Jun 15 10:19:52 2015 +0200
@@ -38,7 +38,10 @@
targets = dict([(name, {"xsd":path.join(_base_path, name, "XSD"),
"class":_GetLocalTargetClassFactory(name),
- "code": path.join(path.split(__file__)[0],name,"plc_%s_main.c"%name)})
+ "code": { fname: path.join(_base_path, name, fname)
+ for fname in listdir(path.join(_base_path, name))
+ if fname.startswith("plc_%s_main"%name) and
+ fname.endswith(".c")}})
for name in listdir(_base_path)
if path.isdir(path.join(_base_path, name))
and not name.startswith("__")])
@@ -67,7 +70,9 @@
return targetchoices
def GetTargetCode(targetname):
- return open(targets[targetname]["code"]).read()
+ codedesc = targets[targetname]["code"]
+ code = "\n".join([open(fpath).read() for fname, fpath in sorted(codedesc.items())])
+ return code
def GetHeader():
filename = path.join(path.split(__file__)[0],"beremiz.h")
--- a/targets/plc_debug.c Fri Apr 03 17:08:13 2015 +0200
+++ b/targets/plc_debug.c Mon Jun 15 10:19:52 2015 +0200
@@ -111,6 +111,7 @@
}
extern int CheckRetainBuffer(void);
+extern void InitRetain(void);
void __init_debug(void)
{
@@ -118,13 +119,19 @@
buffer_cursor = debug_buffer;
retain_offset = 0;
buffer_state = BUFFER_FREE;
+ InitRetain();
/* Iterate over all variables to fill debug buffer */
- if(CheckRetainBuffer())
+ if(CheckRetainBuffer()){
__for_each_variable_do(RemindIterator);
+ }else{
+ char mstr[] = "RETAIN memory invalid - defaults used";
+ LogMessage(LOG_WARNING, mstr, sizeof(mstr));
+ }
retain_offset = 0;
}
extern void InitiateDebugTransfer(void);
+extern void CleanupRetain(void);
extern unsigned long __tick;
@@ -132,6 +139,7 @@
{
buffer_cursor = debug_buffer;
InitiateDebugTransfer();
+ CleanupRetain();
}
void __retrieve_debug(void)
--- a/targets/plc_main_head.c Fri Apr 03 17:08:13 2015 +0200
+++ b/targets/plc_main_head.c Mon Jun 15 10:19:52 2015 +0200
@@ -25,6 +25,7 @@
IEC_TIME __CURRENT_TIME;
IEC_BOOL __DEBUG = 0;
unsigned long __tick = 0;
+char *PLCID = NULL;
/*
* Variable generated by C softPLC and plugins
--- a/tests/python/c_code@c_ext/cfile.xml Fri Apr 03 17:08:13 2015 +0200
+++ b/tests/python/c_code@c_ext/cfile.xml Mon Jun 15 10:19:52 2015 +0200
@@ -14,6 +14,7 @@
volatile char PtoC=1,CtoP=2;
extern long AtomicCompareExchange(long*,long, long);
+extern char *PLCID;
int Simple_C_Call(int val){
return val+1;
@@ -34,6 +35,7 @@
res=1;
}
printf("C code called by Python: toC %d fromC %d\n",toC,*fromC);
+ printf("PLCID id %s\n",PLCID);
return res;
}
--- a/tests/python/plc.xml Fri Apr 03 17:08:13 2015 +0200
+++ b/tests/python/plc.xml Mon Jun 15 10:19:52 2015 +0200
@@ -1,7 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<project xmlns="http://www.plcopen.org/xml/tc6_0201" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xhtml="http://www.w3.org/1999/xhtml" xsi:schemaLocation="http://www.plcopen.org/xml/tc6_0201">
<fileHeader companyName="" productName="Beremiz" productVersion="0.0" creationDateTime="2008-12-14T16:21:19"/>
- <contentHeader name="Beremiz Python Support Tests" modificationDateTime="2015-02-25T13:38:24">
+ <contentHeader name="Beremiz Python Support Tests" modificationDateTime="2015-03-13T22:06:10">
<coordinateInfo>
<pageSize x="1024" y="1024"/>
<fbd>