nodes.py 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. # Include definitions from the Python package
  2. from cmsisdsp.cg.scheduler import GenericNode,GenericSink,GenericSource
  3. ### Define new types of Nodes
  4. class ProcessingNode(GenericNode):
  5. """
  6. Definition of a ProcessingNode for the graph
  7. Parameters
  8. ----------
  9. name : str
  10. Name of the C variable identifying this node
  11. in the C code
  12. theType : CGStaticType
  13. The datatype for the input and output
  14. inLength : int
  15. The number of samples consumed by input
  16. outLength : int
  17. The number of samples produced on output
  18. """
  19. def __init__(self,name,theType,inLength,outLength):
  20. GenericNode.__init__(self,name)
  21. self.addInput("i",theType,inLength)
  22. self.addOutput("o",theType,outLength)
  23. @property
  24. def typeName(self):
  25. """The name of the C++ class implementing this node"""
  26. return "ProcessingNode"
  27. class Sink(GenericSink):
  28. """
  29. Definition of a Sink node for the graph
  30. Parameters
  31. ----------
  32. name : str
  33. Name of the C variable identifying this node
  34. in the C code
  35. theType : CGStaticType
  36. The datatype for the input
  37. inLength : int
  38. The number of samples consumed by input
  39. """
  40. def __init__(self,name,theType,inLength):
  41. GenericSink.__init__(self,name)
  42. self.addInput("i",theType,inLength)
  43. @property
  44. def typeName(self):
  45. """The name of the C++ class implementing this node"""
  46. return "Sink"
  47. class Source(GenericSource):
  48. """
  49. Definition of a Source node for the graph
  50. Parameters
  51. ----------
  52. name : str
  53. Name of the C variable identifying this node
  54. in the C code
  55. theType : CGStaticType
  56. The datatype for the output
  57. outLength : int
  58. The number of samples produced on output
  59. """
  60. def __init__(self,name,theType,outLength):
  61. GenericSource.__init__(self,name)
  62. self.addOutput("o",theType,outLength)
  63. @property
  64. def typeName(self):
  65. """The name of the C++ class implementing this node"""
  66. return "Source"