fix_gen.py 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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("======", "{}_{} {:02}".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. print("====================================")
  34. rdata='{"DMX": 1, "UNIVERS": 2, "NAME": "VPU_01", "TYPE": "MOVER", "VENDOR": "AYERTON", "ATTRIBUT":{}}'
  35. jdata = json.loads(rdata,object_pairs_hook=OrderedDict)
  36. jdata["NAME"] = "{}_{}{:02}".format( name,fix,sub)
  37. jdata["NAME"] = "{}_{}".format( name,fix)#,sub)
  38. nr=1
  39. jdata["UNIVERS"] = univ
  40. jdata["DMX"] = dmx
  41. att = []
  42. #att.append("PAN")
  43. #att.append("PAN-FINE")
  44. #att.append("TITL")
  45. #att.append("TILT-FINE")
  46. #att.append("")
  47. #att.append("SHUTTER")
  48. #att.append("DIM")
  49. #att.append("ZOOM")
  50. #att.append("GOBO")
  51. #att.append("")
  52. #att.append("GOBO2")
  53. #att.append("G-ROT")
  54. #att.append("")
  55. #att.append("PRISMA")
  56. #att.append("P-ROT")
  57. #att.append("")
  58. #att.append("")
  59. att.append("DIM")
  60. att.append("RED")
  61. att.append("GREEN")
  62. att.append("BLUE")
  63. add(jdata,att)
  64. fnr="{}{:02}".format(fix,sub)
  65. f_out.write("{}\t{}\t{}\n".format(fnr,fnr,json.dumps(jdata) ) )
  66. f_out.flush()
  67. rdata='{"DMX": 1, "UNIVERS": 2, "NAME": "SPX7_01", "TYPE": "MOVER", "VENDOR": "JB", "ATTRIBUT":{}}'
  68. jdata = json.loads(rdata,object_pairs_hook=OrderedDict)
  69. if 0:#for i in range(3):
  70. sub+=1
  71. jdata["NAME"] = "{}_{}{:02}".format( name,fix,sub)
  72. dmx+=nr-1
  73. univ=2
  74. nr=1
  75. jdata["UNIVERS"] = univ
  76. jdata["DMX"] = dmx
  77. att = []
  78. att.append("RED")
  79. att.append("GREEN")
  80. att.append("BLUE")
  81. att.append("WHITE")
  82. add(jdata,att)
  83. fnr="{}{:02}".format(fix,sub)
  84. f_out.write("{}\t{}\t{}\n".format(fnr,fnr,json.dumps(jdata) ) )
  85. f_out.flush()
  86. fix += 1
  87. sub=1
  88. dmx+=nr-1