Skip to content

Commit adc0269

Browse files
authored
Merge branch 'main' into staging
2 parents de4d90e + 3c0c558 commit adc0269

File tree

62 files changed

+748
-788
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+748
-788
lines changed

.github/workflows/pypublish.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# This workflow will upload a Python Package to PyPI when a release is created
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
3+
4+
# This workflow uses actions that are not certified by GitHub.
5+
# They are provided by a third-party and are governed by
6+
# separate terms of service, privacy policy, and support
7+
# documentation.
8+
9+
name: thermoflex
10+
11+
on:
12+
push:
13+
branches:
14+
- main
15+
16+
permissions:
17+
contents: read
18+
19+
jobs:
20+
release-build:
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
- uses: actions/setup-python@v5
27+
with:
28+
python-version: "3.x"
29+
30+
- name: Build release distributions
31+
run: |
32+
cd python-serial/
33+
python -m pip install build
34+
python -m build
35+
36+
- name: Upload distributions
37+
uses: actions/upload-artifact@v4
38+
with:
39+
name: release-dists
40+
path: dist/
41+
42+
pypi-publish:
43+
runs-on: ubuntu-latest
44+
needs:
45+
- release-build
46+
permissions:
47+
# IMPORTANT: this permission is mandatory for trusted publishing
48+
id-token: write
49+
50+
# Dedicated environments with protections for publishing are strongly recommended.
51+
# For more information, see: https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#deployment-protection-rules
52+
environment:
53+
name: pypi
54+
# OPTIONAL: uncomment and update to include your PyPI project URL in the deployment status:
55+
url: https://pypi.org/p/thermoflex/
56+
#
57+
# ALTERNATIVE: if your GitHub Release name is the PyPI project version string
58+
# ALTERNATIVE: exactly, uncomment the following line instead:
59+
# url: https://pypi.org/project/YOURPROJECT/${{ github.event.release.name }}
60+
61+
steps:
62+
- name: Retrieve release distributions
63+
uses: actions/download-artifact@v4
64+
with:
65+
name: release-dists
66+
path: python-serial/dist/
67+
68+
- name: Publish release distributions to PyPI
69+
uses: pypa/gh-action-pypi-publish@release/v1
70+
with:
71+
packages-dir: python-serial/dist/

