23 setParanoia(0) |
23 setParanoia(0) |
24 |
24 |
25 from util.TranslationCatalogs import AddCatalog |
25 from util.TranslationCatalogs import AddCatalog |
26 AddCatalog(os.path.join(CanFestivalPath, "objdictgen", "locale")) |
26 AddCatalog(os.path.join(CanFestivalPath, "objdictgen", "locale")) |
27 |
27 |
28 if wx.Platform == '__WXMSW__': |
|
29 DEFAULT_SETTINGS = { |
|
30 "CAN_Driver": "can_tcp_win32", |
|
31 "CAN_Device": "127.0.0.1", |
|
32 "CAN_Baudrate": "125K", |
|
33 "Slave_NodeId": 2, |
|
34 "Master_NodeId": 1, |
|
35 } |
|
36 else: |
|
37 DEFAULT_SETTINGS = { |
|
38 "CAN_Driver": "../CanFestival-3/drivers/can_socket/libcanfestival_can_socket.so", |
|
39 "CAN_Device": "vcan0", |
|
40 "CAN_Baudrate": "125K", |
|
41 "Slave_NodeId": 2, |
|
42 "Master_NodeId": 1, |
|
43 } |
|
44 |
|
45 #-------------------------------------------------- |
28 #-------------------------------------------------- |
46 # SLAVE |
29 # SLAVE |
47 #-------------------------------------------------- |
30 #-------------------------------------------------- |
48 |
31 |
49 class _SlaveCTN(NodeManager): |
32 class _SlaveCTN(NodeManager): |
50 XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?> |
33 XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?> |
51 <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> |
34 <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> |
52 <xsd:element name="CanFestivalSlaveNode"> |
35 <xsd:element name="CanFestivalSlaveNode"> |
53 <xsd:complexType> |
36 <xsd:complexType> |
54 <xsd:attribute name="CAN_Device" type="xsd:string" use="optional" default="%(CAN_Device)s"/> |
37 <xsd:attribute name="CAN_Device" type="xsd:string" use="optional"/> |
55 <xsd:attribute name="CAN_Baudrate" type="xsd:string" use="optional" default="%(CAN_Baudrate)s"/> |
38 <xsd:attribute name="CAN_Baudrate" type="xsd:string" use="optional"/> |
56 <xsd:attribute name="NodeId" type="xsd:integer" use="optional" default="%(Slave_NodeId)d"/> |
39 <xsd:attribute name="NodeId" type="xsd:integer" use="optional" default="2"/> |
57 <xsd:attribute name="Sync_Align" type="xsd:integer" use="optional" default="0"/> |
40 <xsd:attribute name="Sync_Align" type="xsd:integer" use="optional" default="0"/> |
58 <xsd:attribute name="Sync_Align_Ratio" use="optional" default="50"> |
41 <xsd:attribute name="Sync_Align_Ratio" use="optional" default="50"> |
59 <xsd:simpleType> |
42 <xsd:simpleType> |
60 <xsd:restriction base="xsd:integer"> |
43 <xsd:restriction base="xsd:integer"> |
61 <xsd:minInclusive value="1"/> |
44 <xsd:minInclusive value="1"/> |
245 class _NodeListCTN(NodeList): |
228 class _NodeListCTN(NodeList): |
246 XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?> |
229 XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?> |
247 <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> |
230 <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> |
248 <xsd:element name="CanFestivalNode"> |
231 <xsd:element name="CanFestivalNode"> |
249 <xsd:complexType> |
232 <xsd:complexType> |
250 <xsd:attribute name="CAN_Device" type="xsd:string" use="optional" default="%(CAN_Device)s"/> |
233 <xsd:attribute name="CAN_Device" type="xsd:string" use="optional"/> |
251 <xsd:attribute name="CAN_Baudrate" type="xsd:string" use="optional" default="%(CAN_Baudrate)s"/> |
234 <xsd:attribute name="CAN_Baudrate" type="xsd:string" use="optional"/> |
252 <xsd:attribute name="NodeId" type="xsd:integer" use="optional" default="%(Master_NodeId)d"/> |
235 <xsd:attribute name="NodeId" type="xsd:integer" use="optional" default="1"/> |
253 <xsd:attribute name="Sync_TPDOs" type="xsd:boolean" use="optional" default="true"/> |
236 <xsd:attribute name="Sync_TPDOs" type="xsd:boolean" use="optional" default="true"/> |
254 </xsd:complexType> |
237 </xsd:complexType> |
255 </xsd:element> |
238 </xsd:element> |
256 </xsd:schema> |
239 </xsd:schema> |
257 """ % DEFAULT_SETTINGS |
240 """ |
258 |
241 |
259 EditorType = NetworkEditor |
242 EditorType = NetworkEditor |
260 IconPath = os.path.join(CanFestivalPath, "objdictgen", "networkedit.png") |
243 IconPath = os.path.join(CanFestivalPath, "objdictgen", "networkedit.png") |
261 |
244 |
262 def __init__(self): |
245 def __init__(self): |
397 class RootClass: |
380 class RootClass: |
398 XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?> |
381 XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?> |
399 <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> |
382 <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> |
400 <xsd:element name="CanFestivalInstance"> |
383 <xsd:element name="CanFestivalInstance"> |
401 <xsd:complexType> |
384 <xsd:complexType> |
402 <xsd:attribute name="CAN_Driver" type="xsd:string" use="optional" default="%(CAN_Driver)s"/> |
385 <xsd:attribute name="CAN_Driver" type="xsd:string" use="optional"/> |
403 </xsd:complexType> |
386 </xsd:complexType> |
404 </xsd:element> |
387 </xsd:element> |
405 </xsd:schema> |
388 </xsd:schema> |
406 """ % DEFAULT_SETTINGS |
389 """ |
407 |
390 |
408 CTNChildrenTypes = [("CanOpenNode",_NodeListCTN, "CanOpen Master"), |
391 CTNChildrenTypes = [("CanOpenNode",_NodeListCTN, "CanOpen Master"), |
409 ("CanOpenSlave",_SlaveCTN, "CanOpen Slave")] |
392 ("CanOpenSlave",_SlaveCTN, "CanOpen Slave")] |
410 def GetParamsAttributes(self, path = None): |
393 def GetParamsAttributes(self, path = None): |
411 infos = ConfigTreeNode.GetParamsAttributes(self, path = None) |
394 infos = ConfigTreeNode.GetParamsAttributes(self, path = path) |
412 for element in infos: |
395 for element in infos: |
413 if element["name"] == "CanFestivalInstance": |
396 if element["name"] == "CanFestivalInstance": |
414 for child in element["children"]: |
397 for child in element["children"]: |
415 if child["name"] == "CAN_Driver": |
398 if child["name"] == "CAN_Driver": |
416 DLL_LIST= getattr(local_canfestival_config,"DLL_LIST",None) |
399 child["type"] = local_canfestival_config.DLL_LIST |
417 if DLL_LIST is not None: |
|
418 child["type"] = DLL_LIST |
|
419 return infos |
400 return infos |
420 |
401 |
421 def CTNGenerate_C(self, buildpath, locations): |
402 def CTNGenerate_C(self, buildpath, locations): |
422 can_driver = self.CanFestivalInstance.getCAN_Driver() |
403 can_driver = self.CanFestivalInstance.getCAN_Driver() |
|
404 if not can_driver : |
|
405 can_driver = local_canfestival_config.DLL_LIST[0] |
|
406 can_drv_ext = self.GetCTRoot().GetBuilder().extension |
|
407 can_driver_name = "libcanfestival_" + can_driver + can_drv_ext |
423 |
408 |
424 format_dict = {"locstr" : "_".join(map(str,self.GetCurrentLocation())), |
409 format_dict = {"locstr" : "_".join(map(str,self.GetCurrentLocation())), |
425 "candriver" : can_driver, |
410 "candriver" : can_driver_name, |
426 "nodes_includes" : "", |
411 "nodes_includes" : "", |
427 "board_decls" : "", |
412 "board_decls" : "", |
428 "nodes_init" : "", |
413 "nodes_init" : "", |
429 "nodes_open" : "", |
414 "nodes_open" : "", |
430 "nodes_stop" : "", |
415 "nodes_stop" : "", |
514 f.write(cf_main) |
499 f.write(cf_main) |
515 f.close() |
500 f.close() |
516 |
501 |
517 res = [(cf_main_path, local_canfestival_config.getCFLAGS(CanFestivalPath))],local_canfestival_config.getLDFLAGS(CanFestivalPath), True |
502 res = [(cf_main_path, local_canfestival_config.getCFLAGS(CanFestivalPath))],local_canfestival_config.getLDFLAGS(CanFestivalPath), True |
518 |
503 |
519 can_drv_ext = self.GetCTRoot().GetBuilder().extension |
504 can_driver_path = os.path.join(CanFestivalPath,"drivers",can_driver,can_driver_name) |
520 can_driver_path = os.path.join(CanFestivalPath,"drivers",can_driver,"libcanfestival_"+can_driver+can_drv_ext) |
|
521 if os.path.exists(can_driver_path): |
505 if os.path.exists(can_driver_path): |
522 res += ((can_driver+can_drv_ext, file(can_driver_path,"rb")),) |
506 res += ((can_driver_name, file(can_driver_path,"rb")),) |
523 |
507 |
524 return res |
508 return res |
525 |
509 |