py_ext/PythonFileCTNMixin.py
changeset 1148 d0e40e99f422
parent 1145 203f4eff3313
child 1154 da9ccfceff31
equal deleted inserted replaced
1147:71db4592beb2 1148:d0e40e99f422
   155         __%(name)s_rbuffer = %(configname)s__%(uppername)s.value;
   155         __%(name)s_rbuffer = %(configname)s__%(uppername)s.value;
   156         AtomicCompareExchange((long*)&__%(name)s_rlock, 1, 0);
   156         AtomicCompareExchange((long*)&__%(name)s_rlock, 1, 0);
   157     }
   157     }
   158 """ 
   158 """ 
   159 
   159 
   160         vardec, varret, varpub = map("\n".join, zip(*[
   160         var_str = map("\n".join, zip(*[
   161             map(lambda f : f % varinfo,
   161             map(lambda f : f % varinfo,
   162                 (vardecfmt, varretfmt, varpubfmt))
   162                 (vardecfmt, varretfmt, varpubfmt))
   163                 for varinfo in map(lambda variable : {
   163                 for varinfo in map(lambda variable : {
   164                     "name": variable.getname(),
   164                     "name": variable.getname(),
   165                     "configname": configname.upper(),
   165                     "configname": configname.upper(),
   166                     "uppername": variable.getname().upper(),
   166                     "uppername": variable.getname().upper(),
   167                     "IECtype": "IEC_%s"%variable.gettype(),
   167                     "IECtype": "IEC_%s"%variable.gettype(),
   168                     "initial" : str(variable.getinitial())},
   168                     "initial" : str(variable.getinitial())},
   169                     self.CodeFile.variables.variable)]))
   169                     self.CodeFile.variables.variable)]))
       
   170         if len(var_str) > 0:
       
   171             vardec, varret, varpub = var_str
       
   172         else:
       
   173             vardec = varret = varpub = ""
   170         
   174         
   171         PyCFileContent = """\
   175         PyCFileContent = """\
   172 /* 
   176 /* 
   173  * Code generated by Beremiz py_ext confnode 
   177  * Code generated by Beremiz py_ext confnode 
   174  * for safe global variables access
   178  * for safe global variables access