test_gsd.py 982 B

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