-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
225 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from cothread import catools | ||
|
||
from malcolm.parts.ca.capart import CAPart | ||
from malcolm.metas.choicemeta import ChoiceMeta | ||
from malcolm.metas.stringmeta import StringMeta | ||
from malcolm.core.method import takes, REQUIRED | ||
|
||
|
||
class CAChoicePart(CAPart): | ||
"""Defines a part which connects to a pv via channel access DBR_ENUM""" | ||
|
||
@takes( | ||
StringMeta("name", "name of created attribute"), REQUIRED, | ||
StringMeta("description", "desc of created attribute"), REQUIRED, | ||
StringMeta("pv", "full pv of demand and default for rbv"), REQUIRED, | ||
StringMeta("rbv", "override for rbv"), None, | ||
StringMeta("rbv_suff", "set rbv ro pv + rbv_suff"), None, | ||
) | ||
def setup(self, params): | ||
""" setup is called by the base class Part.__init__ via self.Method. | ||
self.Method is defined by the @takes decorator above. | ||
It defines an attribute to publish the pv | ||
Args: | ||
params(Map): parameters described in @takes | ||
""" | ||
meta = ChoiceMeta("meta", params.description, []) | ||
self.create_attribute(meta, params.pv, rbv=params.rbv, | ||
rbv_suff=params.rbv_suff) | ||
|
||
def get_datatype(self): | ||
return catools.DBR_ENUM |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import numpy as np | ||
from cothread import catools | ||
|
||
from malcolm.parts.ca.capart import CAPart | ||
from malcolm.metas.numbermeta import NumberMeta | ||
from malcolm.metas.stringmeta import StringMeta | ||
from malcolm.core.method import takes, returns, REQUIRED | ||
|
||
|
||
class CALongPart(CAPart): | ||
""" Defines a part which connects to a pv via channel access DBR_LONG""" | ||
|
||
@takes( | ||
StringMeta("name", "name of created attribute"), REQUIRED, | ||
StringMeta("description", "desc of created attribute"), REQUIRED, | ||
StringMeta("pv", "full pv of demand and default for rbv"), REQUIRED, | ||
StringMeta("rbv", "override for rbv"), None, | ||
StringMeta("rbv_suff", "set rbv ro pv + rbv_suff"), None, | ||
) | ||
def setup(self, params): | ||
""" setup is called by the base class Part.__init__ via self.Method. | ||
self.Method is defined by the @takes decorator above. | ||
It defines an attribute to publish the pv | ||
Args: | ||
params(Map): parameters described in @takes | ||
""" | ||
meta = NumberMeta("meta", params.description, np.int32) | ||
self.create_attribute(meta, params.pv, rbv=params.rbv, | ||
rbv_suff=params.rbv_suff) | ||
|
||
def get_datatype(self): | ||
return catools.DBR_LONG |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import cothread | ||
from cothread import catools | ||
|
||
from malcolm.parts.ca.capart import CAPart | ||
from malcolm.metas.stringmeta import StringMeta | ||
from malcolm.core.method import takes, REQUIRED | ||
|
||
|
||
class CAStringPart(CAPart): | ||
"""Defines a part which connects to a pv via channel access DBR_STRING""" | ||
|
||
@takes( | ||
StringMeta("name", "name of created attribute"), REQUIRED, | ||
StringMeta("description", "desc of created attribute"), REQUIRED, | ||
StringMeta("pv", "full pv of demand and default for rbv"), REQUIRED, | ||
StringMeta("rbv", "override for rbv"), None, | ||
StringMeta("rbv_suff", "set rbv ro pv + rbv_suff"), None, | ||
) | ||
def setup(self, params): | ||
""" setup is called by the base class Part.__init__ via self.Method. | ||
self.Method is defined by the @takes decorator above. | ||
It defines an attribute to publish the pv | ||
Args: | ||
params(Map): parameters described in @takes | ||
""" | ||
meta = StringMeta("meta", params.description) | ||
self.create_attribute(meta, params.pv, rbv=params.rbv, | ||
rbv_suff=params.rbv_suff) | ||
|
||
def get_datatype(self): | ||
return catools.DBR_CHAR_STR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,28 @@ | ||
import os | ||
import sys | ||
|
||
sys.path.append(os.path.join(os.path.dirname(__file__), "..", "..")) | ||
import setup_malcolm_paths | ||
|
||
from cothread import catools | ||
from malcolm.parts.ca.cadoublepart import CADoublePart | ||
|
||
import unittest | ||
from mock import Mock, patch, ANY | ||
|
||
|
||
class TestCADoublePart(unittest.TestCase): | ||
|
||
def test_init(self): | ||
CADoublePart.create_attribute = Mock() | ||
# reading yaml will result in a dictionary such as:- | ||
exposure_pv={"name": "exposure", | ||
"description": "shutter time", | ||
"pv": "BL00I-EA-DET-01:AcquireTime", | ||
"rbv_suff": "_RBV"} | ||
p = CADoublePart("exp", Mock(), Mock(), exposure_pv) | ||
|
||
# TODO: add above exposure_pv params | ||
p.create_attribute.assert_called_once_with(ANY, | ||
"BL00I-EA-DET-01:AcquireTime", rbv=None, rbv_suff='_RBV') | ||
CADoublePart.create_attribute = Mock() | ||
# reading yaml will result in a dictionary such as:- | ||
d = {"name": "pv", | ||
"description": "a test pv", | ||
"pv": "Prefix:Suffix", | ||
"rbv_suff": "_RBV"} | ||
p = CADoublePart("part", Mock(), Mock(), d) | ||
|
||
p.create_attribute.assert_called_once_with(ANY, | ||
"Prefix:Suffix", rbv=None, | ||
rbv_suff='_RBV') | ||
if __name__ == "__main__": | ||
unittest.main(verbosity=2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import os | ||
import sys | ||
|
||
sys.path.append(os.path.join(os.path.dirname(__file__), "..", "..")) | ||
import setup_malcolm_paths | ||
|
||
from cothread import catools | ||
from malcolm.parts.ca.calongpart import CALongPart | ||
|
||
import unittest | ||
from mock import Mock, patch, ANY | ||
|
||
|
||
class TestCALongPart(unittest.TestCase): | ||
def test_init(self): | ||
CALongPart.create_attribute = Mock() | ||
# reading yaml will result in a dictionary such as:- | ||
d = {"name": "pv", | ||
"description": "a test pv", | ||
"pv": "Prefix:Suffix", | ||
"rbv_suff": "_RBV"} | ||
p = CALongPart("part", Mock(), Mock(), d) | ||
|
||
p.create_attribute.assert_called_once_with(ANY, | ||
"Prefix:Suffix", rbv=None, | ||
rbv_suff='_RBV') | ||
|
||
self.assertEqual(p.get_datatype(), catools.DBR_LONG) | ||
|
||
if __name__ == "__main__": | ||
unittest.main(verbosity=2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import os | ||
import sys | ||
sys.path.append(os.path.join(os.path.dirname(__file__), "..", "..")) | ||
import setup_malcolm_paths | ||
|
||
from cothread import catools | ||
from malcolm.parts.ca.cachoicepart import CAChoicePart | ||
|
||
import unittest | ||
from mock import Mock, patch, ANY | ||
|
||
|
||
class TestCAChoicePart(unittest.TestCase): | ||
|
||
def test_init(self): | ||
CAChoicePart.create_attribute = Mock() | ||
# reading yaml will result in a dictionary such as:- | ||
d = {"name": "pv", | ||
"description": "a test pv", | ||
"pv": "Prefix:Suffix", | ||
"rbv_suff": "_RBV"} | ||
p = CAChoicePart("part", Mock(), Mock(), d) | ||
|
||
p.create_attribute.assert_called_once_with(ANY, | ||
"Prefix:Suffix", rbv=None, | ||
rbv_suff='_RBV') | ||
|
||
self.assertEqual(p.get_datatype(), catools.DBR_ENUM) | ||
|
||
if __name__ == "__main__": | ||
unittest.main(verbosity=2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import os | ||
import sys | ||
|
||
sys.path.append(os.path.join(os.path.dirname(__file__), "..", "..")) | ||
import setup_malcolm_paths | ||
|
||
from cothread import catools | ||
from malcolm.parts.ca.castringpart import CAStringPart | ||
from malcolm.metas.stringmeta import StringMeta | ||
|
||
import unittest | ||
from mock import Mock, patch, ANY | ||
|
||
|
||
class TestCAStringPart(unittest.TestCase): | ||
def test_init(self): | ||
CAStringPart.create_attribute = Mock() | ||
# reading yaml will result in a dictionary such as:- | ||
d = {"name": "pv", | ||
"description": "a test pv", | ||
"pv": "Prefix:Suffix", | ||
"rbv_suff": "_RBV"} | ||
p = CAStringPart("part", Mock(), Mock(), d) | ||
|
||
p.create_attribute.assert_called_once_with(ANY, | ||
"Prefix:Suffix", rbv=None, | ||
rbv_suff='_RBV') | ||
self.assertEqual(p.get_datatype(), catools.DBR_CHAR_STR) | ||
|
||
if __name__ == "__main__": | ||
unittest.main(verbosity=2) |