Author Topic: LSP to LOR replace intensity script  (Read 1169 times)

Offline sielbear

  • Sr. Member
  • ****
  • Posts: 214
LSP to LOR replace intensity script
« on: November 01, 2011, »
Several folks are using xlights as the playback for pixelnet currently as the playback is MUCH smoother. One of the issues is that the current build of LSP exports LOR S2 files with startIntensity, endIntensity, and Intensity values of 1 instead of 0 like they should read. This means that people are having to edit the files manually - not a big deal, but when you're pressed for time, let's speed things up.

I've created a powershell script that will search for startIntensity="1", endIntensity="1", and Intensity="1" and replace those lines of text with appropriate files. The script will search ALL files and subdirectories of c:\xlights. Any text file in this folder or subfolders will get the treatment. I cannot take credit for the code as I modified it from here:

You are not allowed to view links. Register or Login

Download the text file. Change the name to replaceintensity.ps1. If you've never used powershell, you'll likely need to open it as administrator and type:
set-executionpolicy unrestricted

To execute the script, you can open a command prompt and type powershell replaceintensity.ps1. This will kick off the script. You can also open powershell ISE and load the file that way.

I've uploaded a .txt file - simply download and rename to .ps1.

Alternatively, you can make your own PS1 file, copy the contents into a text file or powershell ISE and save as filename.ps1:


function ReplaceIntensity($fileInfo)
{
if( $_.GetType().Name -ne 'FileInfo')
{
# i.e. reject DirectoryInfo and other types
return
}
$old = 'intensity="1"'
$new = 'intensity="0"'
(Get-Content $fileInfo.FullName) | % {$_ -replace $old, $new} | Set-Content -path $fileInfo.FullName
"Processed: " + $fileInfo.FullName
}

function ReplaceStartIntensity($fileInfo)
{
if( $_.GetType().Name -ne 'FileInfo')
{
# i.e. reject DirectoryInfo and other types
return
}
$old = 'startIntensity="1"'
$new = 'startIntensity="0"'
(Get-Content $fileInfo.FullName) | % {$_ -replace $old, $new} | Set-Content -path $fileInfo.FullName
"Processed: " + $fileInfo.FullName
}

function ReplaceEndIntensity($fileInfo)
{
if( $_.GetType().Name -ne 'FileInfo')
{
# i.e. reject DirectoryInfo and other types
return
}
$old = 'endIntensity="1"'
$new = 'endIntensity="0"'
(Get-Content $fileInfo.FullName) | % {$_ -replace $old, $new} | Set-Content -path $fileInfo.FullName
"Processed: " + $fileInfo.FullName
}


$loc = 'c:\xlights'
cd $loc
$files = Get-ChildItem . -recurse

$files | % { ReplaceIntensity( $_ ) }
$files | % { ReplaceStartIntensity( $_ ) }
$files | % { ReplaceEndIntensity( $_ ) }

Offline keitha43

  • Sr. Member
  • ****
  • Posts: 1182
Re: LSP to LOR replace intensity script
« Reply #1 on: November 02, 2011, »
Where do you download powershell for win7?

Offline Steve Gase

  • Sr. Member
  • ****
  • Posts: 2915
    • WinterLightShow in Georgetown, TX
Re: LSP to LOR replace intensity script
« Reply #2 on: November 02, 2011, »
If you google "download powershell windows 7" you'll get some returns... one is a blog that reads:

Quote
A while back, Microsoft announced the release of PowerShell v2 for Windows XP, Windows Server 2003, Windows Vista, and Windows Server 2008 (see You are not allowed to view links. Register or Login).

However, it is not clear to everyone that Powershell v2 is already part of Windows 7 and Windows Server 2008 R2.

I have seen people still asking for the link for PowerShell v2 for Windows 7 and Windows Server 2008 R2. Such download does not exist, since the PowerShell included in the OS is already v2.

Part of this confusion may be due to the fact that the folder in Windows 7 is still called "C:\windows\System32\WindowsPowerShell\v1.0". Maybe it's the fact that we still use the "PS1" file extension. Maybe it's the fact that the file version number for PowerShell.exe is actually "6.1.7600".
You are not allowed to view links. Register or Login  |  110K channels, 50K lights  |  Nutcracker, Falcon, DLA, HolidayCoro

Offline sielbear

  • Sr. Member
  • ****
  • Posts: 214
Re: LSP to LOR replace intensity script
« Reply #3 on: November 02, 2011, »
Yes- that post is correct. Powershell comes installed under win7. Click start and search powershell or ise depending on what you want to open.

Powershell is a windows update for xp.

Offline mmulvenna

  • Patron Member
  • Sr. Member
  • ****
  • Posts: 231
Re: LSP to LOR replace intensity script
« Reply #4 on: November 02, 2011, »
Thanks for posting the script. Great ideas for other things also, thanks for the tip

That was a reported and tested bug by the beta testers and will be included in the next release (hopefully this week) of LSP.
« Last Edit: November 02, 2011, by mmulvenna »
Thanks
Mike

Offline taybrynn

  • Sr. Member
  • ****
  • Posts: 2042
    • RockinChristmas
Re: LSP to LOR replace intensity script
« Reply #5 on: November 03, 2011, »
This is sweet ... I think it could also be modified to fix the Circuit #'s in a .lms file to convert circuit#'s
from the 1->512 range to the 1->4096 (or higher) pixelnet range ... using Network and Unit#.

A really quick version could just use Unit# and do a new circuit#=(unit#-1)*512 + circuit# ... which would
just allow you to specify DMX universe in the Unit# and then it would use the circuit# (1-512) you already assigned
in LOR S3.
Scott - Castle Rock, Colorado   [ 2 homes, 100% RGB in 2016; since 2008; over 32k channels of E1.31 ]
You are not allowed to view links. Register or Login

Offline sielbear

  • Sr. Member
  • ****
  • Posts: 214
Re: LSP to LOR replace intensity script
« Reply #6 on: November 03, 2011, »
I don't know completely how the circuit numbers are calculated - I see your forumla.  I've not had any issues with the native numbering, but if you'll give me a little more info, I'll be happy to try and code something up!

Offline dmoore

  • Sr. Member
  • ****
  • Posts: 225
Re: LSP to LOR replace intensity script
« Reply #7 on: December 01, 2011, »
This problem with export of "1" for intensity appers to be resolved in the latest revision of LSP - 2.0.11317.1750