test_gsd.py 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. from __future__ import division, absolute_import, print_function, unicode_literals
  2. from pyprofibus_tstlib import *
  3. initTest(__file__)
  4. import pyprofibus
  5. import pyprofibus.gsd
  6. import os
  7. class Test_GSD(TestCase):
  8. def test_modular(self):
  9. gsd = pyprofibus.gsd.GsdInterp.fromFile(os.path.join("misc", "dummy_modular.gsd"))
  10. gsd.setConfiguredModule("dummy input module")
  11. gsd.setConfiguredModule("dummy output module")
  12. self.assertEqual([ e.getDU()
  13. for e in gsd.getCfgDataElements() ],
  14. [ bytearray([0x00, ]),
  15. bytearray([0x10, ]),
  16. bytearray([0x20, ]), ])
  17. self.assertEqual(gsd.getIdentNumber(), 0x4224)
  18. self.assertEqual(gsd.getUserPrmData(), bytearray([0x00, 0x00, 0x00, 0x42]))
  19. def test_compact(self):
  20. gsd = pyprofibus.gsd.GsdInterp.fromFile(os.path.join("misc", "dummy_compact.gsd"))
  21. self.assertEqual([ e.getDU()
  22. for e in gsd.getCfgDataElements() ],
  23. [ bytearray([0x00, ]),
  24. bytearray([0x10, ]),
  25. bytearray([0x20, ]), ])
  26. self.assertEqual(gsd.getIdentNumber(), 0x4224)
  27. self.assertEqual(gsd.getUserPrmData(), bytearray([0x00, 0x00, 0x00, 0x42]))