fix_gen.py 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. import json
  2. from collections import OrderedDict
  3. f_out = open("patch.sav","w")
  4. nr=0
  5. dmx=1
  6. def add(jdata,att):
  7. global nr,dmx,name,fix,sub
  8. print("======", "{}_{} {:03}".format( name,fix,sub) )
  9. #for i in jdata:
  10. # print(i )
  11. if "ATTRIBUT" in jdata:
  12. for a in att:
  13. if a == "":
  14. print("---",nr+dmx-1,nr,"")
  15. nr+=1
  16. continue
  17. rdata = '{"NR": 1, "MASTER": "0", "MODE": "S", "VALUE": 0, "ACTIVE": 0, "FX": "", "FX2": {}}'
  18. rdata = '{"NR": 1, "MASTER": "0", "MODE": "S", "VALUE": 0, "ACTIVE": 0, "FX": "", "FX2": {}}'
  19. jattr = json.loads(rdata,object_pairs_hook=OrderedDict)
  20. jattr["NR"] = nr
  21. if a in ["DIM","RED","GREEN","BLUE"]: #,"PAN","TILT","ZOOM","IRIS"]:
  22. jattr["MODE"] = "F"
  23. jdata["ATTRIBUT"][a] = jattr
  24. print("add",nr+dmx-1,nr,a)
  25. nr+=1
  26. print()
  27. fix = 1
  28. sub =1
  29. name="VPU"
  30. dmx=1
  31. univ=2
  32. #for i in range(9*13): # fixtures
  33. #for i in range(8+1*12+1): # fixtures
  34. #for i in range((8*2)+1*(12*2)+1): # fixtures
  35. for i in range(96): # fixtures
  36. print("====================================")
  37. rdata='{"DMX": 1, "UNIVERS": 2, "NAME": "VPU_01", "TYPE": "MOVER", "VENDOR": "AYERTON", "ATTRIBUT":{}}'
  38. jdata = json.loads(rdata,object_pairs_hook=OrderedDict)
  39. jdata["NAME"] = "{}_{}{:02}".format( name,fix,sub)
  40. jdata["NAME"] = "{}_{:03}".format( name,fix)#,sub)
  41. nr=1
  42. jdata["UNIVERS"] = univ
  43. jdata["DMX"] = dmx
  44. att = []
  45. #att.append("PAN")
  46. #att.append("PAN-FINE")
  47. #att.append("TITL")
  48. #att.append("TILT-FINE")
  49. #att.append("")
  50. #att.append("SHUTTER")
  51. #att.append("DIM")
  52. #att.append("ZOOM")
  53. #att.append("GOBO")
  54. #att.append("")
  55. #att.append("GOBO2")
  56. #att.append("G-ROT")
  57. #att.append("")
  58. #att.append("PRISMA")
  59. #att.append("P-ROT")
  60. #att.append("")
  61. #att.append("")
  62. att.append("DIM")
  63. att.append("RED")
  64. att.append("GREEN")
  65. att.append("BLUE")
  66. add(jdata,att)
  67. fnr="{}{:02}".format(fix,sub)
  68. fnr="{}".format(fix,sub)
  69. fnr="{:04}".format(fix,sub)
  70. f_out.write("{}\t{}\t{}\n".format(fnr,fnr,json.dumps(jdata) ) )
  71. f_out.flush()
  72. rdata='{"DMX": 1, "UNIVERS": 2, "NAME": "SPX7_01", "TYPE": "MOVER", "VENDOR": "JB", "ATTRIBUT":{}}'
  73. jdata = json.loads(rdata,object_pairs_hook=OrderedDict)
  74. if 0:#for i in range(3):
  75. sub+=1
  76. jdata["NAME"] = "{}_{:03}{:03}".format( name,fix,sub)
  77. dmx+=nr-1
  78. univ=2
  79. nr=1
  80. jdata["UNIVERS"] = univ
  81. jdata["DMX"] = dmx
  82. att = []
  83. att.append("RED")
  84. att.append("GREEN")
  85. att.append("BLUE")
  86. att.append("WHITE")
  87. add(jdata,att)
  88. fnr="{}{:02}".format(fix,sub)
  89. fnr="{:04}".format(fix,sub)
  90. f_out.write("{}\t{}\t{}\n".format(fnr,fnr,json.dumps(jdata) ) )
  91. f_out.flush()
  92. fix += 1
  93. sub=1
  94. dmx+=nr-1
  95. if dmx >= 512:
  96. univ +=1
  97. dmx = 1