mdsthin 0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
mdsthin-0.1/LICENSE ADDED
@@ -0,0 +1,8 @@
1
+
2
+ Copyright (c) 2024, Massachusetts Institute of Technology All rights reserved.
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5
+
6
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7
+
8
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
mdsthin-0.1/PKG-INFO ADDED
@@ -0,0 +1,17 @@
1
+ Metadata-Version: 2.1
2
+ Name: mdsthin
3
+ Version: 0.1
4
+ Summary: MDSplus Thin-Client implemented in pure python
5
+ Author-email: Stephen Lane-Walsh <slwalsh@psfc.mit.edu>
6
+ License:
7
+ Copyright (c) 2024, Massachusetts Institute of Technology All rights reserved.
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
14
+
15
+ Requires-Python: >=3.7
16
+ License-File: LICENSE
17
+ Requires-Dist: numpy
mdsthin-0.1/README.md ADDED
@@ -0,0 +1,116 @@
1
+
2
+ # mdsthin - Python MDSplus Thin Client Implementation
3
+
4
+ ## Installation
5
+
6
+ ```sh
7
+ git clone https://github.com/MDSplus/mdsthin.git
8
+ python3 -m pip install -e mdsthin
9
+ ```
10
+
11
+ ## Tests
12
+
13
+ ```sh
14
+ python3 -m mdsthin.test [-v] [--server SERVER] [--cmod]
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ ```py
20
+ import mdsthin
21
+ c = mdsthin.Connection('server')
22
+
23
+
24
+ print(c.get('whoami()').data())
25
+ # username
26
+
27
+ print(c.tcl('show current test'))
28
+ # 123
29
+
30
+ print(c.get('4 + 5').data())
31
+ # 9
32
+
33
+
34
+ c.openTree('test', 123)
35
+
36
+
37
+ y = c.get('SIGNAL_NODE').data()
38
+ x = c.get('dim_of(SIGNAL_NODE)').data()
39
+
40
+
41
+ gm = c.getMany()
42
+ gm.append('y', 'SIGNAL_NODE')
43
+ gm.append('x', 'dim_of(SIGNAL_NODE)')
44
+ gm.execute()
45
+
46
+ y = gm.get('y').data()
47
+ x = gm.get('x').data()
48
+
49
+
50
+ print(c.getObject('ACTION_NODE').data())
51
+ # Action(...)
52
+
53
+
54
+ # Build_Signal(1000. * $VALUE, Word_Unsigned([1,2,3,4,5]), [0QU,10QU,20QU,30QU,40QU])
55
+ Signal(MULTIPLY(Float32(1000.0), dVALUE()), UInt16Array([1, 2, 3, 4, 5]), UInt64Array([0, 10, 20, 30, 40]))
56
+
57
+ ```
58
+
59
+ ## Examples
60
+
61
+ See the `examples/` folder.
62
+
63
+ ## mdstcl
64
+
65
+ ```
66
+ python3 -m mdsthin.mdstcl SERVER
67
+ Connectiong to: SERVER
68
+ TCL> show current test
69
+ 123
70
+ TCL> exit
71
+ ```
72
+
73
+ ```py
74
+ import mdsthin
75
+ c = mdsthin.Connection('server')
76
+
77
+ c.mdstcl()
78
+ TCL> show current test
79
+ 123
80
+ TCL> exit
81
+ ```
82
+
83
+ ## tdic
84
+
85
+ ```
86
+ python3 -m mdsthin.tdic SERVER
87
+ Connectiong to: SERVER
88
+ TDI> 4 + 5
89
+ 9L
90
+ TDI> exit
91
+ ```
92
+
93
+ ```py
94
+ import mdsthin
95
+ c = mdsthin.Connection('server')
96
+
97
+ c.tdic()
98
+ Connectiong to: SERVER
99
+ TDI> 4 + 5
100
+ 9L
101
+ TDI> exit
102
+ ```
103
+
104
+ ## Compatability with full MDSplus python package
105
+
106
+ There is a subpackage called `MDSplus` that provides slightly better mappings with the full MDSplus python package.
107
+
108
+ ```py
109
+ from mdsthin import MDSplus
110
+
111
+ c = MDSplus.Connection('server')
112
+
113
+ i = Uint32(42)
114
+
115
+ MDSplus.mdsExceptions.checkStatus(265388200)
116
+ ```
@@ -0,0 +1,68 @@
1
+ #
2
+ # Copyright (c) 2024, Massachusetts Institute of Technology All rights reserved.
3
+ #
4
+ # Redistribution and use in source and binary forms, with or without
5
+ # modification, are permitted provided that the following conditions are met:
6
+ #
7
+ # Redistributions of source code must retain the above copyright notice, this
8
+ # list of conditions and the following disclaimer.
9
+ #
10
+ # Redistributions in binary form must reproduce the above copyright notice, this
11
+ # list of conditions and the following disclaimer in the documentation and/or
12
+ # other materials provided with the distribution.
13
+ #
14
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17
+ # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
18
+ # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19
+ # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
21
+ # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22
+ # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
+ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ #
25
+
26
+ #
27
+ # This package provdes a "best effort" approach to adding compatability with the real MDSplus Python package
28
+ # Several classes are similar but with different names, others are missing entirely. So we map what we can,
29
+ # and can provide additional compatability mapping in the future
30
+ #
31
+
32
+ from ..connection import Connection, GetMany, PutMany
33
+
34
+ from ..descriptors import String, StringArray
35
+ from ..descriptors import Int8, Int16, Int32, Int64, Int8Array, Int16Array, Int32Array, Int64Array
36
+ from ..descriptors import List, Dictionary
37
+ from ..descriptors import Signal, Dimension, Window, Slope, Function, Conglom, Range, Action, Dispatch
38
+ from ..descriptors import Program, Routine, Procedure, Method, Dependency, Condition, WithUnits, Call, WithError
39
+ from ..functions import *
40
+
41
+ # Compatability
42
+
43
+ from ..descriptors import Descriptor as Data
44
+ from ..descriptors import Descriptor as DescriptorNULL
45
+ from ..descriptors import Descriptor as EmptyData
46
+
47
+ from ..descriptors import UInt8 as Uint8
48
+ from ..descriptors import UInt16 as Uint16
49
+ from ..descriptors import UInt32 as Uint32
50
+ from ..descriptors import UInt64 as Uint64
51
+
52
+ from ..descriptors import UInt8Array as Uint8Array
53
+ from ..descriptors import UInt16Array as Uint16Array
54
+ from ..descriptors import UInt32Array as Uint32Array
55
+ from ..descriptors import UInt64Array as Uint64Array
56
+
57
+ from .. import exceptions as mdsExceptions
58
+
59
+ mdsExceptions.statusToException = mdsExceptions.getException
60
+
61
+ def checkStatus(status, ignore=tuple(), message=None):
62
+ # TODO: message
63
+ if mdsExceptions.STATUS_NOT_OK(status):
64
+ exception = mdsExceptions.getException(status)
65
+ if isinstance(exception, ignore):
66
+ print(exception)
67
+ else:
68
+ raise exception
@@ -0,0 +1,29 @@
1
+ #
2
+ # Copyright (c) 2024, Massachusetts Institute of Technology All rights reserved.
3
+ #
4
+ # Redistribution and use in source and binary forms, with or without
5
+ # modification, are permitted provided that the following conditions are met:
6
+ #
7
+ # Redistributions of source code must retain the above copyright notice, this
8
+ # list of conditions and the following disclaimer.
9
+ #
10
+ # Redistributions in binary form must reproduce the above copyright notice, this
11
+ # list of conditions and the following disclaimer in the documentation and/or
12
+ # other materials provided with the distribution.
13
+ #
14
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17
+ # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
18
+ # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19
+ # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
21
+ # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22
+ # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
+ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ #
25
+
26
+ from .connection import *
27
+ from .descriptors import *
28
+ from .exceptions import *
29
+ from .functions import *