def pyvcpLedTableRow(num, baseName, widg, Size, onColor, offColor):
thisDIname = baseName + "{:03d}".format(num) + "-" + widg
#
mystr ="\t\t\t\n\t\t\t\t\""
mystr = mystr + thisDIname
mystr = mystr + "\"\n\t\t\t\t"
mystr = mystr + str (Size)
mystr = mystr + "\n\t\t\t\t\""
mystr = mystr + onColor
mystr = mystr + "\"\n\t\t\t\t\""
mystr = mystr + offColor
mystr = mystr + "\"\n\t\t\t\n"
#
return(mystr)
def pyvcpCheckbuttonTableRow(num, baseName, widg):
# THERE IS NO size param for checkbutton
thisDOname = baseName + "{:03d}".format(num) + "-" + widg
#
mystr ="\t\t\t<"+widg+">\n\t\t\t\t\""
mystr = mystr + thisDOname
mystr = mystr + "\"\n"
mystr = mystr + "\t\t\t"+widg+">\n"
#
return(mystr)
#
def pyvcpS32TableRow(num, baseName, widg, font, format, wide):
# an S32 widget is an int display ( signed but will show pos ints ok
thisAIname=baseName
thisAIname = thisAIname + "{:03d}".format(num) + "-" + widg
#
mystr ="\t\t\t<"+widg+">\n\t\t\t\t\""
mystr = mystr + thisAIname
mystr = mystr + "\"\n\t\t\t\t"+font+"\n"
mystr = mystr + "\t\t\t\t\""+format+"\"\n"
mystr = mystr + "\t\t\t\t"+str(wide)+"\n"
mystr = mystr + "\t\t\t"+widg+">\n"
#
return(mystr)
def pyvcpScaleTableRow(num, baseName, widg, font, min, max, orientStrg):
thisAOname=baseName
thisAOname = thisAOname + "{:03d}".format(num) + "-" + widg
#
mystr ="\t\t\t<"+widg+">\n\t\t\t\t\""
mystr = mystr + thisAOname
mystr = mystr + "\"\n\t\t\t\t"+font+"\n"
# there are no size tall wide for vert/horx slider (aka scale)
mystr = mystr + "\t\t\t\t"+str(min)+"\n"
mystr = mystr + "\t\t\t\t"+str(max)+"\n"
mystr = mystr + orientStrg
mystr = mystr + "\t\t\t"+widg+">\n"
#
return(mystr)
# ------------------------------------------------------------------------
# file head
# ------------------------------------------------------------------------
f = open("test01.xml", "w")
f.write("\n")
f.write("\n")
#f.write("\n")
# ------------------------------------------------------------------------
# leds DI
# ------------------------------------------------------------------------
nDI=152 # 2048 allowed
baseName="DI-"
widg="led"
ledSize=25
onColor="green"
offColor="red"
rowWidth = 32 # can pack 32 into 1 pkt and have 64 sets of 32 spec'd in hi 6 bits of cmd
numRows = int(nDI / rowWidth) # 3/5 = 0
if((numRows * rowWidth) < nDI): # true
numRows = numRows + 1 # 1
f.write("\t\n")
for row in range(numRows): # make loop 0...(numRows-1)
f.write("\t\t\n")
for col in range(rowWidth):
widgNum = ( row * rowWidth ) + col
if (widgNum < nDI):
mystr = pyvcpLedTableRow(widgNum, baseName, widg, ledSize, onColor, offColor)
f.write(mystr)
f.write("\t
\n")
# ------------------------------------------------------------------------
# checkbuttons DO
# ------------------------------------------------------------------------
nDO=152 # 2048 allowed
baseName="DO-"
widg="checkbutton"
rowWidth = 32 # can pack 32 into 1 pkt and have 64 sets of 32 spec'd in hi 6 bits of cmd
numRows = int(nDO / rowWidth) # 3/5 = 0
if((numRows * rowWidth) < nDO): # true
numRows = numRows + 1 # 1
f.write("\t\n")
for row in range(numRows): # make loop 0...(numRows-1)
f.write("\t\t\n")
for col in range(rowWidth):
widgNum = ( row * rowWidth ) + col
if (widgNum < nDO):
mystr = pyvcpCheckbuttonTableRow(widgNum, baseName, widg)
f.write(mystr)
f.write("\t
\n")
# ------------------------------------------------------------------------
# s32 display AI
# ------------------------------------------------------------------------
nAI=64 # 256 14 bit (max) values 64 sets of 4 set is inn hi 6 bits of cnd byte byfW[1]
# 2 bits identify which AI in set of 4 in hi 2 bits of budw[2] and [4]
# if last pkt has only 1 AI then 1st chnl is repeated
widg="s32"
baseName="AI-"
font='"Helvetica",11' # 12 roo wide 11 not wide enuf 11 will do maybe a diff dont?
format="6d"
width=6 #16384 max plus sign
rowWidth = 16 # TBD
numRows = int(nAI / rowWidth) # 3/5 = 0
if((numRows * rowWidth) < nAI): # true
numRows = numRows + 1 # 1
f.write("\t\n")
for row in range(numRows): # make loop 0...(numRows-1)
f.write("\t\t\n")
for col in range(rowWidth):
widgNum = ( row * rowWidth ) + col
if (widgNum < nAI):
mystr = pyvcpS32TableRow(widgNum, baseName, widg, font, format, width)
f.write(mystr)
f.write("\t
\n")
# ------------------------------------------------------------------------
# scale slider AO
# AO are Analoog Outputs arduino Uno aint got none
# AO and PO can use same table row writing function
# ------------------------------------------------------------------------
nAO = 64 #14bit data possible leaves 2 bits for id inside one set and 2^6 sets = 257 poss
widg="scale"
baseName="AO-"
font='"Helvetica",8'
# min max up to 16384 range for 14 bit dac while typicl pw, is 0-255
min=-8192
max=8192
orientStrg="\t\t\t\tHORIZONTAL\n"
rowWidth = 8 # 16 is too wide for screen 6 is to tall for screen 12 is ok for cray 256
numRows = int(nAO / rowWidth) # 3/5 = 0
if((numRows * rowWidth) < nAO): # true
numRows = numRows + 1 # 1
f.write("\t\n")
for row in range(numRows): # make loop 0...(numRows-1)
f.write("\t\t\n")
for col in range(rowWidth):
widgNum = ( row * rowWidth ) + col
if (widgNum < nAO):
mystr = pyvcpScaleTableRow(widgNum, baseName, widg, font, min, max, orientStrg)
f.write(mystr)
f.write("\t
\n")
# ------------------------------------------------------------------------
# scale slider PO
# PO are Pwm Outputs
# the PO can use same func as AO ( both can use pyvcp 'scale' to get s32 output pin )
# ------------------------------------------------------------------------
nPO = 64 #14bit data possible leaves 2 bits for id inside one set and 2^6 sets = 257 poss
widg="scale"
baseName="PO-"
font='"Helvetica",8'
# min max up to 16384 range for 14 bit dac while typicl pw, is 0-255
min=-8192
max=8192
orientStrg="\t\t\t\tVERTICAL\n"
rowWidth = 16 # 16 is too wide for screen 6 is to tall for screen 12 is ok for cray 256
numRows = int(nPO / rowWidth) # 3/5 = 0
if((numRows * rowWidth) < nPO): # true
numRows = numRows + 1 # 1
f.write("\t\n")
for row in range(numRows): # make loop 0...(numRows-1)
f.write("\t\t\n")
for col in range(rowWidth):
widgNum = ( row * rowWidth ) + col
if (widgNum < nPO):
mystr = pyvcpScaleTableRow(widgNum, baseName, widg, font, min, max, orientStrg)
f.write(mystr)
f.write("\t
\n")
# ------------------------------------------------------------------------
# file tail
# ------------------------------------------------------------------------
#f.write("\n")
f.write("\n")
f.close()