1301 # Push this dictionnary into result. |
1301 # Push this dictionnary into result. |
1302 self._VariablesList.append(attrs) |
1302 self._VariablesList.append(attrs) |
1303 # Fill in IEC<->C translation dicts |
1303 # Fill in IEC<->C translation dicts |
1304 IEC_path=attrs["IEC_path"] |
1304 IEC_path=attrs["IEC_path"] |
1305 Idx=int(attrs["num"]) |
1305 Idx=int(attrs["num"]) |
1306 self._IECPathToIdx[IEC_path]=Idx |
1306 self._IECPathToIdx[IEC_path]=(Idx, attrs["type"]) |
1307 except Exception,e: |
1307 except Exception,e: |
1308 self.logger.write_error(_("Cannot open/parse VARIABLES.csv!\n")) |
1308 self.logger.write_error(_("Cannot open/parse VARIABLES.csv!\n")) |
1309 self.logger.write_error(traceback.format_exc()) |
1309 self.logger.write_error(traceback.format_exc()) |
1310 self.ResetIECProgramsAndVariables() |
1310 self.ResetIECProgramsAndVariables() |
1311 return False |
1311 return False |
1329 for v in self._VariablesList if v["vartype"] != "FB" and v["C_path"].find('.')<0]), |
1329 for v in self._VariablesList if v["vartype"] != "FB" and v["C_path"].find('.')<0]), |
1330 "subscription_table_count": |
1330 "subscription_table_count": |
1331 len(self._VariablesList), |
1331 len(self._VariablesList), |
1332 "variables_pointer_type_table_count": |
1332 "variables_pointer_type_table_count": |
1333 len(self._VariablesList), |
1333 len(self._VariablesList), |
1334 "variables_pointer_type_table_initializer":"\n".join([ |
1334 "for_each_variable_do_code":"\n".join([ |
1335 {"PT":" variable_table[%(num)s].ptrvalue = (void*)(%(C_path)s);\n", |
1335 {"PT":" (*fp)((void*)&%(C_path)s,%(type)s_P_ENUM);\n", |
1336 "VAR":" variable_table[%(num)s].ptrvalue = (void*)(&%(C_path)s);\n"}[v["vartype"]]%v + |
1336 "VAR":" (*fp)((void*)&%(C_path)s,%(type)s_ENUM);\n"}[v["vartype"]]%v |
1337 " variable_table[%(num)s].type = %(type)s_ENUM;\n"%v |
1337 for v in self._VariablesList if v["vartype"] != "FB" and v["type"] in DebugTypes ]), |
|
1338 "find_variable_case_code":"\n".join([ |
|
1339 " case %(num)s:\n"%v+ |
|
1340 " varp = (void*)&%(C_path)s;\n"%v+ |
|
1341 {"PT":" return %(type)s_P_ENUM;\n", |
|
1342 "VAR":" return %(type)s_ENUM;\n"}[v["vartype"]]%v |
1338 for v in self._VariablesList if v["vartype"] != "FB" and v["type"] in DebugTypes ])} |
1343 for v in self._VariablesList if v["vartype"] != "FB" and v["type"] in DebugTypes ])} |
1339 |
1344 |
1340 return debug_code |
1345 return debug_code |
1341 |
1346 |
1342 def Generate_plc_common_main(self): |
1347 def Generate_plc_common_main(self): |
1594 # This variable is not needed anymore! |
1599 # This variable is not needed anymore! |
1595 #print "Unused : " + IECPath |
1600 #print "Unused : " + IECPath |
1596 IECPathsToPop.append(IECPath) |
1601 IECPathsToPop.append(IECPath) |
1597 elif IECPath != "__tick__": |
1602 elif IECPath != "__tick__": |
1598 # Convert |
1603 # Convert |
1599 Idx = self._IECPathToIdx.get(IECPath,None) |
1604 Idx, IEC_Type = self._IECPathToIdx.get(IECPath,(None,None)) |
1600 if Idx is not None: |
1605 if Idx is not None: |
1601 Idxs.append(Idx) |
1606 Idxs.append((Idx, IEC_Type, IECPath)) |
1602 self.TracedIECPath.append(IECPath) |
|
1603 else: |
1607 else: |
1604 self.logger.write_warning(_("Debug : Unknown variable %s\n")%IECPath) |
1608 self.logger.write_warning(_("Debug : Unknown variable %s\n")%IECPath) |
1605 for IECPathToPop in IECPathsToPop: |
1609 for IECPathToPop in IECPathsToPop: |
1606 self.IECdebug_datas.pop(IECPathToPop) |
1610 self.IECdebug_datas.pop(IECPathToPop) |
1607 |
1611 |
1608 self._connector.SetTraceVariablesList(Idxs) |
1612 Idxs.sort() |
|
1613 self.TracedIECPath = zip(Idxs)[2] |
|
1614 self._connector.SetTraceVariablesList(zip(zip(Idxs)[0:1])) |
1609 self.IECdebug_lock.release() |
1615 self.IECdebug_lock.release() |
1610 |
1616 |
1611 #for IEC_path, IECdebug_data in self.IECdebug_datas.iteritems(): |
1617 #for IEC_path, IECdebug_data in self.IECdebug_datas.iteritems(): |
1612 # print IEC_path, IECdebug_data[0].keys() |
1618 # print IEC_path, IECdebug_data[0].keys() |
1613 |
1619 |
1627 """ |
1633 """ |
1628 Dispatching use a dictionnary linking IEC variable paths |
1634 Dispatching use a dictionnary linking IEC variable paths |
1629 to a WeakKeyDictionary linking |
1635 to a WeakKeyDictionary linking |
1630 weakly referenced callables to optionnal args |
1636 weakly referenced callables to optionnal args |
1631 """ |
1637 """ |
1632 if IECPath != "__tick__" and self._IECPathToIdx.get(IECPath, None) is None: |
1638 if IECPath != "__tick__" and not self._IECPathToIdx.has_key(IECPath): |
1633 return None |
1639 return None |
1634 |
1640 |
1635 self.IECdebug_lock.acquire() |
1641 self.IECdebug_lock.acquire() |
1636 # If no entry exist, create a new one with a fresh WeakKeyDictionary |
1642 # If no entry exist, create a new one with a fresh WeakKeyDictionary |
1637 IECdebug_data = self.IECdebug_datas.get(IECPath, None) |
1643 IECdebug_data = self.IECdebug_datas.get(IECPath, None) |