Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Formula / Algorithm help?
#1
Question 
Hello,

I took on a project which is now 4,000+ lines of code and reaching completion. The last step of this project is to link the settings with the real world.

Project scope:
Splashpad Controller (water jets / solenoids)
Maximum of 12 relays / solenoids in total
Maximum of 4 buttons / activators / 4 zones

The user can determine how many zones are active, which buttons/activators trigger which zone, how many solenoids are in each zone, and which sequence is being used in each zone. A sequence could be a chase of water jets back and forth (1, 2, 3, 2, 1, 2, 3, 2, 1, 2, ..)

My problem is: I need to figure out a formula which allows the user to feel like they have as much customization as possible yet still limiting the amount of sequences that need to be created. I'm using another 3rd party software which is triggered by MIDI and outputs DMX to our relays.

Once they choose how many relays / solenoids are assigned to each zone..
example:
Zone 1 - 3
Zone 2 - 3
Zone 3 - 4
Zone 4 - 0

I need to then assign relay / solenoid IDs to each zone..
example:
Relays: 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12
Zones: 1 1 1 - 2 2 2 - 3 3 3 3

The amount of combinations here could almost be endless (not what I want). The easiest approach on the coding side seems like just squishing together all the zones and relays (not having gaps in the above example) and letting the user do whatever they want. The problem is I have to create all of the sequences manually in the 3rd party software.

In my 3rd Party DMX Software I have 6 different types of scenes set up for each of the 4 zones. (Chase slow, Chase fast, random, etc...). I then have 12 versions of each of the 6 sequences for all 4 zones (for different solenoid counts). This adds up to 288 possibilities. This already seems like way too much, though there could be more depending on what the user is allowed to do.

Any help with formulas and ideas on how to simplify this, but letting the user feel like they still have freedom, would be much appreciated.

Thank you..

This is my concept for the "easy coding approach" and "most difficult, infinite sequence approach for the 3rd party program".

#!/usr/bin/python3.7

import os

zones_max = 4
solenoids_max = 12
solenoids_zone_0 = 3
solenoids_zone_1 = 4
solenoids_zone_2 = 3
solenoids_zone_3 = 0

os.system("clear")

def start():
    added_up = solenoids_zone_0 + solenoids_zone_1 + solenoids_zone_2 + solenoids_zone_3
    print("TOTAL SOLENOIDS: " + str(added_up))

    if added_up > 12:
        print("TOO MANY SOLENOIDS CONFIGURED")
        return
    if added_up < 1:
        print("NOT ENOUGH SOLENOIDS CONFIGURED")
        return

    solenoid_list = []

    for z in range(zones_max):
        for i in range(int(globals()["solenoids_zone_" + str(z)])):
            print(z)
            solenoid_list.append(z)

    print(solenoid_list)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python “Formula” Package: How do I parse Excel formula with a range of cells? JaneTan 1 2,675 Jul-12-2021, 11:09 AM
Last Post: jefsummers

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020