Author Topic: Revision to setnet.py -- setnetByName.py  (Read 1082 times)

Offline Steve Gase

  • Sr. Member
  • ****
  • Posts: 2915
    • WinterLightShow in Georgetown, TX
Revision to setnet.py -- setnetByName.py
« on: December 13, 2011, »
With praise to frankr for solving the problem for LSP to xLights imports with his setnet.py file, I found that it was not working the way that I wished.  So, I am including a new script almost entirely lifting Frank's original. 

This script, instead of using the position of a channel definition in the xml sequence file instead looks at the name of the channel, and usings a partial string match to associate the network.

This is important (to me) because when I change my controller and channel definitions to add new features or trim elements that I am not using, I won't need to find the channel(s) new position in the file.  Instead, I rely on the name of the channel to associate the element back to the network.

It requires that you assign names to all of your channels, but this isn't too bad, even with a large number of channels.  You might assocate all channels with the network number... I chose names of the elements (mega01 is the first SSC string in my mega tree).  The matches are case-sensitive, and the substrings MUST match the first character in the channel name.

If you don't have a matching entry in your table, the network number will be assigned "999".  This makes it easier to find them with a text editor... the usual fix(es) in this situation is to add a missing channel name in LSP, or add a missing substring in the python script.

This is my first Python coding, and there might be more elegant methods to do what I've done, so be kind. :)

And thanks again, Frank! 
You are not allowed to view links. Register or Login  |  110K channels, 50K lights  |  Nutcracker, Falcon, DLA, HolidayCoro

Offline Steve Gase

  • Sr. Member
  • ****
  • Posts: 2915
    • WinterLightShow in Georgetown, TX
Re: Revision to setnet.py -- setnetByName.py
« Reply #1 on: December 13, 2011, »
Here is an example... and the description of the table values:

# This script works from the name= xml property stored with each
# channel definition in an LOR file.
# repeat this pattern for each network you want to define:
# {'name': 'LeadingSubString,'net':num},
# you can list as many of those pairs between curly braces as you like
# each curly brace set needs to be seperated by a comma and the whole thing
# is within square brackets []
#
# name is a SUBSTRING, it does not need to match the entire name= value for a channel,
# the matches must agree on case, and for the entire length of the SUBSTRING value
# ('mega0' will match 'mega01 #1','mega01 #2','mega02 #1'...  but will NOT match 'mega','mega10', etc.)
# network number is 0-based in xLights, so the first network should start with 0 (not quoted)
# even though xLights displays it as '1' in the network configuration
#
# NOTE: to make it easier to find channels with missing definitions,
# any channel without a matching name pattern is given a net="999" value. 
# Search for the string 'net="999"' using an editor to find channels and
# then add them to the networks[] table below.
# to assign channel names, use the Configure Channel option in LSP. 
# (This can be applied individually or by controller.)
#
# fyi: I now skip any lms file with 'new' at the start of the name to avoid reprocessing of the derived files


networks = [{'name':'mega0', 'net':0},
          {'name':'mega10', 'net':0},
          {'name':'mega11', 'net':0},
          {'name':'mega12', 'net':0},
          {'name':'mega13', 'net':0},
          {'name':'mega14', 'net':0},
          {'name':'mega15', 'net':1},
          {'name':'mega16', 'net':1},
          {'name':'mega17', 'net':1},
          {'name':'mega18', 'net':1},
          {'name':'mega19', 'net':1},
          {'name':'mega20', 'net':1},
          {'name':'mega21', 'net':1},
          {'name':'mega22', 'net':1},
          {'name':'mega23', 'net':1},
          {'name':'mega24', 'net':1},
          {'name':'mega25', 'net':1},
          {'name':'mega26', 'net':1},
          {'name':'mega27', 'net':1},
          {'name':'mega28', 'net':1},
          {'name':'mega29', 'net':2},
          {'name':'mega3', 'net':2},
          {'name':'mega4', 'net':2},
          {'name':'corostar', 'net':1},
          {'name':'Aether', 'net':3},
          {'name':'Coro Top', 'net':3},
          {'name':'Coro Bot', 'net':3},
          {'name':'Front', 'net':4},
          {'name':'Side', 'net':4},
          {'name':'Back', 'net':4},
          {'name':'Tree', 'net':4},
          {'name':'Bush', 'net':4},
          {'name':'Mega', 'net':4},
          {'name':'Spike', 'net':4},
          {'name':'Street', 'net':4},
          {'name':'Penguin', 'net':4},
          {'name':'Snow', 'net':4},
          {'name':'Ridge', 'net':4},
          {'name':'Spiral', 'net':4},
          {'name':'Meteor', 'net':4},
          {'name':'TBD', 'net':4},
          {'name':'BigArch', 'net':5}]
You are not allowed to view links. Register or Login  |  110K channels, 50K lights  |  Nutcracker, Falcon, DLA, HolidayCoro

Offline jeffcoast

  • Sr. Member
  • ****
  • Posts: 318
Re: Revision to setnet.py -- setnetByName.py
« Reply #2 on: December 14, 2011, »
This will be much more helpful. I have some of my controllers with channels I am not using and deleted them from the controllers to make it easier to make changes when I was sequencing. So now I just need to add the controller numbers I assigned to the channel names and I won't have to have different versions of setnet depending on which sequence I am making changes too.
Jeff Cook
Orlando, FL