From 9ec92eaba6839d1bf111baa100eab21f5f39a5b6 Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Thu, 30 Jun 2022 20:13:30 +0100 Subject: [PATCH] 2022-06-30 snapshot. commit 317b9ecf1db6e01035334e95ccb7ab85e9b96683 Author: Craig Oates Date: Thu Jun 30 20:10:28 2022 +0100 fix typo's and minor edits README.md. commit f2b17da0c2dfda81527b69bc28dbb4926a73164c Author: Craig Oates Date: Thu Jun 30 20:02:09 2022 +0100 add .stl models of (3D printable) enclosure. If you have the means, you can use these .stl files to 3D print an enclosure for the Raspberry Pi and the circuitry connected to it. These models where used for the exhibition. commit ac90de7fe4b6bd13e162234fc7d76dd797685457 Author: Craig Oates Date: Tue Jun 28 04:36:07 2022 +0100 add outer-shell-top-001.stl (test). commit 3247b1d62016d56c28ac3dc96178ef6c9ba67ad8 Author: Craig Oates Date: Fri Nov 5 18:08:10 2021 +0000 update README. commit de3573cd2188a115d4f10ea0ac4205213e89aac3 Author: gallery1 Date: Thu Apr 8 14:57:29 2021 +0100 increase light threshold to 39 in gallery1. I, commented out print statements and changed formating out print strings -- they were used for testing. Having ran the relays for a sustained period of time. It became apparent, the threshold for the light levels in gallery1 was too low. What ended up happening was the light would remain on for long periods of time through out the day but the light levels (Light Wave and Eyes and Ears) would show no welding was occuring. What made this a little tricky to pick it apart, though, was some days the light levels would rest at 38 and others at 39. Because it fluctuates, I couldn't tell if gallery1 would miss some 'welding triggers'. I decided to increase it to 39 in the end because the charts produced by Light Wave suggests the change in light brought on by the welding increases the light levels by at least 2 -- most of the time. So, by increasing the threshold to 39, the light levels must pass it which means the light level must now hit 40+ effectively (not worrying about decimal values). This is still reachable on days when the natural light level is at 38. The tradeoff is the system might miss the very short welding bursts but the charts produced by Light Wave suggests they are too rare to interfere with the intended effect/outcome of the system in a significant way. I say all this but I wouldn't be surprised if I backtrack on everything I said here in a future commit. commit 723f053a86f13b0269ae01f218137f8543b327d0 Author: gallery2 Date: Mon Feb 1 14:21:46 2021 +0000 seperate light reading conditions for each relay. With both Light-Meters installed in Ritheron, it is now apparent, each booth has different levels on light in them. This means each Relay (linked to its factory counterpart) needs to adjust to match. The branching logic is implemented in a sloppy way here so it will need to be refactored at some point but this is just a quick change to test the code. commit a64d796a79f7d61c1f3bf0dc25ca04d94ceb7a19 Author: gallery2 Date: Mon Feb 1 14:12:00 2021 +0000 add timeout exception handling. At the time of writing, I would find the relay.service wouldn't crash so it couldn't be restarted. Instead, it would hang and I think it's to do with the HTTP request not timing out properly. I can't confirm this yet so I've added in an exception case to help with monitoring the issue. This is a 'work-in-progress' commit. commit 116ae5cada0a29b54c642a6b05b09a5520c73f54 Author: gallery2 Date: Tue Jan 26 15:29:32 2021 +0000 re-comment out print statement (testing print statement). commit 4bcaab53f64609fd08b102919c1282361abc0e73 Author: gallery2 Date: Tue Jan 26 15:18:07 2021 +0000 create a Systemd service file. This is so the program can run unattended. It is a move away from the '@reboot' cronjob used previously. Note this will need to be copied into the appropriate loction of the system if you have just cloned the repository. Search for Systemd docuementation on the interwebs or in the repositories README (hopefully it's been added after this commmit). commit 3a28c3b001e998d1b025829ef6798f38c8632ce7 Author: gallery2 Date: Tue Jan 26 14:50:44 2021 +0000 remove 60 sec. delay at startup and add add new (cli) exception message. The removal of the delay is in preparation of moving the program to a Systemd service -- instead of a '@reboot' cronjob. By doing that, the need to wait for the network stack on the Raspberry Pi to start is a built-in feature. The change to Systemd is becuase the program would terminate when it hits the 'max. requests exceeded' exception in the 'requests' module (Python). Having spoke to Nic (lead artist), she has stated she has a preference for the program to be requesting the latest light readings or nothing at all. The 'backoff' features which come with the 'requests' module will stop the program from crashing but at the possibility of the having the Relays be out-of-sync -- whilst still looking like it's working -- with the latest light readings produced by the Light Meters in the factory and what's been delivered to the server (Midpoint). To be fair, this problem only arose when I ran the two gallery Relays, one Light Meter and one instance of Eyes and Ears from the same location (my flat). This wouldn't be the case in the when the exhibiton is live. Either way, Systemd it is. The natural process of waiting for the program to restart (with added delay in Systemd service file if wanted) naturally allows the system to 'backoff' but it keeps the all-or-nothing aspect Nic prefers. The exception message is a minor change. It's there just to make it easier to determine if the program is terminating because of the 'max. requests exceeded' exception. I added it to the generic exception for ease more than anything else. I can catch other exceptions whilst expecting the 'max. requests' one. This is not the best approach to programming but the trade-off between project goals and budget make me think this is ok (for now). It is what it is. commit 92cbbe1d2fa2a4f72f8c33733ecb40a8aee973f6 Author: Craig Oates Date: Mon Jan 11 10:48:33 2021 +0000 change condition of light levels to switch on greater than 48. The light meter readings changed when new a Light Meter (factory2) was installed (new components). The change produces different light levels (don't know why but probably different components). This change accounts for the new levels and the light which is controlled by this code now turns on when it receives a reading greater than 48. This seems to be the baseline light level in the welding booth (in Ritherdon, the factory) -- after monitoring the readings for a period of time. commit deb17a061bab5c79ffda4744d452bdcb6067900a Author: Craig Oates Date: Fri Jan 8 20:02:24 2021 +0000 correct URL used for RESTAPI calls. The URL before was for adding a light reading -- not getting a reading. This URL change fixes that. This is what happens when you copy-and-paste code from the Light Meter project into this one. commit 564ee5d938401df45c30c0107e4c04a1e162f8e4 Author: Craig Oates Date: Fri Jan 8 19:55:42 2021 +0000 import platform module. The module is used to help determine which device is running the program. The device name allows the rest of the system to know what this device needs when I makes it RESTAPI calls. commit 37843eb3b56441112feea8520fd6de58513d023c Author: Craig Oates Date: Fri Jan 8 19:53:14 2021 +0000 add call to get device Id. Adds a line of code which gets and stores the device's Id. Which is then used to determine which URL to use for the RESTAPI. commit eceb05ff558ccbfb32b3ec3b589d6064cd54aabe Author: Craig Oates Date: Fri Jan 8 19:48:19 2021 +0000 fix device name checks. The device/host names for the devices running this program should be using 'galleryX' ('X' denotes the device number). I put 'factory' instead of gallery because I'm an idiot. 'factory' are the device names for the Light Meter project. commit 59cab50a3265deb044ba860405974832c676a0a2 Author: Craig Oates Date: Fri Jan 8 19:45:57 2021 +0000 update how URL is formed (RESTAPI call). This adds a check to determine which relay the system is (hostname/device name). When name is determined,the URL the program will use for the RESTAPI call is then set. At the time of writing, the system is expecting two relays. Hence the if-else statement. If more devices are to be added, this approach will need to be reconsidered. commit f95ac677d65d833e8b4073aa6e639efa12dfeacd Author: rtrp@gallery1 Date: Fri Nov 27 18:29:54 2020 +0000 update URL for RestAPI calls. The API calls now go to rither.abbether.net instead of the designated IP address assigned the server (AWS). This change makes it easier to access the RestAPI (see midpoint repo.) server. The URL will remain constant and if the server needs to be powered-down/restarted for anything, the new IP address Amazon (web services) assigns to it will no longer matter. And, the code used to make the RestAPI call will no longer need changing manually. commit 6da8436227b9578881c5f191b94e057d6145e57a Author: Craig Oates Date: Sun Jan 12 23:37:41 2020 +0000 port startup and shutdown scripts from Light-Meter repo. commit bb32709f5d10f9afe6466de3196d6408209bfcfe Author: Craig Oates Date: Sun Jan 12 23:19:02 2020 +0000 remove old code from relay.py. commit dfe6554d6f2d1678a8e16cfde072df3c327a1a51 Author: Craig Date: Sun Jan 5 20:31:51 2020 +0000 port over code from test project. --- README.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index e0d9814..934e4ff 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,13 @@ # Return to Ritherdon: Relay -Relay is a Python 3 based project for controlling a set of lights via -relay switches -- based on the light meter readings made available via -the 'Midpoint' project. Relay is one of three project which combine to -make the 'Personal Flash in Real-Time' artwork with is one of several -artworks created as part of the 'Return to Ritherdon' project. For -more information on this repository and 'Return to Ritherdon', please -the links below: +Relay is a Python 3 based project for controlling a set of lights via relay +switches. The controlling of said lights is based on the light meter readings +made available via the combination of the 'Light Meter' and 'Midpoint' projects +(use the 'Overview' link below). Relay is one of three project which combine to +make the 'Personal Flash in Real-Time' artwork which is one of several artworks +created as part of the 'Return to Ritherdon' project. For more information on +this repository and 'Return to Ritherdon' in general, please use the links +below: - [Return to Ritherdon Overview](https://git.abbether.net/return-to-ritherdon/rtr-docs) - [Relay Documentaion](https://git.abbether.net/return-to-ritherdon/rtr-docs/src/branch/master/relay/rtr-relay.md)