.github/workflows/testpypublish.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# This workflow will upload a Python Package to PyPI when a release is created
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
3+
4+
# This workflow uses actions that are not certified by GitHub.
5+
# They are provided by a third-party and are governed by
6+
# separate terms of service, privacy policy, and support
7+
# documentation.
8+
9+
name: thermo
10+
11+
on:
12+
push:
13+
branches:
14+
- staging
15+
16+
permissions:
17+
contents: read
18+
19+
jobs:
20+
release-build:
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
- uses: actions/setup-python@v5
27+
with:
28+
python-version: "3.x"
29+
30+
- name: Build release distributions
31+
run: |
32+
cd python-serial/
33+
python -m pip install build
34+
python -m build
35+
36+
- name: Upload distributions
37+
uses: actions/upload-artifact@v4
38+
with:
39+
name: release-dists
40+
path: dist/
41+
42+
testpypi-publish:
43+
runs-on: ubuntu-latest
44+
needs:
45+
- release-build
46+
permissions:
47+
# IMPORTANT: this permission is mandatory for trusted publishing
48+
id-token: write
49+
50+
# Dedicated environments with protections for publishing are strongly recommended.
51+
# For more information, see: https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#deployment-protection-rules
52+
environment:
53+
name: pypi
54+
# OPTIONAL: uncomment and update to include your PyPI project URL in the deployment status:
55+
url: https://pypi.org/p/thermo/
56+
#
57+
# ALTERNATIVE: if your GitHub Release name is the PyPI project version string
58+
# ALTERNATIVE: exactly, uncomment the following line instead:
59+
# url: https://pypi.org/project/YOURPROJECT/${{ github.event.release.name }}
60+
61+
steps:
62+
- name: Retrieve release distributions
63+
uses: actions/download-artifact@v4
64+
with:
65+
name: release-dists
66+
path: python-serial/dist/
67+
68+
- name: Publish release distributions to PyPI
69+
uses: pypa/gh-action-pypi-publish@release/v1
70+
with:
71+
packages-dir: python-serial/dist/

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
test-env/
2+
asus-test-env/
23
ThermoflexSessions/
3-
logdata.*
4+
ExampleSessions/
5+
devtest/
6+
scratch/
7+
communication/
8+
protoc-28.2-win64/
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
DATETIME,DEVICE ID,STATUS TYPE,uptime,errors,volt_supply,pot_values,can_id,firmware,board_ver,muscle_count,log_interval,vrd_scalar,vrd_offset,max_current,min_v_supply,enable_status,control_mode,pwm_out,load_amps,load_voltdrop,load_ohms,SMA_default_mode,SMA_default_setpoint,SMA_rcontrol_kp,SMA_rcontrol_ki,SMA_rcontrol_kd,vld_scalar,vld_offset,r_sns_ohms,amp_gain,af_mohms,delta_mohms,trainstate
2+
11/18/2024 16:53:50.755,66051,status node dump,647,255,3.817204475402832,0.4713541567325592,0,0.0,0.0,2,500,0.05376344174146652,0.0,80.0,7.0,,,,,,,,,,,,,,,,,,
3+
11/18/2024 16:53:51.565,66051,status node compact,648,255,3.826164722442627,0.470703125,,,,,,,,,,,,,,,,,,,,,,,,,,,
4+
11/18/2024 16:53:51.862,66051,status node compact,649,255,3.822580575942993,0.4713541567325592,,,,,,,,,,,,,,,,,,,,,,,,,,,
5+
11/18/2024 16:53:52.461,66051,status node compact,649,255,3.8189964294433594,0.4710286557674408,,,,,,,,,,,,,,,,,,,,,,,,,,,
6+
11/18/2024 16:53:53.658,66051,status node compact,650,255,3.8189964294433594,0.4710286557674408,,,,,,,,,,,,,,,,,,,,,,,,,,,
7+
11/18/2024 16:53:54.260,66051,status node compact,651,255,3.8189964294433594,0.4716796875,,,,,,,,,,,,,,,,,,,,,,,,,,,
8+
11/18/2024 16:53:54.861,66051,status node compact,652,255,3.817204475402832,0.4713541567325592,,,,,,,,,,,,,,,,,,,,,,,,,,,
9+
11/18/2024 16:53:55.462,66051,status node compact,652,255,3.826164722442627,0.4713541567325592,,,,,,,,,,,,,,,,,,,,,,,,,,,
10+
11/18/2024 16:53:56.665,66051,status node compact,653,255,3.817204475402832,0.4720052182674408,,,,,,,,,,,,,,,,,,,,,,,,,,,
11+
11/18/2024 16:53:57.271,66051,status node compact,654,255,3.813620090484619,0.4716796875,,,,,,,,,,,,,,,,,,,,,,,,,,,
12+
11/18/2024 16:53:57.890,66051,status node compact,655,255,3.820788621902466,0.4716796875,,,,,,,,,,,,,,,,,,,,,,,,,,,
13+
11/18/2024 16:53:58.750,66051,status node compact,655,255,3.820788621902466,0.4713541567325592,,,,,,,,,,,,,,,,,,,,,,,,,,,
14+
11/18/2024 16:53:59.677,66051,status node compact,656,255,3.8189964294433594,0.4713541567325592,,,,,,,,,,,,,,,,,,,,,,,,,,,

