# import the CCS Scripting interfaces.
from org.lsst.ccs.scripting import CCS;

import sys

CCS.setThrowExceptions(True)

limitHi = 10.0
dbandHi=0.0
subName= ""
nchans = 100

if len(sys.argv) >= 2:
    subName= sys.argv[1]

if len(sys.argv) >= 5:
    nchans = int(sys.argv[2])
    limitHi = float(sys.argv[3])
    dbandHi = float(sys.argv[4])
    
# Create a subsystem wrapper
demo = CCS.attachSubsystem(subName);
    
# Invoke a valid synchronous command
for i in range(nchans):
    demo.synchCommandLine(10,"submitChange DemoChannel"+str(i)+" limitHi "+str(limitHi));
    demo.synchCommandLine(10,"submitChange DemoChannel"+str(i)+" dbandHi "+str(dbandHi));
    
demo.synchCommandLine(10, "commitBulkChange");

print "OK"