README.md

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
#### System Requirements
2+
3+
- Python 3.12 or greater
4+
- Pyserial 3.5 or greater
5+
## Introduction
6+
7+
###### The Thermoflex muscle is a current activated artificial muscle that is designed to have a low profile usage and simple activation and deactivation sequence. The purpose of this library is 2-fold; to become the working backend of the Delta hardware application and to allow for open-source development of the Nitinol muscle.
8+
9+
## Download and Installation
10+
11+
12+
To install our software, you can use the pip and package methods
13+
14+
`pip install thermoflex`
15+
16+
or you can install manually by downloading the files from our Github and running the tfsetup.py file. Be sure that you are have the setuptools package installed if you choose to install manually.
17+
18+
( add Github site and link)
19+
20+
## Launch and Use
21+
22+
Import the thermoflex library and use .discover() to find our product.
23+
24+
```python
25+
import thermoflex as tf
26+
27+
netlist = tf.discover()
28+
network1 = netlist[0]
29+
```
30+
31+
This will return a list of NodeNet-objects. Each NodeNet contains a list of Node-objects connected at initialization as well as a broadcast Node and a self Node device. From here you will be able to assign nodes to variables using the .getDevice() command.
32+
33+
``` Python
34+
node0 = network1.node_list[0]
35+
```
36+
37+
You can also assign the broadcast node and self node by calling a NodeNet's .broadcast_node and .self_node.
38+
39+
``` Python
40+
node_b = network1.broadcast_node
41+
node_s = network1.self_node
42+
```
43+
44+
Once you have your connected node bound, you can call its status, reset and logging commands. To use the muscles, you need to create Muscle objects
45+
(see Node Methods*hyperlink)
46+
47+
48+
To create Muscle-class objects, start by calling tf.muscle(). This is where you need input your *idnum*, *resistance*, *length*, and *diameter* values if you have them.
49+
50+
51+
``` Python
52+
muscle1 = tf.muscle(idnum = 0, resist= 300, diam= 2, length= 150)
53+
muscle2 = tf.muscle(idnum = 1, resist= 290, diam= 2, length= 145)
54+
```
55+
56+
Note that the *idnum* field is the only field that is neccesary for creating the Muscle-object.
57+
58+
Next, assign the muscle objects to a node object by calling the .setMuscle() command. This command takes the identification number and the muscle object as arguments
59+
60+
```Python
61+
node0.setMuscle(0, muscle1)
62+
node0.setMuscle(1, muscle2)
63+
```
64+
65+
Sessions are automatically created and create a filesystem that exports to a higher level folder. Sessions track the incoming and outgoing serial data and saves it to a .ses file and a .txt file. The .txt files are generated as plain messages, where as the .ses files have serialized messages.
66+
67+
```Python
68+
sessionl = tf.Session.sessionl
69+
session1 = session[0]
70+
```
71+
72+
73+
74+
| **Program Commands** | **Function** |
75+
| --------------------- | ----------------------------------------------------------------------- |
76+
| discover(*prodid*) | finds connected nodes from the product id (*prodid*) |
77+
| update() | updates all of the networks |
78+
| updatenet(*network*) | updates the *network* |
79+
| delay(*time*) | continuously calls update on all of the networks until *time* is called |
80+
| endsession(*session*) | Ends and deletes the *session* |
81+
| endAll() | Ends and deletes all sessions, nodes, and networks |
82+
83+
| **NodeNet Commands** | **Function** |
84+
| -------------------- | --------------------------------------------------------------------------------------- |
85+
| refreshDevices() | updates the status for all devices on a NodeNet |
86+
| addNode(*nodeid*) | creates a new Node with the given *nodeid* |
87+
| removeNode(*nodeid*) | removes a Node object with *nodeid* from the given NodeNet's internal node list |
88+
| getDevice(*nodeid*) | gets the Node object with *nodeid* and attaches it to the NodeNet |
89+
| openPort() | Opens the port associated with the network, Started upon initialization |
90+
| closePort() | Closes the port associated with the network |
91+
| start_serial() | starts the serial loop for sending and receiving commands. started upon initialization. |
92+
93+
From here, you can add commands to your command buffer. The commands are as follows.
94+
95+
| **Node Commands** | **Function** |
96+
| ------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------- |
97+
| status() | Checks the status of the node and returns its status |
98+
| getStatus() | Returns the latest node status received |
99+
| reset() | Resets at the node level, can be extrapolated to reset the entire network |
100+
| setLogmode(mode) | Sets the logging mode of the node; mode:(0:'none', 1:'compact', 2:'dump', 3:'readable dump') |
101+
| setMode(conmode, device) | Sets the input mode of the node; conmode : (percent, volts, amps, ohms, train); device : (all,node,m1,m2,...,m*n*) |
102+
| setSetpoint(musc, conmode, setpoint) | Sets the point at which the node actuates to; musc: *muscle id number*; conmode : (percent, volts, amps, ohms, train); setpoint : *float* |
103+
| setMuscle(idnum,muscle) | Assigns a muscle to the node; will have presets in the future |
104+
| enable(muscle) | Enables the selected muscle to act on the value set by setSetpoint(); enable : (*muscle object*) |
105+
| enableAll | Enables all connected muscles of the node |
106+
| disable(muscle) | Disables the selected muscle : (m1,m2,...,m*n*) |
107+
| disableAll | Disables all connected muscles of the node |
108+
| update | Sends and receives the packets to "update" the node state |
109+
These commands should be in the format,
110+
111+
```Python
112+
node0.enable(muscle1)
113+
```
114+
115+
The muscle objects also have their own commands that are passed to their commanding node. These commands are as follows.
116+
117+
| **Muscle Command** | **Function** |
118+
| -------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
119+
| changeMusclemos(*mosfetnum*:int) | Manually changes the mosfet number of the selected muscle. The mosfet number is set automatically when the muscle is assigned to a node; |
120+
| setMode(conmode) | Sets the data type that a given muscle receives for its setSetpoint() command; conmode : (percent, volts, amps, ohms, train) |
121+
| setSetpoint(setpoint:float) | Sets the setpoint of the muscle at the node. |
122+
| setEnable(bool) | Sets the enable status of the muscle in the node. |
123+
124+
Developer install instructions
125+
for testing purposes, use the command
126+
```
127+
pip install -e $SRC
128+
```
129+
with $SRC being the path to the python-serial folder. This will install the files as a test library.

0 commit comments

Comments
 (0)