[{"id":"9a152ded.cdff9","type":"tab","label":"Start","disabled":false,"info":""},{"id":"1f55eb2e.158f95","type":"tab","label":"Camera Main","disabled":false,"info":""},{"id":"a946aea5.fe7cb","type":"tab","label":"Smartphone","disabled":false,"info":""},{"id":"2d99e20d.5e48ee","type":"tab","label":"External Cam","disabled":false,"info":""},{"id":"adecba7c.a89278","type":"tab","label":"GPhoto2","disabled":false,"info":""},{"id":"2fb4a0.ab59cb6","type":"tab","label":"RPi Cam","disabled":false,"info":""},{"id":"8f3594bc.ecc048","type":"tab","label":"Settings","disabled":false,"info":""},{"id":"4aee81d.130dd8","type":"tab","label":"Update","disabled":false,"info":""},{"id":"83cc546d.8e6a58","type":"tab","label":"OpenScan Cloud","disabled":false,"info":""},{"id":"e4b4ade8.5763e","type":"subflow","name":"List Files","info":"","in":[{"x":180,"y":80,"wires":[{"id":"5024ed86.4c84c4"}]}],"out":[{"x":680,"y":60,"wires":[{"id":"d0eb6be8.eda228","port":0}]}]},{"id":"449b7301.e9f22c","type":"subflow","name":"FIle Upload (3)","info":"","category":"","in":[],"out":[{"x":840,"y":320,"wires":[{"id":"bd8f9e38.c27a1","port":0}]}],"env":[{"name":"UPLOAD_DIR","type":"str","value":"."}]},{"id":"742aa8b9.f0ccc8","type":"subflow","name":"FIle Upload (3) (2)","info":"","category":"","in":[],"out":[{"x":840,"y":320,"wires":[{"id":"cafcb6ac.9d9c98","port":0}]}],"env":[{"name":"UPLOAD_DIR","type":"str","value":"."}]},{"id":"f15aaf51.f4429","type":"ui_base","theme":{"name":"theme-light","lightTheme":{"default":"#0094CE","baseColor":"#0094CE","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif","edited":true,"reset":false},"darkTheme":{"default":"#097479","baseColor":"#097479","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif","edited":true,"reset":false},"customTheme":{"name":"Untitled Theme 1","default":"#4B7930","baseColor":"#4B7930","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif","reset":false},"themeState":{"base-color":{"default":"#0094CE","value":"#0094CE","edited":false},"page-titlebar-backgroundColor":{"value":"#0094CE","edited":false},"page-backgroundColor":{"value":"#fafafa","edited":false},"page-sidebar-backgroundColor":{"value":"#ffffff","edited":false},"group-textColor":{"value":"#1bbfff","edited":false},"group-borderColor":{"value":"#ffffff","edited":false},"group-backgroundColor":{"value":"#ffffff","edited":false},"widget-textColor":{"value":"#111111","edited":false},"widget-backgroundColor":{"value":"#0094ce","edited":false},"widget-borderColor":{"value":"#ffffff","edited":false},"base-font":{"value":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif"}},"angularTheme":{"primary":"indigo","accents":"blue","warn":"red","background":"grey"}},"site":{"name":"OpenScan Pi","hideToolbar":"false","allowSwipe":"false","lockMenu":"false","allowTempTheme":"true","dateFormat":"DD/MM/YYYY","sizes":{"sx":37,"sy":37,"gx":6,"gy":6,"cx":4,"cy":4,"px":3,"py":3}}},{"id":"c19e2c9e.f4b99","type":"ui_spacer","name":"spacer","group":"","order":8,"width":8,"height":1},{"id":"75afd9cb.6a3ed8","type":"ui_spacer","name":"spacer","group":"","order":2,"width":1,"height":1},{"id":"e49ddca1.744a","type":"ui_spacer","name":"spacer","group":"","order":4,"width":1,"height":1},{"id":"987b4012.f9a07","type":"ui_spacer","name":"spacer","group":"","order":5,"width":6,"height":1},{"id":"caea0d6c.4e75","type":"ui_spacer","name":"spacer","group":"","order":6,"width":1,"height":1},{"id":"3fadc6db.3997ea","type":"ui_spacer","name":"spacer","group":"","order":8,"width":1,"height":1},{"id":"f5864201.8e5ff","type":"ui_spacer","name":"spacer","group":"","order":9,"width":1,"height":1},{"id":"9c6a04ac.e760a8","type":"ui_spacer","name":"spacer","group":"","order":11,"width":1,"height":1},{"id":"bb5bfba5.b3b7b8","type":"ui_spacer","name":"spacer","group":"","order":11,"width":8,"height":1},{"id":"f4e697fc.ee1608","type":"ui_tab","z":"","name":"Settings","icon":"dashboard","order":4,"disabled":false,"hidden":false},{"id":"ddd1a14a.d7351","type":"ui_group","z":"","name":"Settings","tab":"f4e697fc.ee1608","order":1,"disp":true,"width":"6","collapse":false},{"id":"79b73861.bb6048","type":"ui_spacer","name":"spacer","group":"","order":11,"width":8,"height":1},{"id":"a2b83ddb.6a2ee","type":"ui_group","z":"","name":"Camera Settings","tab":"","order":3,"disp":true,"width":"6","collapse":false},{"id":"1ecaa9e9.4192e6","type":"ui_spacer","name":"spacer","group":"","order":3,"width":1,"height":1},{"id":"e58f9de6.10904","type":"ui_spacer","name":"spacer","group":"","order":3,"width":1,"height":1},{"id":"924edf62.f208d","type":"ui_spacer","name":"spacer","group":"","order":3,"width":1,"height":1},{"id":"1303ee2a.fd44f2","type":"ui_spacer","name":"spacer","group":"","order":3,"width":1,"height":1},{"id":"5d12f9cd.9c4a88","type":"ui_spacer","name":"spacer","group":"a2b83ddb.6a2ee","order":5,"width":6,"height":1},{"id":"35a0e31e.2cf06c","type":"ui_group","z":"","name":"Advanced Pin & Motor Settings","tab":"f4e697fc.ee1608","order":2,"disp":true,"width":9,"collapse":true},{"id":"b9933221.eac94","type":"ui_group","z":"","name":"Advanced Camera Parameters","tab":"f4e697fc.ee1608","order":3,"disp":true,"width":9,"collapse":true},{"id":"6bdd5033.f67e","type":"ui_group","z":"","name":"Node Red Update","tab":"","order":1,"disp":true,"width":"6","collapse":false},{"id":"88a2f658.ac2378","type":"ui_spacer","name":"spacer","group":"6bdd5033.f67e","order":3,"width":6,"height":1},{"id":"8abef8eb.32fed8","type":"ui_tab","z":"","name":"Start","icon":"dashboard","order":1,"disabled":false,"hidden":false},{"id":"f7451b10.d6c048","type":"ui_group","z":"","name":"Start","tab":"8abef8eb.32fed8","order":1,"disp":false,"width":10,"collapse":false},{"id":"d25e08b4.5b27e8","type":"ui_tab","z":"","name":"Update & Info","icon":"dashboard","order":5,"disabled":false,"hidden":false},{"id":"ddbd496e.93a288","type":"ui_group","z":"","name":"Manage Updates","tab":"d25e08b4.5b27e8","order":1,"disp":true,"width":"6","collapse":false},{"id":"3ce32450.e0cffc","type":"ui_group","z":"","name":"Changelog","tab":"d25e08b4.5b27e8","order":2,"disp":true,"width":16,"collapse":false},{"id":"ceb0b5fe.bdd2f8","type":"ui_group","z":"","name":"Background","tab":"8abef8eb.32fed8","order":2,"disp":false,"width":"1","collapse":false},{"id":"191e6406.b089ec","type":"ui_group","z":"","name":"Info","tab":"d25e08b4.5b27e8","order":3,"disp":true,"width":"6","collapse":false},{"id":"6c07aa26.f11494","type":"ui_group","z":"","name":"Preview","tab":"","order":2,"disp":true,"width":11,"collapse":false},{"id":"8a897c8e.d858c","type":"ui_group","z":"","name":"Run","tab":"","order":3,"disp":true,"width":"6","collapse":false},{"id":"436c5312.8bd37c","type":"ui_spacer","name":"spacer","group":"6c07aa26.f11494","order":2,"width":3,"height":1},{"id":"76c2902a.e0813","type":"ui_spacer","name":"spacer","group":"6c07aa26.f11494","order":4,"width":3,"height":1},{"id":"e3c989ac.ead728","type":"ui_spacer","name":"spacer","group":"8a897c8e.d858c","order":4,"width":6,"height":1},{"id":"739bb3d8.c525bc","type":"ui_tab","z":"","name":"Camera","icon":"dashboard","order":2,"disabled":false,"hidden":false},{"id":"3aee2d1a.bc7412","type":"ui_group","z":"","name":"Main","tab":"739bb3d8.c525bc","order":1,"disp":false,"width":"6","collapse":false},{"id":"a0313e96.486fc","type":"ui_group","z":"","name":"Settings RPi","tab":"739bb3d8.c525bc","order":2,"disp":false,"width":"6","collapse":false},{"id":"b0cc7e63.5b5b3","type":"ui_group","z":"","name":"Preview RPi","tab":"739bb3d8.c525bc","order":6,"disp":false,"width":15,"collapse":false},{"id":"71843631.f4d5f8","type":"ui_group","z":"","name":"Preview GPhoto2","tab":"739bb3d8.c525bc","order":7,"disp":false,"width":15,"collapse":false},{"id":"56fe100.930a8f","type":"ui_group","z":"","name":"Settings Gphoto2","tab":"739bb3d8.c525bc","order":3,"disp":false,"width":6,"collapse":false},{"id":"66fc75c9.2e33fc","type":"ui_group","z":"","name":"Settings External Camera","tab":"739bb3d8.c525bc","order":4,"disp":false,"width":"6","collapse":false},{"id":"3e00b4d5.2a3f8c","type":"ui_group","z":"","name":"Settings Smartphone","tab":"739bb3d8.c525bc","order":5,"disp":false,"width":13,"collapse":false},{"id":"e76adf89.87655","type":"ui_group","z":"","name":"Data","tab":"739bb3d8.c525bc","order":8,"disp":false,"width":"6","collapse":false},{"id":"d8910e38.d12d1","type":"ui_group","z":"","name":"File upload","tab":"4c2d09a1.024848","order":4,"disp":true,"width":"6","collapse":false},{"id":"4c2d09a1.024848","type":"ui_tab","z":"","name":"File Upload","icon":"dashboard","order":3},{"id":"b9e9bd43.5257f","type":"ui_spacer","name":"spacer","group":"d77de880.1a5308","order":3,"width":1,"height":1},{"id":"71ce9ec5.16f49","type":"ui_group","z":"","name":"Experimental","tab":"739bb3d8.c525bc","order":9,"disp":false,"width":"6","collapse":false},{"id":"32cec472.113aac","type":"ui_spacer","name":"spacer","group":"191e6406.b089ec","order":2,"width":6,"height":1},{"id":"4a961dc6.c4bdc4","type":"ui_spacer","name":"spacer","group":"191e6406.b089ec","order":5,"width":6,"height":1},{"id":"9cc33f2c.6a6cd","type":"ui_group","z":"","name":"Group 1","tab":"5897836.06b027c","order":1,"disp":false,"width":"8","collapse":false},{"id":"5897836.06b027c","type":"ui_tab","z":"","name":"OpenScan Cloud","icon":"dashboard","order":6,"disabled":false,"hidden":false},{"id":"2da4bd3.c2b1042","type":"ui_spacer","name":"spacer","group":"ddd1a14a.d7351","order":4,"width":6,"height":1},{"id":"9f0a90cb.629f4","type":"ui_spacer","name":"spacer","group":"ddd1a14a.d7351","order":7,"width":6,"height":1},{"id":"120b6320.a5e22d","type":"ui_spacer","name":"spacer","group":"35a0e31e.2cf06c","order":9,"width":9,"height":1},{"id":"1b856f2d.ee2f81","type":"ui_spacer","name":"spacer","group":"35a0e31e.2cf06c","order":20,"width":9,"height":1},{"id":"71a8daa5.0cf124","type":"ui_spacer","name":"spacer","group":"f7451b10.d6c048","order":2,"width":10,"height":1},{"id":"95e84ac4.b72218","type":"ui_spacer","name":"spacer","group":"3aee2d1a.bc7412","order":2,"width":6,"height":1},{"id":"9f81d1ab.e2b9a","type":"ui_spacer","name":"spacer","group":"3aee2d1a.bc7412","order":9,"width":6,"height":1},{"id":"f4b4a3fd.c5c66","type":"ui_spacer","name":"spacer","group":"3aee2d1a.bc7412","order":12,"width":6,"height":1},{"id":"86b44fdb.7b5c","type":"ui_spacer","name":"spacer","group":"3aee2d1a.bc7412","order":19,"width":6,"height":1},{"id":"36072888.d9f3e8","type":"ui_spacer","name":"spacer","group":"56fe100.930a8f","order":3,"width":6,"height":1},{"id":"8b2c2e77.b2f6b","type":"ui_spacer","name":"spacer","group":"56fe100.930a8f","order":8,"width":6,"height":1},{"id":"b03e36d.46725c8","type":"ui_spacer","name":"spacer","group":"66fc75c9.2e33fc","order":2,"width":6,"height":1},{"id":"d6ee58ad.acbce8","type":"ui_spacer","name":"spacer","group":"66fc75c9.2e33fc","order":7,"width":6,"height":1},{"id":"c5fbf030.664e7","type":"ui_spacer","name":"spacer","group":"b0cc7e63.5b5b3","order":5,"width":5,"height":1},{"id":"b84e632.17093a","type":"ui_spacer","name":"spacer","group":"b0cc7e63.5b5b3","order":7,"width":5,"height":1},{"id":"ab6cc0ca.7bf72","type":"ui_spacer","name":"spacer","group":"71843631.f4d5f8","order":2,"width":1,"height":1},{"id":"32a0b125.5eee4e","type":"ui_spacer","name":"spacer","group":"71843631.f4d5f8","order":4,"width":1,"height":1},{"id":"b20f5c57.d4b34","type":"ui_spacer","name":"spacer","group":"71843631.f4d5f8","order":6,"width":1,"height":1},{"id":"5024ed86.4c84c4","type":"exec","z":"e4b4ade8.5763e","command":"ls","addpay":true,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":310,"y":80,"wires":[["d0eb6be8.eda228"],[],[]]},{"id":"d0eb6be8.eda228","type":"change","z":"e4b4ade8.5763e","name":"split","rules":[{"t":"set","p":"payload","pt":"msg","to":"$split(payload, '\\n')[$ != \"\"]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":490,"y":60,"wires":[[]]},{"id":"8136fc2b.942cf","type":"http in","z":"449b7301.e9f22c","name":"","url":"/fileupload","method":"post","upload":true,"swaggerDoc":"","x":100,"y":200,"wires":[["9a71f029.aafba"]]},{"id":"fc298520.54d958","type":"ui_template","z":"449b7301.e9f22c","group":"3aee2d1a.bc7412","name":"Upload","order":20,"width":6,"height":2,"format":"
\n\n\n","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":80,"y":160,"wires":[[]]},{"id":"9a71f029.aafba","type":"change","z":"449b7301.e9f22c","name":"","rules":[{"t":"set","p":"filename","pt":"msg","to":"$env('UPLOAD_DIR') & '/' & req.files[0].originalname","tot":"jsonata"},{"t":"set","p":"payload","pt":"msg","to":"req.files[0].buffer","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":200,"wires":[["5464e2c9.e1081c"]]},{"id":"5464e2c9.e1081c","type":"file","z":"449b7301.e9f22c","name":"","filename":"/home/pi/shared/log/loadsettings.log","appendNewline":false,"createDir":false,"overwriteFile":"true","x":571,"y":200,"wires":[["f55f65c1.0c6ff8","7476a50.4030d5c"]]},{"id":"cd0374ac.50fa18","type":"ui_toast","z":"449b7301.e9f22c","position":"bottom right","displayTime":"2","highlight":"","sendall":true,"outputs":0,"ok":"OK","cancel":"","topic":"","name":"","x":790,"y":280,"wires":[]},{"id":"f55f65c1.0c6ff8","type":"python3-function","z":"449b7301.e9f22c","name":"no/wrong file selected","func":"import filecmp\nimport shutil\nimport os\n\nif msg['filename']==\"./\":\n return msg\nif filecmp.cmp(\"/home/pi/shared/log/loadsettings_save.log\",\"/home/pi/shared/log/loadsettings.log\")==True:\n return\n\nwith open(\"/home/pi/shared/log/loadsettings.log\", \"rw+\") as file:\n commandraw=file.readlines()[0]\n command=commandraw.split(';')\n if command[0]!=\"Settings for OpenScanPi\":\n msg['payload']=\"wrong fileformat\"\n msg['highlight']=\"red\"\n return msg\n\n else:\n length=len(open(\"/home/pi/shared/log/loadsettings.log\").readlines())\n for x in range (1,length):\n with open(\"/home/pi/shared/log/loadsettings.log\", \"rw+\") as file:\n commandraw=file.readlines()[x]\n command=commandraw.split(';')\n if command[0]==\"zoomfactor\":\n command[0]=\"zoom\"\n if command[0]==\"projectname\":\n command[0]=\"skip\"\n try:\n if os.path.isfile(\"/home/pi/shared/log/\"+command[0]+\".log\"):\n with open(\"/home/pi/shared/log/\"+command[0]+\".log\",\"w\") as file:\n file.write(command[1])\n except:\n pass\n shutil.copy(\"/home/pi/shared/log/loadsettings.log\",\"/home/pi/shared/log/loadsettings_save.log\")\n msg['payload']=\"settings loaded\"\n return msg","outputs":1,"x":520,"y":260,"wires":[["cd0374ac.50fa18","bd8f9e38.c27a1","7577cad1.1b4cd4"]]},{"id":"bd8f9e38.c27a1","type":"function","z":"449b7301.e9f22c","name":"","func":"if (msg.payload==\"settings loaded\"){\n var msg1 = { payload:\"settings loaded\" };\n return msg1;\n}","outputs":1,"noerr":0,"x":749,"y":320,"wires":[[]]},{"id":"7577cad1.1b4cd4","type":"debug","z":"449b7301.e9f22c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":750,"y":240,"wires":[]},{"id":"7476a50.4030d5c","type":"debug","z":"449b7301.e9f22c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":830,"y":180,"wires":[]},{"id":"644535a3.1e997c","type":"inject","z":"2fb4a0.ab59cb6","name":"","topic":"","payload":"Started!","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":"","x":80,"y":100,"wires":[["640f4e8d.ce31","5d2b9742.274b38","31c00602.ea26ba","c2459f18.05765","689c7683.801678","74e6fa81.3a52b4","8c7bb9c0.9622f8","dd247d5e.6f266"]]},{"id":"640f4e8d.ce31","type":"file in","z":"2fb4a0.ab59cb6","name":"","filename":"/home/pi/shared/log/camerabrightness.log","format":"","chunk":false,"sendError":false,"encoding":"none","x":340,"y":240,"wires":[["722dfda9.439ff4"]]},{"id":"a9089952.dcbbe8","type":"ui_button","z":"2fb4a0.ab59cb6","name":"","group":"a0313e96.486fc","order":13,"width":0,"height":0,"passthru":true,"label":"Start Routine","tooltip":"","color":"","bgcolor":"","icon":"","payload":"starten","payloadType":"str","topic":"","x":90,"y":940,"wires":[["8fc42f69.188c3","8489d6b8.e07288"]]},{"id":"12237dbf.377612","type":"ui_button","z":"2fb4a0.ab59cb6","name":"","group":"b0cc7e63.5b5b3","order":2,"width":5,"height":1,"passthru":false,"label":"Update Preview","tooltip":"press to show the effect of changed settings (takes one second to load)","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":100,"y":660,"wires":[["3b1947e9.020e38"]]},{"id":"29b36726.080948","type":"ui_text","z":"2fb4a0.ab59cb6","group":"a0313e96.486fc","order":3,"width":6,"height":1,"name":"","label":"Camera Brightness","format":"{{msg.payload}}","layout":"row-spread","x":1130,"y":240,"wires":[]},{"id":"8fc42f69.188c3","type":"python3-function","z":"2fb4a0.ab59cb6","name":"Run Routine","func":"import RPi.GPIO as GPIO\nimport time\nimport picamera\nfrom time import sleep\n# Zip-packer\nimport os\nimport shutil\nfrom os import path\nfrom zipfile import ZipFile\nfrom shutil import make_archive\nfrom PIL import Image\nimport sys\n\nfrom zipfile import ZipFile\n\nwith open(\"/home/pi/shared/log/currentstatus_rpi.log\", \"r\") as file:\n test=file.read()\nif test!=\"no camera found\" and test!=\"--READY--\":\n return\n\n#routine settings\nwith open(\"/home/pi/shared/log/fotosperrotation.log\", \"r\") as file:\n fotosperrotation=int(file.read())\nwith open(\"/home/pi/shared/log/startdeflection.log\", \"r\") as file:\n startdeflection=int(file.read())\nwith open(\"/home/pi/shared/log/verticalpositions.log\", \"r\") as file:\n verticalpositions=int(file.read())\nwith open(\"/home/pi/shared/log/projectname.log\", \"r\") as file:\n projectname=file.read()\n\n# cam settings\nwith open(\"/home/pi/shared/log/camera_resolution_x.log\", \"r\") as file:\n resx=int(file.read())\nwith open(\"/home/pi/shared/log/camera_resolution_y.log\", \"r\") as file:\n resy=int(file.read())\n\n\nwith open(\"/home/pi/shared/log/pin_rotor_dir.log\", \"r\") as file:\n dirpinrotor=int(file.read())\nwith open(\"/home/pi/shared/log/pin_rotor_step.log\", \"r\") as file:\n steppinrotor=int(file.read())\nwith open(\"/home/pi/shared/log/pin_turntable_dir.log\", \"r\") as file:\n dirpintt=int(file.read())\nwith open(\"/home/pi/shared/log/pin_turntable_step.log\", \"r\") as file:\n steppintt=int(file.read())\nwith open(\"/home/pi/shared/log/rotor_stepsperrotation.log\", \"r\") as file:\n rotorspr=int(file.read())\nwith open(\"/home/pi/shared/log/turntable_stepsperrotation.log\", \"r\") as file:\n ttspr=int(file.read()) \nwith open(\"/home/pi/shared/log/rotor_delay.log\", \"r\") as file:\n delayrotor=float(file.read())\nwith open(\"/home/pi/shared/log/turntable_delay.log\", \"r\") as file:\n delaytt=float(file.read()) \nwith open(\"/home/pi/shared/log/turntable_accramp.log\", \"r\") as file:\n ttramp=int(file.read())\nwith open(\"/home/pi/shared/log/turntable_acc.log\", \"r\") as file:\n ttacc=ttramp*float(file.read()) \nwith open(\"/home/pi/shared/log/rotor_accramp.log\", \"r\") as file:\n rotorramp=int(file.read())\nwith open(\"/home/pi/shared/log/rotor_acc.log\", \"r\") as file:\n rotoracc=rotorramp*float(file.read()) \n\nstartangle = rotorspr/360*startdeflection\nprojectcode =time.strftime(\"20%y-%m-%d %H.%M.%S - \")+projectname+'/'\ndirname='./shared/'+projectcode\nos.makedirs(dirname) \n\nGPIO.setwarnings(False)\nGPIO.setmode(GPIO.BCM)\nGPIO.setup(3, GPIO.OUT)\n\n\n\ndef ttrun(step_count):\n stoptest()\n GPIO.setup(dirpintt, GPIO.OUT)\n GPIO.setup(steppintt, GPIO.OUT)\n if (step_count>0):\n GPIO.output(dirpintt, GPIO.HIGH)\n if(step_count<0):\n GPIO.output(dirpintt, GPIO.LOW)\n step_count=-step_count\n for x in range(step_count):\n GPIO.output(steppintt, GPIO.HIGH)\n if x<=ttramp and x<=step_count/2:\n delay=delaytt+(ttramp-x)*delaytt/ttacc\n elif step_count-x<=ttramp and x>step_count/2:\n delay=delaytt+(ttramp-step_count+x)*delaytt/ttacc\n sleep(delay)\n GPIO.output(steppintt, GPIO.LOW)\n sleep(delay)\n\ndef rotorrun(step_count):\n stoptest()\n GPIO.setup(dirpinrotor, GPIO.OUT)\n GPIO.setup(steppinrotor, GPIO.OUT)\n if (step_count>0):\n GPIO.output(dirpinrotor, GPIO.HIGH)\n if(step_count<0):\n GPIO.output(dirpinrotor, GPIO.LOW)\n step_count=-step_count\n for x in range(step_count):\n GPIO.output(steppinrotor, GPIO.HIGH)\n if x<=rotorramp and x<=step_count/2:\n delay=delayrotor+(rotorramp-x)*delayrotor/rotoracc\n elif step_count-x<=rotorramp and x>step_count/2:\n delay=delayrotor+(rotorramp-step_count+x)*delayrotor/rotoracc\n sleep(delay)\n GPIO.output(steppinrotor, GPIO.LOW)\n sleep(delay)\n\ndef updatepreview():\n with open(\"/home/pi/shared/log/updatepreview.log\", \"w\") as file:\n file.write(time.strftime(\"20%y-%m-%d_%H-%M-%S\"))\n\ndef stoptest():\n with open(\"/home/pi/shared/log/stopstate.log\", \"r\") as file:\n if (file.read()!=\"stop\"):\n return\n saveparameters()\n with open(\"/home/pi/shared/log/stopstate.log\", \"w\") as file:\n file.write(\"ready\")\n stoppppppp() #produce error until i find a better solution :)\n \ndef takephoto():\n stoptest()\n with picamera.PiCamera() as camera:\n with open(\"/home/pi/shared/log/cameracontrast.log\", \"r\") as file:\n cameracontrast=int(file.read())\n with open(\"/home/pi/shared/log/camerabrightness.log\", \"r\") as file:\n camerabrightness=int(file.read())\n with open(\"/home/pi/shared/log/shutterspeed.log\", \"r\") as file:\n shutterspeed=int(file.read())*100\n camera.iso = 100\n camera.brightness = camerabrightness\n camera.contrast = cameracontrast\n camera.resolution=(resx, resy)\n camera.exposure_compensation = 0 \n timestamp= time.strftime(\"20%y-%m-%d_%H-%M-%S\")\n filepath = dirname+'/'+ timestamp + \".jpg\"\n sleep(0.7)\n camera.awb_mode = 'auto'\n camera.exposure_mode = 'off'\n camera.shutter_speed = shutterspeed\n camera.capture(filepath, quality=100)\n \n crop(filepath)\n zip(filepath)\n camera.close()\n updatepreview()\n\ndef turntablerotation():\n for x in range (fotosperrotation):\n with open(\"/home/pi/shared/log/currentstatus_rpi.log\", \"w\") as file:\n file.write(\"Position: \"+str(vertpos)+\"/\"+str(verticalpositions)+\" Foto: \"+str(x+1)+\"/\"+str(fotosperrotation))\n if fotosperrotation!=1:\n ttrun(ttspr/fotosperrotation)\n takephoto()\n\ndef saveparameters():\n os.mknod(dirname+\"/parameters.txt\")\n\n with open(\"/home/pi/shared/log/cameracontrast.log\", \"r\") as file:\n cameracontrast=int(file.read())\n with open(\"/home/pi/shared/log/camerabrightness.log\", \"r\") as file:\n camerabrightness=int(file.read())\n with open(\"/home/pi/shared/log/shutterspeed.log\", \"r\") as file:\n shutterspeed=int(file.read())\n with open(\"/home/pi/shared/log/cropx.log\", \"r\") as file:\n cropx=int(file.read())\n with open(\"/home/pi/shared/log/cropy.log\", \"r\") as file:\n cropy=int(file.read())\n\n with open(dirname+\"/parameters.txt\", \"w\") as file:\n file.write(\"Settings for OpenScanPi;\\n\")\n file.write(\"projectname;\"+str(projectname)+\"\\n\")\n file.write(\"fotosperrotation;\"+str(fotosperrotation)+\"\\n\")\n file.write(\"startdeflection;\"+str(startdeflection)+\"\\n\")\n file.write(\"verticalpositions;\"+str(verticalpositions)+\"\\n\")\n file.write(\"camerabrightness;\"+str(camerabrightness)+\"\\n\")\n file.write(\"shutterspeed;\"+str(shutterspeed)+\"\\n\")\n file.write(\"cameracontrast;\"+str(cameracontrast)+\"\\n\")\n file.write(\"cropx;\"+str(cropx)+\"\\n\")\n file.write(\"cropy;\"+str(cropy)+\"\\n\")\n\n zip(dirname+\"/parameters.txt\")\n\n shutil.move('shared/temp.zip','shared/ui/data/zip/'+projectcode[:-1]+'.zip')\n shutil.rmtree(dirname)\n \n with open(\"/home/pi/shared/log/currentstatus_rpi.log\", \"w\") as file:\n file.write(\"--READY--\")\n\ndef zip(filepath):\n with ZipFile(\"/home/pi/shared/temp.zip\", \"a\") as zip:\n zip.write(filepath, os.path.basename(filepath))\n os.remove(filepath)\n \ndef crop(filepath):\n with open(\"/home/pi/shared/log/cropx.log\", \"r\") as file:\n cropx=int(file.read())\n with open(\"/home/pi/shared/log/cropy.log\", \"r\") as file:\n cropy=int(file.read()) \n\n img = Image.open(filepath)\n width, height = img.size \n\n left = width*cropx/100\n top = height*cropy/100\n right = width*(100-cropx)/100\n bottom = height*(100-cropy)/100\n img= img.crop((left,top,right,bottom))\n img.save(filepath, quality=100)\n zoom=min(float(cropx)/50,float(cropy)/50)\n img = img.resize((int(float(600-12*cropx)/(1-zoom)), int(float(450-9*cropy)/(1-zoom))))\n img.save('./shared/ui/data/preview.jpg')\n img.close()\n\n\nrotorrun(-startangle)\nfor x in range (verticalpositions-1):\n vertpos = x+1\n turntablerotation()\n if (verticalpositions>1):\n rotorrun(2*startangle/(verticalpositions-1))\nif (verticalpositions==1):\n startangle=-startangle\nvertpos=verticalpositions\nturntablerotation()\n\nrotorrun(-startangle)\n\nsaveparameters()\n\nreturn msg","outputs":1,"x":250,"y":940,"wires":[["efcbec58.ac2c1"]]},{"id":"722dfda9.439ff4","type":"ui_slider","z":"2fb4a0.ab59cb6","name":"","label":" ","tooltip":"adjust the camera brightness","group":"a0313e96.486fc","order":4,"width":6,"height":1,"passthru":true,"outs":"all","topic":"","min":"0","max":"100","step":1,"x":590,"y":240,"wires":[["487c5591.71f9dc"]]},{"id":"5d2b9742.274b38","type":"function","z":"2fb4a0.ab59cb6","name":"Reset Project Name","func":"msg.payload=\"default\"\nreturn msg;","outputs":1,"noerr":0,"x":280,"y":200,"wires":[["874acd51.12158","27ca25fc.2e5bca"]]},{"id":"874acd51.12158","type":"ui_text_input","z":"2fb4a0.ab59cb6","name":"project n","label":"Project Name","tooltip":"enter project name","group":"a0313e96.486fc","order":2,"width":6,"height":1,"passthru":true,"mode":"text","delay":"300","topic":"","x":600,"y":200,"wires":[["27ca25fc.2e5bca"]]},{"id":"27ca25fc.2e5bca","type":"file","z":"2fb4a0.ab59cb6","name":"","filename":"/home/pi/shared/log/projectname.log","appendNewline":false,"createDir":true,"overwriteFile":"true","encoding":"none","x":830,"y":200,"wires":[[]]},{"id":"a95de614.115ff8","type":"function","z":"2fb4a0.ab59cb6","name":"timestamp pic file","func":"var d = new Date();\nvar n = d.getTime();\nmsg.payload = \"/ui/data/preview.jpg?ts=\" + n;\nreturn msg;","outputs":1,"noerr":0,"x":810,"y":660,"wires":[["8148d620.3d5c48"]]},{"id":"8148d620.3d5c48","type":"ui_template","z":"2fb4a0.ab59cb6","group":"b0cc7e63.5b5b3","name":"preview","order":1,"width":15,"height":11,"format":"\n","storeOutMessages":false,"fwdInMessages":false,"templateScope":"local","x":980,"y":660,"wires":[[]]},{"id":"b1853b33.6eb8e8","type":"python3-function","z":"2fb4a0.ab59cb6","name":"Take Preview Shot","func":"import time\nimport picamera\nfrom time import sleep\nimport subprocess\nfrom PIL import Image\n\ndownscale=3\n\nwith open(\"/home/pi/shared/log/camera.log\", \"r\") as file:\n if file.read()!=\"RPi Camera\":\n return\n\nwith open(\"/home/pi/shared/log/currentstatus_rpi.log\", \"r\") as file:\n if file.read()==\"creating zip file\":\n return\n\nif subprocess.check_output([\"vcgencmd\",\"get_camera\"])[-2:-1]==\"0\":\n with open(\"/home/pi/shared/log/currentstatus_rpi.log\", \"w\") as file:\n file.write(\"no camera found\")\n return\n\nwith open(\"/home/pi/shared/log/currentstatus_rpi.log\", \"r\") as file:\n state=file.read()\n if state[:3]==\"Pos\":\n return\n\nwith open(\"/home/pi/shared/log/currentstatus_rpi.log\", \"w\") as file:\n file.write(\"--READY--\")\n\nwith open(\"/home/pi/shared/log/shutterspeed.log\", \"r\") as file:\n shutterspeed=int(file.read())*100\n\n\nwith open(\"/home/pi/shared/log/camera_resolution_x.log\", \"r\") as file:\n resx=int(file.read())\nwith open(\"/home/pi/shared/log/camera_resolution_y.log\", \"r\") as file:\n resy=int(file.read())\nwith open(\"/home/pi/shared/log/currentstatus_rpi.log\", \"r\") as file:\n currentstatus=file.read()\n\ndef crop(filepath):\n with open(\"/home/pi/shared/log/cropx.log\", \"r\") as file:\n cropx=int(file.read())\n with open(\"/home/pi/shared/log/cropy.log\", \"r\") as file:\n cropy=int(file.read()) \n img = Image.open(filepath)\n width, height = img.size \n\n left = width*cropx/100\n top = height*cropy/100\n right = width*(100-cropx)/100\n bottom = height*(100-cropy)/100\n img= img.crop((left,top,right,bottom))\n img.save(filepath)\n zoom=min(float(cropx)/50,float(cropy)/50)\n img = img.resize((int(float(1200-24*cropx)/(1-zoom)), int(float(900-18*cropy)/(1-zoom))))\n img.save('./shared/ui/data/preview.jpg')\n img.close()\n\nif currentstatus == \"--READY--\":\n with picamera.PiCamera() as camera:\n with open(\"/home/pi/shared/log/cameracontrast.log\", \"r\") as file:\n cameracontrast=int(file.read())\n with open(\"/home/pi/shared/log/camerabrightness.log\", \"r\") as file:\n camerabrightness=int(file.read())\n camera.iso = 100\n camera.brightness = camerabrightness\n camera.contrast = cameracontrast\n camera.resolution=(resx/downscale, resy/downscale)\n camera.exposure_compensation = 0 \n sleep(0.4)\n camera.awb_mode = 'auto'\n camera.exposure_mode = 'off'\n camera.shutter_speed = shutterspeed\n camera.capture(\"./shared/ui/data/preview.jpg\",quality=80)\n crop(\"./shared/ui/data/preview.jpg\")\n return msg\n\n\nreturn","outputs":1,"x":550,"y":660,"wires":[["a95de614.115ff8"]]},{"id":"31c00602.ea26ba","type":"file in","z":"2fb4a0.ab59cb6","name":"","filename":"/home/pi/shared/log/cameracontrast.log","format":"","chunk":false,"sendError":false,"encoding":"none","x":340,"y":280,"wires":[["21416173.70b8ae"]]},{"id":"a9c9d653.6f8cb8","type":"ui_text","z":"2fb4a0.ab59cb6","group":"a0313e96.486fc","order":7,"width":6,"height":1,"name":"","label":"Camera Contrast","format":"{{msg.payload}}","layout":"row-spread","x":1130,"y":280,"wires":[]},{"id":"21416173.70b8ae","type":"ui_slider","z":"2fb4a0.ab59cb6","name":"contrast","label":" ","tooltip":"adjust the camera contrast","group":"a0313e96.486fc","order":8,"width":6,"height":1,"passthru":true,"outs":"all","topic":"","min":"-100","max":"100","step":"5","x":600,"y":280,"wires":[["e226507f.24786"]]},{"id":"bdb8926a.a3097","type":"comment","z":"2fb4a0.ab59cb6","name":"System","info":"","x":55,"y":3159.9936332702637,"wires":[]},{"id":"72bf21dd.1a7a","type":"function","z":"2fb4a0.ab59cb6","name":"Autoupdate on?","func":"if (global.get(\"autoupdate\") == \"on\"){\n return msg\n}","outputs":1,"noerr":0,"x":343.0000762939453,"y":501.0001611709595,"wires":[["1c4b5036.a10fd"]]},{"id":"3b1947e9.020e38","type":"delay","z":"2fb4a0.ab59cb6","name":"","pauseType":"rate","timeout":"0.1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1.35","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":330,"y":660,"wires":[["b1853b33.6eb8e8"]]},{"id":"c2459f18.05765","type":"exec","z":"2fb4a0.ab59cb6","command":"sudo rm -rf -d /home/pi/shared/ui/data/preview.jpg","addpay":true,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":370,"y":100,"wires":[[],[],[]]},{"id":"781f3.b6439e0d4","type":"file in","z":"2fb4a0.ab59cb6","name":"","filename":"/home/pi/shared/log/currentstatus_rpi.log","format":"lines","chunk":false,"sendError":false,"encoding":"none","x":420,"y":540,"wires":[["31c04784.2c6708"]]},{"id":"803f0685.7ab378","type":"ui_text","z":"2fb4a0.ab59cb6","group":"a0313e96.486fc","order":1,"width":0,"height":0,"name":"","label":"Current Status:","format":" {{msg.payload}} ","layout":"row-spread","x":900,"y":540,"wires":[]},{"id":"60e1e9c2.517b28","type":"inject","z":"2fb4a0.ab59cb6","name":"","topic":"Repeater","payload":"0.1","payloadType":"str","repeat":"0.1","crontab":"","once":true,"onceDelay":"1","x":111.99996948242188,"y":501.00060081481934,"wires":[["781f3.b6439e0d4","72bf21dd.1a7a","47a0794f.b62c78"]]},{"id":"47a0794f.b62c78","type":"file in","z":"2fb4a0.ab59cb6","name":"","filename":"/home/pi/shared/log/updatepreview.log","format":"lines","chunk":false,"sendError":false,"encoding":"none","x":410,"y":580,"wires":[["9bf74b79.d19938"]]},{"id":"9bf74b79.d19938","type":"function","z":"2fb4a0.ab59cb6","name":"check preview mod","func":"if (msg.payload!=global.get(\"updatepreview\")){\n return msg\n}\n","outputs":1,"noerr":0,"x":690,"y":580,"wires":[["a95de614.115ff8","f165689b.6f4898"]]},{"id":"333695df.905d2a","type":"ui_button","z":"2fb4a0.ab59cb6","name":"","group":"a0313e96.486fc","order":14,"width":0,"height":0,"passthru":true,"label":"Stop Routine","tooltip":"","color":"","bgcolor":"","icon":"","payload":"stop","payloadType":"str","topic":"","x":90,"y":1040,"wires":[["d4491741.67cde8"]]},{"id":"35a36b3b.902074","type":"link in","z":"2fb4a0.ab59cb6","name":"Update Preview RPi","links":["4bafeaee.da8274","1519cfac.723f1","1c4b5036.a10fd","1a794560.38424b","529400f0.1e473","cdc6c714.a50768","f5ee2b34.38c468","e24779c5.096f48","bb4b43c8.b49e7","efcbec58.ac2c1","eedbeec5.3e917"],"x":175,"y":700,"wires":[["3b1947e9.020e38"]]},{"id":"1c4b5036.a10fd","type":"link out","z":"2fb4a0.ab59cb6","name":"","links":["35a36b3b.902074"],"x":476.0174150466919,"y":500.67735385894775,"wires":[]},{"id":"689c7683.801678","type":"python3-function","z":"2fb4a0.ab59cb6","name":"set initial variables","func":"import subprocess\n\nwith open(\"/home/pi/shared/log/stopstate.log\", \"w\") as file:\n file.write(\"run\")\nwith open(\"/home/pi/shared/log/updatepreview.log\", \"w\") as file:\n file.write(\"start\")\nwith open(\"/home/pi/shared/log/ringlightstatus1.log\", \"w\") as file:\n file.write(\"off\")\nwith open(\"/home/pi/shared/log/ringlightstatus2.log\", \"w\") as file:\n file.write(\"off\")\n\nif subprocess.check_output([\"vcgencmd\",\"get_camera\"])[-2:-1]==\"0\":\n with open(\"/home/pi/shared/log/currentstatus_rpi.log\", \"w\") as file:\n file.write(\"no camera found\")\n return\nwith open(\"/home/pi/shared/log/currentstatus_rpi.log\", \"w\") as file:\n file.write(\"--READY--\")","outputs":1,"x":270,"y":440,"wires":[[]]},{"id":"d4491741.67cde8","type":"python3-function","z":"2fb4a0.ab59cb6","name":"set stop state variables","func":"with open(\"/home/pi/shared/log/currentstatus_rpi.log\", \"r\") as file:\n test=file.read()\nif test[:3]!=\"Pos\":\n return\n\nwith open(\"/home/pi/shared/log/stopstate.log\", \"w\") as file:\n file.write(\"stop\")\nwith open(\"/home/pi/shared/log/currentstatus_rpi.log\", \"w\") as file:\n file.write(\"--stopping--\")","outputs":1,"x":280,"y":1040,"wires":[[]]},{"id":"f165689b.6f4898","type":"change","z":"2fb4a0.ab59cb6","name":"","rules":[{"t":"set","p":"updatepreview","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":940,"y":580,"wires":[[]]},{"id":"529400f0.1e473","type":"link out","z":"2fb4a0.ab59cb6","name":"","links":["35a36b3b.902074","cbe4bd92.d30af"],"x":975,"y":440,"wires":[]},{"id":"2818e518.aba02a","type":"exec","z":"8f3594bc.ecc048","command":"sudo reboot","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":490,"y":80,"wires":[[],[],[]]},{"id":"60e99835.699768","type":"exec","z":"8f3594bc.ecc048","command":"sudo shutdown -h now","addpay":true,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":520,"y":160,"wires":[[],[],[]]},{"id":"1c7926a9.f486a9","type":"ui_button","z":"8f3594bc.ecc048","name":"","group":"ddd1a14a.d7351","order":6,"width":6,"height":1,"passthru":false,"label":"Reboot","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"date","topic":"","x":80,"y":100,"wires":[["d448ae83.6e869","77ff3a1d.cc6224"]]},{"id":"9a862fcc.92d8","type":"ui_button","z":"8f3594bc.ecc048","name":"","group":"ddd1a14a.d7351","order":5,"width":6,"height":1,"passthru":false,"label":"Shutdown","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"date","topic":"","x":80,"y":140,"wires":[["ad1598b6.21bd68","77ff3a1d.cc6224"]]},{"id":"991c9040.2e977","type":"file","z":"8f3594bc.ecc048","name":"","filename":"/home/pi/shared/log/ssh.log","appendNewline":false,"createDir":true,"overwriteFile":"true","encoding":"none","x":640,"y":320,"wires":[[]]},{"id":"9cec1f3f.50562","type":"ui_switch","z":"8f3594bc.ecc048","name":"","label":"SSH Off/On","tooltip":"Start/Stop SSH Service, which allows remote access to the device","group":"ddd1a14a.d7351","order":2,"width":6,"height":1,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":410,"y":320,"wires":[["991c9040.2e977","99c850c1.215ca"]]},{"id":"d05e436c.d4173","type":"exec","z":"8f3594bc.ecc048","command":"sudo /etc/init.d/ssh stop ","addpay":true,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":877.0000076293945,"y":403.00000190734863,"wires":[[],[],[]]},{"id":"99c850c1.215ca","type":"function","z":"8f3594bc.ecc048","name":"Load Variables","func":"if (msg.payload === true){\n return [msg,null]\n}\nif (msg.payload ===false){\n return [null,msg]\n}","outputs":2,"noerr":0,"x":600.9999771118164,"y":358.00005531311035,"wires":[["aa7445c8.1a70b8"],["d05e436c.d4173"]]},{"id":"aa7445c8.1a70b8","type":"exec","z":"8f3594bc.ecc048","command":"sudo /etc/init.d/ssh start","addpay":true,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":877.0000228881836,"y":350.99999809265137,"wires":[[],[],[]]},{"id":"16d0584b.c1d918","type":"inject","z":"8f3594bc.ecc048","name":"","topic":"","payload":"Started!","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":"","x":80,"y":320,"wires":[["838f1a14.76d1a8","d81e87b.e11c078","4f64db4c.310424"]]},{"id":"9bbcd84e.957a48","type":"file","z":"8f3594bc.ecc048","name":"","filename":"/home/pi/shared/log/samba.log","appendNewline":false,"createDir":true,"overwriteFile":"true","encoding":"none","x":690,"y":460,"wires":[[]]},{"id":"59c337aa.061f38","type":"ui_switch","z":"8f3594bc.ecc048","name":"","label":"Samba Off/On","tooltip":"Start/Stop Samba Filesharing Server to remotely access the Pi's filesystem","group":"ddd1a14a.d7351","order":1,"width":6,"height":1,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":440,"y":460,"wires":[["9bbcd84e.957a48","cf0e918d.7c98f"]]},{"id":"50687124.df976","type":"exec","z":"8f3594bc.ecc048","command":"sudo /etc/init.d/smbd stop","addpay":true,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":932.9999771118164,"y":545.0000839233398,"wires":[[],[],[]]},{"id":"cf0e918d.7c98f","type":"function","z":"8f3594bc.ecc048","name":"Load Variables","func":"if (msg.payload === true){\n return [msg,null]\n}\nreturn [null,msg]\n","outputs":2,"noerr":0,"x":644.9999923706055,"y":498.9998664855957,"wires":[["38fc1b4f.fc6ca4"],["50687124.df976"]]},{"id":"38fc1b4f.fc6ca4","type":"exec","z":"8f3594bc.ecc048","command":"sudo /etc/init.d/smbd start","addpay":true,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":933.9999771118164,"y":492.9999198913574,"wires":[[],[],[]]},{"id":"ad1598b6.21bd68","type":"delay","z":"8f3594bc.ecc048","name":"","pauseType":"delay","timeout":"1.5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":310,"y":160,"wires":[["60e99835.699768"]]},{"id":"d448ae83.6e869","type":"delay","z":"8f3594bc.ecc048","name":"","pauseType":"delay","timeout":"1.5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":310,"y":80,"wires":[["2818e518.aba02a"]]},{"id":"77ff3a1d.cc6224","type":"python3-function","z":"8f3594bc.ecc048","name":"blink","func":"from time import sleep\nimport RPi.GPIO as GPIO\n\nsleeptime = 0.05\n\nwith open(\"/home/pi/shared/log/pin_ringlight1.log\", \"r\") as file:\n ringlightpin1=int(file.read())\nwith open(\"/home/pi/shared/log/pin_ringlight2.log\", \"r\") as file:\n ringlightpin2=int(file.read())\n\nGPIO.setwarnings(False)\nGPIO.setmode(GPIO.BCM)\nGPIO.setup(ringlightpin1, GPIO.OUT)\nGPIO.setup(ringlightpin2, GPIO.OUT)\nGPIO.output(ringlightpin2, GPIO.LOW)\n\nwith open(\"/home/pi/shared/log/ringlightstatus1.log\", \"w\") as file:\n file.write(\"off\")\nwith open(\"/home/pi/shared/log/ringlightstatus2.log\", \"w\") as file:\n file.write(\"off\")\n\nfor x in range(10):\n GPIO.output(ringlightpin1, GPIO.HIGH)\n sleep(sleeptime)\n GPIO.output(ringlightpin1, GPIO.LOW)\n sleep(sleeptime)\nmsg['payload']=\"off\"\nreturn msg","outputs":1,"x":270,"y":120,"wires":[["1ba25587.a47c9a"]]},{"id":"2634230b.e1987c","type":"ui_dropdown","z":"8f3594bc.ecc048","name":"","label":" Pin - rotor direction","tooltip":"standard value: 5","place":" ","group":"35a0e31e.2cf06c","order":2,"width":0,"height":0,"passthru":true,"options":[{"label":"","value":"2","type":"str"},{"label":"","value":"3","type":"str"},{"label":"","value":"4","type":"str"},{"label":"","value":"5","type":"str"},{"label":"","value":"6","type":"str"},{"label":"","value":"7","type":"str"},{"label":"","value":"9","type":"str"},{"label":"","value":"10","type":"str"},{"label":"","value":"11","type":"str"},{"label":"","value":"12","type":"str"},{"label":"","value":"13","type":"str"},{"label":"","value":"14","type":"str"},{"label":"","value":"15","type":"str"},{"label":"","value":"16","type":"str"},{"label":"","value":"17","type":"str"},{"label":"","value":"18","type":"str"},{"label":"","value":"19","type":"str"},{"label":"","value":"20","type":"str"},{"label":"","value":"21","type":"str"},{"label":"","value":"22","type":"str"},{"label":"","value":"23","type":"str"},{"label":"","value":"24","type":"str"},{"label":"","value":"25","type":"str"},{"label":"","value":"26","type":"str"},{"label":"","value":"27","type":"str"}],"payload":"","topic":"","x":644.5590505599976,"y":830.9723405838013,"wires":[["570e7dac.aa7944"]]},{"id":"a73addee.3c9d4","type":"file in","z":"8f3594bc.ecc048","name":"","filename":"/home/pi/shared/log/pin_rotor_dir.log","format":"lines","chunk":false,"sendError":false,"encoding":"none","x":299.99996852874756,"y":831.465124130249,"wires":[["2634230b.e1987c"]]},{"id":"570e7dac.aa7944","type":"file","z":"8f3594bc.ecc048","name":"","filename":"/home/pi/shared/log/pin_rotor_dir.log","appendNewline":false,"createDir":true,"overwriteFile":"true","encoding":"none","x":1026.999945640564,"y":831.4651288986206,"wires":[[]]},{"id":"3d8e2b9c.385974","type":"inject","z":"8f3594bc.ecc048","name":"","topic":"","payload":"Started!","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":"","x":67.99999237060547,"y":690.4654216766357,"wires":[["c656ef1a.1470a"]]},{"id":"7348c834.1e0dc8","type":"ui_dropdown","z":"8f3594bc.ecc048","name":"","label":" Pin - rotor step","tooltip":"standard value: 6","place":" ","group":"35a0e31e.2cf06c","order":3,"width":0,"height":0,"passthru":true,"options":[{"label":"","value":"2","type":"str"},{"label":"","value":"3","type":"str"},{"label":"","value":"4","type":"str"},{"label":"","value":"5","type":"str"},{"label":"","value":"6","type":"str"},{"label":"","value":"7","type":"str"},{"label":"","value":"9","type":"str"},{"label":"","value":"10","type":"str"},{"label":"","value":"11","type":"str"},{"label":"","value":"12","type":"str"},{"label":"","value":"13","type":"str"},{"label":"","value":"14","type":"str"},{"label":"","value":"15","type":"str"},{"label":"","value":"16","type":"str"},{"label":"","value":"17","type":"str"},{"label":"","value":"18","type":"str"},{"label":"","value":"19","type":"str"},{"label":"","value":"20","type":"str"},{"label":"","value":"21","type":"str"},{"label":"","value":"22","type":"str"},{"label":"","value":"23","type":"str"},{"label":"","value":"24","type":"str"},{"label":"","value":"25","type":"str"},{"label":"","value":"26","type":"str"},{"label":"","value":"27","type":"str"}],"payload":"","topic":"","x":634.5417318344116,"y":883.4651880264282,"wires":[["df748b5f.872298"]]},{"id":"38f309b.90595f6","type":"file in","z":"8f3594bc.ecc048","name":"","filename":"/home/pi/shared/log/pin_rotor_step.log","format":"lines","chunk":false,"sendError":false,"encoding":"none","x":298.9826498031616,"y":883.957971572876,"wires":[["7348c834.1e0dc8"]]},{"id":"df748b5f.872298","type":"file","z":"8f3594bc.ecc048","name":"","filename":"/home/pi/shared/log/pin_rotor_step.log","appendNewline":false,"createDir":true,"overwriteFile":"true","encoding":"none","x":1025.982626914978,"y":883.9579763412476,"wires":[[]]},{"id":"baefd8cc.6d2aa8","type":"ui_dropdown","z":"8f3594bc.ecc048","name":"","label":" Pin - turntable direction","tooltip":"standard value: 9","place":" ","group":"35a0e31e.2cf06c","order":4,"width":0,"height":0,"passthru":true,"options":[{"label":"","value":"2","type":"str"},{"label":"","value":"3","type":"str"},{"label":"","value":"4","type":"str"},{"label":"","value":"5","type":"str"},{"label":"","value":"6","type":"str"},{"label":"","value":"7","type":"str"},{"label":"","value":"9","type":"str"},{"label":"","value":"10","type":"str"},{"label":"","value":"11","type":"str"},{"label":"","value":"12","type":"str"},{"label":"","value":"13","type":"str"},{"label":"","value":"14","type":"str"},{"label":"","value":"15","type":"str"},{"label":"","value":"16","type":"str"},{"label":"","value":"17","type":"str"},{"label":"","value":"18","type":"str"},{"label":"","value":"19","type":"str"},{"label":"","value":"20","type":"str"},{"label":"","value":"21","type":"str"},{"label":"","value":"22","type":"str"},{"label":"","value":"23","type":"str"},{"label":"","value":"24","type":"str"},{"label":"","value":"25","type":"str"},{"label":"","value":"26","type":"str"},{"label":"","value":"27","type":"str"}],"payload":"","topic":"","x":664.5590505599976,"y":934.4654321670532,"wires":[["92cd1e35.bbb7b"]]},{"id":"3285c0af.0abdf","type":"file in","z":"8f3594bc.ecc048","name":"","filename":"/home/pi/shared/log/pin_turntable_dir.log","format":"lines","chunk":false,"sendError":false,"encoding":"none","x":309.99996852874756,"y":934.958215713501,"wires":[["baefd8cc.6d2aa8"]]},{"id":"92cd1e35.bbb7b","type":"file","z":"8f3594bc.ecc048","name":"","filename":"/home/pi/shared/log/pin_turntable_dir.log","appendNewline":false,"createDir":true,"overwriteFile":"true","encoding":"none","x":1036.999945640564,"y":934.9582204818726,"wires":[[]]},{"id":"a670280c.cadcf8","type":"ui_dropdown","z":"8f3594bc.ecc048","name":"","label":" Pin - turntable step","tooltip":"standard value: 11","place":" ","group":"35a0e31e.2cf06c","order":5,"width":0,"height":0,"passthru":true,"options":[{"label":"","value":"2","type":"str"},{"label":"","value":"3","type":"str"},{"label":"","value":"4","type":"str"},{"label":"","value":"5","type":"str"},{"label":"","value":"6","type":"str"},{"label":"","value":"7","type":"str"},{"label":"","value":"9","type":"str"},{"label":"","value":"10","type":"str"},{"label":"","value":"11","type":"str"},{"label":"","value":"12","type":"str"},{"label":"","value":"13","type":"str"},{"label":"","value":"14","type":"str"},{"label":"","value":"15","type":"str"},{"label":"","value":"16","type":"str"},{"label":"","value":"17","type":"str"},{"label":"","value":"18","type":"str"},{"label":"","value":"19","type":"str"},{"label":"","value":"20","type":"str"},{"label":"","value":"21","type":"str"},{"label":"","value":"22","type":"str"},{"label":"","value":"23","type":"str"},{"label":"","value":"24","type":"str"},{"label":"","value":"25","type":"str"},{"label":"","value":"26","type":"str"},{"label":"","value":"27","type":"str"}],"payload":"","topic":"","x":644.5417318344116,"y":986.9582796096802,"wires":[["a77a2650.e6b5b8"]]},{"id":"294d5e3c.b79782","type":"file in","z":"8f3594bc.ecc048","name":"","filename":"/home/pi/shared/log/pin_turntable_step.log","format":"lines","chunk":false,"sendError":false,"encoding":"none","x":318.9826498031616,"y":987.4510631561279,"wires":[["a670280c.cadcf8"]]},{"id":"a77a2650.e6b5b8","type":"file","z":"8f3594bc.ecc048","name":"","filename":"/home/pi/shared/log/pin_turntable_step.log","appendNewline":false,"createDir":true,"overwriteFile":"true","encoding":"none","x":1045.982626914978,"y":987.4510679244995,"wires":[[]]},{"id":"a155485f.2398b8","type":"ui_button","z":"8f3594bc.ecc048","name":"","group":"35a0e31e.2cf06c","order":1,"width":0,"height":0,"passthru":false,"label":"Reset all Pin Parameters","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"date","topic":"","x":260.9999694824219,"y":779.9097261428833,"wires":[["542968a4.b7e1b8"]]},{"id":"542968a4.b7e1b8","type":"python3-function","z":"8f3594bc.ecc048","name":"set initial variables","func":"with open(\"/home/pi/shared/log/pin_rotor_dir.log\", \"w\") as file:\n file.write(\"5\")\nwith open(\"/home/pi/shared/log/pin_rotor_step.log\", \"w\") as file:\n file.write(\"6\")\nwith open(\"/home/pi/shared/log/pin_turntable_dir.log\", \"w\") as file:\n file.write(\"9\")\nwith open(\"/home/pi/shared/log/pin_turntable_step.log\", \"w\") as file:\n file.write(\"11\")\nwith open(\"/home/pi/shared/log/pin_ringlight1.log\", \"w\") as file:\n file.write(\"17\")\nwith open(\"/home/pi/shared/log/pin_ringlight2.log\", \"w\") as file:\n file.write(\"27\")\nwith open(\"/home/pi/shared/log/pin_externalcam.log\", \"w\") as file:\n file.write(\"10\")\nwith open(\"/home/pi/shared/log/rotor_stepsperrotation.log\", \"w\") as file:\n file.write(\"17067\")\nwith open(\"/home/pi/shared/log/turntable_stepsperrotation.log\", \"w\") as file:\n file.write(\"3200\") \nwith open(\"/home/pi/shared/log/rotor_delay.log\", \"w\") as file:\n file.write(\"0.0005\")\nwith open(\"/home/pi/shared/log/turntable_delay.log\", \"w\") as file:\n file.write(\"0.0005\") \nwith open(\"/home/pi/shared/log/turntable_accramp.log\", \"w\") as file:\n file.write(\"200\")\nwith open(\"/home/pi/shared/log/turntable_acc.log\", \"w\") as file:\n file.write(\"1\") \nwith open(\"/home/pi/shared/log/turntable_angle.log\", \"w\") as file:\n file.write(\"10\") \nwith open(\"/home/pi/shared/log/rotor_accramp.log\", \"w\") as file:\n file.write(\"200\")\nwith open(\"/home/pi/shared/log/rotor_acc.log\", \"w\") as file:\n file.write(\"1\") \nwith open(\"/home/pi/shared/log/rotor_angle.log\", \"w\") as file:\n file.write(\"5\") \nreturn msg","outputs":1,"x":529.9999465942383,"y":779.9098825454712,"wires":[["69a5383d.bc5008"]]},{"id":"231e91ad.a2795e","type":"link in","z":"8f3594bc.ecc048","name":"Reset Parameters","links":["69a5383d.bc5008","c656ef1a.1470a","5738fde9.d71fa4"],"x":33.000000953674316,"y":830.8643503189087,"wires":[["a73addee.3c9d4","38f309b.90595f6","3285c0af.0abdf","294d5e3c.b79782","e02baa5f.8c0fd8","51b82858.f6af18","b87ad1b2.65e22"]]},{"id":"69a5383d.bc5008","type":"link out","z":"8f3594bc.ecc048","name":"","links":["231e91ad.a2795e","5bb62d67.946384","ae34bfeb.259d6","6ff7e620.b7ae78","ffe898e5.260058","728dc8b6.5be688"],"x":739.9965515136719,"y":779.7742357254028,"wires":[]},{"id":"c656ef1a.1470a","type":"link out","z":"8f3594bc.ecc048","name":"","links":["231e91ad.a2795e","5bb62d67.946384","ae34bfeb.259d6","6ff7e620.b7ae78","ffe898e5.260058","728dc8b6.5be688"],"x":194.99998474121094,"y":690.9096164703369,"wires":[]},{"id":"9cb3f4d.67b4008","type":"ui_dropdown","z":"8f3594bc.ecc048","name":"","label":" Pin - ringlight1","tooltip":"standard value: 17","place":" ","group":"35a0e31e.2cf06c","order":6,"width":0,"height":0,"passthru":true,"options":[{"label":"","value":"2","type":"str"},{"label":"","value":"3","type":"str"},{"label":"","value":"4","type":"str"},{"label":"","value":"5","type":"str"},{"label":"","value":"6","type":"str"},{"label":"","value":"7","type":"str"},{"label":"","value":"9","type":"str"},{"label":"","value":"10","type":"str"},{"label":"","value":"11","type":"str"},{"label":"","value":"12","type":"str"},{"label":"","value":"13","type":"str"},{"label":"","value":"14","type":"str"},{"label":"","value":"15","type":"str"},{"label":"","value":"16","type":"str"},{"label":"","value":"17","type":"str"},{"label":"","value":"18","type":"str"},{"label":"","value":"19","type":"str"},{"label":"","value":"20","type":"str"},{"label":"","value":"21","type":"str"},{"label":"","value":"22","type":"str"},{"label":"","value":"23","type":"str"},{"label":"","value":"24","type":"str"},{"label":"","value":"25","type":"str"},{"label":"","value":"26","type":"str"},{"label":"","value":"27","type":"str"}],"payload":"","topic":"","x":634.5417327880859,"y":1035.687388420105,"wires":[["fe17402f.f12ca"]]},{"id":"e02baa5f.8c0fd8","type":"file in","z":"8f3594bc.ecc048","name":"","filename":"/home/pi/shared/log/pin_ringlight1.log","format":"lines","chunk":false,"sendError":false,"encoding":"none","x":298.98265075683594,"y":1036.1801719665527,"wires":[["9cb3f4d.67b4008"]]},{"id":"fe17402f.f12ca","type":"file","z":"8f3594bc.ecc048","name":"","filename":"/home/pi/shared/log/pin_ringlight1.log","appendNewline":false,"createDir":true,"overwriteFile":"true","encoding":"none","x":1025.9826278686523,"y":1036.1801767349243,"wires":[[]]},{"id":"838b653b.eb7568","type":"ui_dropdown","z":"8f3594bc.ecc048","name":"","label":" Pin - ringlight2","tooltip":"standard value: 27","place":" ","group":"35a0e31e.2cf06c","order":7,"width":0,"height":0,"passthru":true,"options":[{"label":"","value":"2","type":"str"},{"label":"","value":"3","type":"str"},{"label":"","value":"4","type":"str"},{"label":"","value":"5","type":"str"},{"label":"","value":"6","type":"str"},{"label":"","value":"7","type":"str"},{"label":"","value":"9","type":"str"},{"label":"","value":"10","type":"str"},{"label":"","value":"11","type":"str"},{"label":"","value":"12","type":"str"},{"label":"","value":"13","type":"str"},{"label":"","value":"14","type":"str"},{"label":"","value":"15","type":"str"},{"label":"","value":"16","type":"str"},{"label":"","value":"17","type":"str"},{"label":"","value":"18","type":"str"},{"label":"","value":"19","type":"str"},{"label":"","value":"20","type":"str"},{"label":"","value":"21","type":"str"},{"label":"","value":"22","type":"str"},{"label":"","value":"23","type":"str"},{"label":"","value":"24","type":"str"},{"label":"","value":"25","type":"str"},{"label":"","value":"26","type":"str"},{"label":"","value":"27","type":"str"}],"payload":"","topic":"","x":634.5590515136719,"y":1086.68763256073,"wires":[["5faf491b.d92b98"]]},{"id":"51b82858.f6af18","type":"file in","z":"8f3594bc.ecc048","name":"","filename":"/home/pi/shared/log/pin_ringlight2.log","format":"lines","chunk":false,"sendError":false,"encoding":"none","x":298.9999694824219,"y":1087.1804161071777,"wires":[["838b653b.eb7568"]]},{"id":"5faf491b.d92b98","type":"file","z":"8f3594bc.ecc048","name":"","filename":"/home/pi/shared/log/pin_ringlight2.log","appendNewline":false,"createDir":true,"overwriteFile":"true","encoding":"none","x":1026.9999465942383,"y":1087.1804208755493,"wires":[[]]},{"id":"3eda8662.5ce5ea","type":"ui_dropdown","z":"8f3594bc.ecc048","name":"","label":" Pin - external camera","tooltip":"standard value: 10","place":" ","group":"35a0e31e.2cf06c","order":8,"width":0,"height":0,"passthru":true,"options":[{"label":"","value":"2","type":"str"},{"label":"","value":"3","type":"str"},{"label":"","value":"4","type":"str"},{"label":"","value":"5","type":"str"},{"label":"","value":"6","type":"str"},{"label":"","value":"7","type":"str"},{"label":"","value":"9","type":"str"},{"label":"","value":"10","type":"str"},{"label":"","value":"11","type":"str"},{"label":"","value":"12","type":"str"},{"label":"","value":"13","type":"str"},{"label":"","value":"14","type":"str"},{"label":"","value":"15","type":"str"},{"label":"","value":"16","type":"str"},{"label":"","value":"17","type":"str"},{"label":"","value":"18","type":"str"},{"label":"","value":"19","type":"str"},{"label":"","value":"20","type":"str"},{"label":"","value":"21","type":"str"},{"label":"","value":"22","type":"str"},{"label":"","value":"23","type":"str"},{"label":"","value":"24","type":"str"},{"label":"","value":"25","type":"str"},{"label":"","value":"26","type":"str"},{"label":"","value":"27","type":"str"}],"payload":"","topic":"","x":653.5417327880859,"y":1139.180480003357,"wires":[["58c56bbd.7238b4"]]},{"id":"b87ad1b2.65e22","type":"file in","z":"8f3594bc.ecc048","name":"","filename":"/home/pi/shared/log/pin_externalcam.log","format":"lines","chunk":false,"sendError":false,"encoding":"none","x":308.98265075683594,"y":1139.6732635498047,"wires":[["3eda8662.5ce5ea"]]},{"id":"58c56bbd.7238b4","type":"file","z":"8f3594bc.ecc048","name":"","filename":"/home/pi/shared/log/pin_externalcam.log","appendNewline":false,"createDir":true,"overwriteFile":"true","encoding":"none","x":1035.9826278686523,"y":1139.6732683181763,"wires":[[]]},{"id":"2ebfa79c.d21c08","type":"ui_text_input","z":"8f3594bc.ecc048","name":"","label":"","tooltip":"standard value: 17067","group":"35a0e31e.2cf06c","order":22,"width":3,"height":1,"passthru":true,"mode":"text","delay":"0","topic":"","x":580,"y":1760,"wires":[["be33b365.fb58a"]]},{"id":"2250d4a9.31f69c","type":"file in","z":"8f3594bc.ecc048","name":"","filename":"/home/pi/shared/log/rotor_stepsperrotation.log","format":"lines","chunk":false,"sendError":false,"encoding":"none","x":320,"y":1760,"wires":[["2ebfa79c.d21c08"]]},{"id":"be33b365.fb58a","type":"file","z":"8f3594bc.ecc048","name":"","filename":"/home/pi/shared/log/rotor_stepsperrotation.log","appendNewline":false,"createDir":true,"overwriteFile":"true","encoding":"none","x":840,"y":1760,"wires":[[]]},{"id":"f53f4ed2.c38eb","type":"ui_text","z":"8f3594bc.ecc048","group":"35a0e31e.2cf06c","order":21,"width":6,"height":1,"name":"","label":"Rotor - Steps per Rotation","format":"{{msg.payload}}","layout":"row-spread","x":250,"y":1720,"wires":[]},{"id":"b3a393f1.aaf46","type":"ui_text_input","z":"8f3594bc.ecc048","name":"","label":"","tooltip":"standard value: 3200","group":"35a0e31e.2cf06c","order":11,"width":3,"height":1,"passthru":true,"mode":"text","delay":"0","topic":"","x":600,"y":1300,"wires":[["2be96923.74c4b6"]]},{"id":"91af0a0.0302bf8","type":"file in","z":"8f3594bc.ecc048","name":"","filename":"/home/pi/shared/log/turntable_stepsperrotation.log","format":"lines","chunk":false,"sendError":false,"encoding":"none","x":330,"y":1300,"wires":[["b3a393f1.aaf46"]]},{"id":"2be96923.74c4b6","type":"file","z":"8f3594bc.ecc048","name":"","filename":"/home/pi/shared/log/turntable_stepsperrotation.log","appendNewline":false,"createDir":true,"overwriteFile":"true","encoding":"none","x":870,"y":1300,"wires":[[]]},{"id":"e3ea0f82.4f248","type":"ui_text","z":"8f3594bc.ecc048","group":"35a0e31e.2cf06c","order":10,"width":6,"height":1,"name":"","label":"Turntable - Steps per Rotation","format":"{{msg.payload}}","layout":"row-spread","x":270,"y":1260,"wires":[]},{"id":"6e9cf54d.d152ac","type":"ui_text_input","z":"8f3594bc.ecc048","name":"","label":"","tooltip":"standard value: 0.0005","group":"35a0e31e.2cf06c","order":24,"width":3,"height":1,"passthru":true,"mode":"text","delay":"0","topic":"","x":580,"y":1840,"wires":[["311f2807.82fc88"]]},{"id":"5cd9c9a4.0211c8","type":"file in","z":"8f3594bc.ecc048","name":"","filename":"/home/pi/shared/log/rotor_delay.log","format":"lines","chunk":false,"sendError":false,"encoding":"none","x":280,"y":1840,"wires":[["6e9cf54d.d152ac"]]},{"id":"311f2807.82fc88","type":"file","z":"8f3594bc.ecc048","name":"","filename":"/home/pi/shared/log/rotor_delay.log","appendNewline":false,"createDir":true,"overwriteFile":"true","encoding":"none","x":800,"y":1840,"wires":[[]]},{"id":"18f058eb.542ee7","type":"ui_text","z":"8f3594bc.ecc048","group":"35a0e31e.2cf06c","order":23,"width":6,"height":1,"name":"","label":"Rotor - Delay (s)","format":"{{msg.payload}}","layout":"row-spread","x":220,"y":1800,"wires":[]},{"id":"3decaa28.c9afb6","type":"ui_text_input","z":"8f3594bc.ecc048","name":"","label":"","tooltip":"standard value: 0.0005","group":"35a0e31e.2cf06c","order":13,"width":3,"height":1,"passthru":true,"mode":"text","delay":"0","topic":"","x":560,"y":1380,"wires":[["a85b7f2b.06041"]]},{"id":"e0e44c.f7272bb8","type":"file in","z":"8f3594bc.ecc048","name":"","filename":"/home/pi/shared/log/turntable_delay.log","format":"lines","chunk":false,"sendError":false,"encoding":"none","x":300,"y":1380,"wires":[["3decaa28.c9afb6"]]},{"id":"a85b7f2b.06041","type":"file","z":"8f3594bc.ecc048","name":"","filename":"/home/pi/shared/log/turntable_delay.log","appendNewline":false,"createDir":true,"overwriteFile":"true","encoding":"none","x":800,"y":1380,"wires":[[]]},{"id":"e64ece9e.03b44","type":"ui_text","z":"8f3594bc.ecc048","group":"35a0e31e.2cf06c","order":12,"width":6,"height":1,"name":"","label":"Turntable - Delay (s)","format":"{{msg.payload}}","layout":"row-spread","x":240,"y":1340,"wires":[]},{"id":"44568015.41d6a","type":"ui_text","z":"8f3594bc.ecc048","group":"b9933221.eac94","order":2,"width":7,"height":1,"name":"","label":"RPi Cam Resolution x","format":"{{msg.payload}}","layout":"row-spread","x":240,"y":2260,"wires":[]},{"id":"6a483d91.35fbc4","type":"ui_button","z":"8f3594bc.ecc048","name":"","group":"b9933221.eac94","order":1,"width":9,"height":1,"passthru":false,"label":"Reset all Cam Parameters","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"date","topic":"","x":260,"y":2220,"wires":[["c9e7bdd0.2846f"]]},{"id":"c9e7bdd0.2846f","type":"python3-function","z":"8f3594bc.ecc048","name":"set initial variables","func":"with open(\"/home/pi/shared/log/picamera_activation.log\", \"w\") as file:\n file.write(\"true\")\nwith open(\"/home/pi/shared/log/camera_resolution_x.log\", \"w\") as file:\n file.write(\"3280\")\nwith open(\"/home/pi/shared/log/camera_resolution_y.log\", \"w\") as file:\n file.write(\"2464\") \n \nreturn msg","outputs":1,"x":510,"y":2220,"wires":[["5738fde9.d71fa4"]]},{"id":"5738fde9.d71fa4","type":"link out","z":"8f3594bc.ecc048","name":"","links":["231e91ad.a2795e","5bb62d67.946384","ae34bfeb.259d6","6ff7e620.b7ae78","ffe898e5.260058","728dc8b6.5be688"],"x":655,"y":2220,"wires":[]},{"id":"46f33fd7.d7dda","type":"file in","z":"8f3594bc.ecc048","name":"","filename":"/home/pi/shared/log/camera_resolution_x.log","format":"lines","chunk":false,"sendError":false,"encoding":"none","x":310,"y":2300,"wires":[["fa44fcc9.3da22"]]},{"id":"918e745a.e24398","type":"file","z":"8f3594bc.ecc048","name":"","filename":"/home/pi/shared/log/camera_resolution_x.log","appendNewline":false,"createDir":true,"overwriteFile":"true","encoding":"none","x":790,"y":2300,"wires":[[]]},{"id":"2d9858d5.093298","type":"file in","z":"8f3594bc.ecc048","name":"","filename":"/home/pi/shared/log/camera_resolution_y.log","format":"lines","chunk":false,"sendError":false,"encoding":"none","x":310,"y":2380,"wires":[["d60d6a03.0a86b8"]]},{"id":"d96df1e5.775c1","type":"file","z":"8f3594bc.ecc048","name":"","filename":"/home/pi/shared/log/camera_resolution_y.log","appendNewline":false,"createDir":true,"overwriteFile":"true","encoding":"none","x":790,"y":2380,"wires":[[]]},{"id":"a689fb29.128f88","type":"ui_text","z":"8f3594bc.ecc048","group":"b9933221.eac94","order":4,"width":7,"height":1,"name":"","label":"RPi Cam Resolution y","format":"{{msg.payload}}","layout":"row-spread","x":240,"y":2340,"wires":[]},{"id":"6ff7e620.b7ae78","type":"link in","z":"8f3594bc.ecc048","name":"Reset Parameters","links":["3de3afc6.4755e","a7f0bc18.40ee","c46b984d.ed3f18","69a5383d.bc5008","c656ef1a.1470a","5738fde9.d71fa4"],"x":35,"y":2300,"wires":[["46f33fd7.d7dda","2d9858d5.093298"]]},{"id":"f82f18e.e98d4e8","type":"inject","z":"2d99e20d.5e48ee","name":"","topic":"","payload":"Started!","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":"","x":80,"y":60,"wires":[["1a822d74.3f1383","df1102c4.06896","fd31005a.52026"]]},{"id":"acac479a.0613c8","type":"file","z":"2d99e20d.5e48ee","name":"","filename":"/home/pi/shared/log/timeperfoto_ext.log","appendNewline":false,"createDir":true,"overwriteFile":"true","encoding":"none","x":820,"y":60,"wires":[["fb30aef8.a18fd"]]},{"id":"1a822d74.3f1383","type":"file in","z":"2d99e20d.5e48ee","name":"","filename":"/home/pi/shared/log/timeperfoto_ext.log","format":"lines","chunk":false,"sendError":false,"encoding":"none","x":320,"y":60,"wires":[["9dfca058.0726b"]]},{"id":"9dfca058.0726b","type":"ui_slider","z":"2d99e20d.5e48ee","name":"","label":" ","tooltip":"Set this value depending on your camera's speed (release + processing time)","group":"66fc75c9.2e33fc","order":4,"width":0,"height":0,"passthru":true,"outs":"all","topic":"","min":"0.5","max":"3","step":"0.1","x":583.9999732971191,"y":60.00003242492676,"wires":[["acac479a.0613c8"]]},{"id":"fb30aef8.a18fd","type":"ui_text","z":"2d99e20d.5e48ee","group":"66fc75c9.2e33fc","order":3,"width":0,"height":0,"name":"","label":"Time per Foto (s)","format":"{{msg.payload}}","layout":"row-spread","x":1090,"y":60,"wires":[]},{"id":"7b91243b.3ea26c","type":"ui_button","z":"2d99e20d.5e48ee","name":"","group":"66fc75c9.2e33fc","order":8,"width":0,"height":0,"passthru":false,"label":"Start Routine","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":90,"y":260,"wires":[["120dd629.e543ea"]]},{"id":"c572b48b.e18948","type":"file","z":"2d99e20d.5e48ee","name":"","filename":"/home/pi/shared/log/releasetime_ext.log","appendNewline":false,"createDir":true,"overwriteFile":"true","encoding":"none","x":820,"y":100,"wires":[["c61f37b3.d7e2f8"]]},{"id":"df1102c4.06896","type":"file in","z":"2d99e20d.5e48ee","name":"","filename":"/home/pi/shared/log/releasetime_ext.log","format":"lines","chunk":false,"sendError":false,"encoding":"none","x":320,"y":100,"wires":[["c0c13bb5.8440b8"]]},{"id":"c0c13bb5.8440b8","type":"ui_slider","z":"2d99e20d.5e48ee","name":"","label":" ","tooltip":"depending on the camera's remote shutter sensitivity, this value might need to be adjusted (50-100ms usually is a good value)","group":"66fc75c9.2e33fc","order":6,"width":0,"height":0,"passthru":true,"outs":"all","topic":"","min":"10","max":"200","step":"10","x":585.9999771118164,"y":100.00000190734863,"wires":[["c572b48b.e18948"]]},{"id":"c61f37b3.d7e2f8","type":"ui_text","z":"2d99e20d.5e48ee","group":"66fc75c9.2e33fc","order":5,"width":0,"height":0,"name":"","label":"Release time (ms)","format":"{{msg.payload}}","layout":"row-spread","x":1090,"y":100,"wires":[]},{"id":"29a33e5f.d0bec2","type":"inject","z":"2d99e20d.5e48ee","name":"","topic":"Repeater","payload":"0.1","payloadType":"str","repeat":"0.5","crontab":"","once":true,"onceDelay":"5","x":100,"y":200,"wires":[["3d6627a6.774d08"]]},{"id":"3d6627a6.774d08","type":"file in","z":"2d99e20d.5e48ee","name":"","filename":"/home/pi/shared/log/currentstatus_ext.log","format":"lines","chunk":false,"sendError":false,"encoding":"none","x":360,"y":200,"wires":[["3b105a60.6f8336"]]},{"id":"3b105a60.6f8336","type":"ui_text","z":"2d99e20d.5e48ee","group":"66fc75c9.2e33fc","order":1,"width":0,"height":0,"name":"","label":"Current Status:","format":"{{msg.payload}}","layout":"row-spread","x":625,"y":200,"wires":[]},{"id":"120dd629.e543ea","type":"python3-function","z":"2d99e20d.5e48ee","name":"Run Routine","func":"import RPi.GPIO as GPIO\nimport time\nimport picamera\nfrom time import sleep\nimport sys\n\nwith open(\"/home/pi/shared/log/releasetime_ext.log\", \"r\") as file:\n releasetime_ext=int(file.read())\nwith open(\"/home/pi/shared/log/timeperfoto_ext.log\", \"r\") as file:\n timeperfoto_ext=float(file.read())\nwith open(\"/home/pi/shared/log/pin_externalcam.log\", \"r\") as file:\n photopin=int(file.read()) \n\n#routine settings\nwith open(\"/home/pi/shared/log/fotosperrotation.log\", \"r\") as file:\n fotosperrotation=int(file.read())\nwith open(\"/home/pi/shared/log/startdeflection.log\", \"r\") as file:\n startdeflection=int(file.read())\nwith open(\"/home/pi/shared/log/verticalpositions.log\", \"r\") as file:\n verticalpositions=int(file.read())\n\nwith open(\"/home/pi/shared/log/pin_rotor_dir.log\", \"r\") as file:\n dirpinrotor=int(file.read())\nwith open(\"/home/pi/shared/log/pin_rotor_step.log\", \"r\") as file:\n steppinrotor=int(file.read())\nwith open(\"/home/pi/shared/log/pin_turntable_dir.log\", \"r\") as file:\n dirpintt=int(file.read())\nwith open(\"/home/pi/shared/log/pin_turntable_step.log\", \"r\") as file:\n steppintt=int(file.read())\nwith open(\"/home/pi/shared/log/rotor_stepsperrotation.log\", \"r\") as file:\n rotorspr=int(file.read())\nwith open(\"/home/pi/shared/log/turntable_stepsperrotation.log\", \"r\") as file:\n ttspr=int(file.read()) \nwith open(\"/home/pi/shared/log/rotor_delay.log\", \"r\") as file:\n delayrotor=float(file.read())\nwith open(\"/home/pi/shared/log/turntable_delay.log\", \"r\") as file:\n delaytt=float(file.read())\nwith open(\"/home/pi/shared/log/turntable_accramp.log\", \"r\") as file:\n ttramp=int(file.read())\nwith open(\"/home/pi/shared/log/turntable_acc.log\", \"r\") as file:\n ttacc=ttramp*float(file.read()) \nwith open(\"/home/pi/shared/log/rotor_accramp.log\", \"r\") as file:\n rotorramp=int(file.read())\nwith open(\"/home/pi/shared/log/rotor_acc.log\", \"r\") as file:\n rotoracc=rotorramp*float(file.read()) \n\n\nwith open(\"/home/pi/shared/log/camera.log\", \"r\") as file:\n test1=file.read()\nwith open(\"/home/pi/shared/log/currentstatus_ext.log\", \"r\") as file:\n test2=file.read()\n\nif test1!=\"External Camera\":\n return\nif test2!=\"--READY--\":\n return\n\nstartdelay = 5\n\nfor i in range(startdelay,0,-1):\n sleep(1)\n with open(\"/home/pi/shared/log/currentstatus_ext.log\", \"w\") as file:\n file.write(\"starting in \"+str(i)+\"s\")\n \n\nstartangle = rotorspr/360*startdeflection\n\nGPIO.setwarnings(False)\nGPIO.setmode(GPIO.BCM)\nGPIO.setup(3, GPIO.OUT)\n\ndef ttrun(step_count):\n GPIO.setup(dirpintt, GPIO.OUT)\n GPIO.setup(steppintt, GPIO.OUT)\n if (step_count>0):\n GPIO.output(dirpintt, GPIO.HIGH)\n if(step_count<0):\n GPIO.output(dirpintt, GPIO.LOW)\n step_count=-step_count\n for x in range(step_count):\n GPIO.output(steppintt, GPIO.HIGH)\n if x<=ttramp and x<=step_count/2:\n delay=delaytt+(ttramp-x)*delaytt/ttacc\n elif step_count-x<=ttramp and x>step_count/2:\n delay=delaytt+(ttramp-step_count+x)*delaytt/ttacc\n sleep(delay)\n GPIO.output(steppintt, GPIO.LOW)\n sleep(delay)\n\ndef rotorrun(step_count):\n GPIO.setup(dirpinrotor, GPIO.OUT)\n GPIO.setup(steppinrotor, GPIO.OUT)\n if (step_count>0):\n GPIO.output(dirpinrotor, GPIO.HIGH)\n if(step_count<0):\n GPIO.output(dirpinrotor, GPIO.LOW)\n step_count=-step_count\n for x in range(step_count):\n GPIO.output(steppinrotor, GPIO.HIGH)\n if x<=rotorramp and x<=step_count/2:\n delay=delayrotor+(rotorramp-x)*delayrotor/rotoracc\n elif step_count-x<=rotorramp and x>step_count/2:\n delay=delayrotor+(rotorramp-step_count+x)*delayrotor/rotoracc\n sleep(delay)\n GPIO.output(steppinrotor, GPIO.LOW)\n sleep(delay)\n\n\ndef stoptest():\n with open(\"/home/pi/shared/log/stopstate_ext.log\", \"r\") as file:\n if (file.read()!=\"stop\"):\n return\n\n with open(\"/home/pi/shared/log/currentstatus_ext.log\", \"w\") as file:\n file.write(\"stopping\")\n\n with open(\"/home/pi/shared/log/currentstatus_ext.log\", \"w\") as file:\n file.write(\"--READY--\")\n with open(\"/home/pi/shared/log/stopstate_ext.log\", \"w\") as file:\n file.write(\"ready\")\n sys.exit()\n\ndef takephoto():\n stoptest()\n GPIO.setup(photopin, GPIO.OUT)\n GPIO.output(photopin, GPIO.HIGH)\n sleep(releasetime_ext*0.001)\n GPIO.output(photopin, GPIO.LOW)\n sleep(timeperfoto_ext)\n stoptest()\n\n\ndef turntablerotation():\n for x in range (fotosperrotation):\n with open(\"/home/pi/shared/log/currentstatus_ext.log\", \"w\") as file:\n file.write(\"Position: \"+str(vertpos)+\"/\"+str(verticalpositions)+\" Foto: \"+str(x+1)+\"/\"+str(fotosperrotation))\n if fotosperrotation!=1:\n ttrun(ttspr/fotosperrotation)\n takephoto()\n\nrotorrun(-startangle)\nfor x in range (verticalpositions-1):\n vertpos = x+1\n turntablerotation()\n if (verticalpositions>1):\n rotorrun(2*startangle/(verticalpositions-1))\nif (verticalpositions==1):\n startangle=-startangle\nvertpos=verticalpositions\nturntablerotation()\nrotorrun(-startangle)\n\nwith open(\"/home/pi/shared/log/currentstatus_ext.log\", \"w\") as file:\n file.write(\"--READY--\")\nreturn msg","outputs":1,"x":281.99995040893555,"y":260.77760791778564,"wires":[[]]},{"id":"51bc53.97f793ac","type":"ui_button","z":"2d99e20d.5e48ee","name":"","group":"66fc75c9.2e33fc","order":9,"width":0,"height":0,"passthru":true,"label":"Stop Routine","tooltip":"","color":"","bgcolor":"","icon":"","payload":"stop","payloadType":"str","topic":"","x":88.99997329711914,"y":312.11102771759033,"wires":[["d0474d84.66165"]]},{"id":"d0474d84.66165","type":"python3-function","z":"2d99e20d.5e48ee","name":"set stop state variables","func":"with open(\"/home/pi/shared/log/currentstatus_ext.log\", \"r\") as file:\n test=file.read()\nif test==\"--READY--\":\n return\n\nwith open(\"/home/pi/shared/log/stopstate_ext.log\", \"w\") as file:\n file.write(\"stop\")\nwith open(\"/home/pi/shared/log/currentstatus_ext.log\", \"w\") as file:\n file.write(\"--stopping--\")","outputs":1,"x":311.00002670288086,"y":312.221745967865,"wires":[[]]},{"id":"fd31005a.52026","type":"python3-function","z":"2d99e20d.5e48ee","name":"set initial variables","func":"with open(\"/home/pi/shared/log/stopstate_ext.log\", \"w\") as file:\n file.write(\"run\")\nwith open(\"/home/pi/shared/log/currentstatus_ext.log\", \"w\") as file:\n file.write(\"--READY--\")\n","outputs":1,"x":250,"y":140,"wires":[[]]},{"id":"772edab5.39d4f4","type":"link in","z":"8f3594bc.ecc048","name":"Reboot","links":["a5ed604d.e6933","79927a77.c4aff4","554933c4.8b6aac","42ee3c4.9dffbc4","3350027c.cfb2fe","c59c8579.dddab8"],"x":115,"y":60,"wires":[["77ff3a1d.cc6224","d448ae83.6e869"]]},{"id":"6eec63ca.790bfc","type":"ui_text","z":"9a152ded.cdff9","group":"f7451b10.d6c048","order":1,"width":0,"height":0,"name":"","label":"","format":" {{msg.payload}} ","layout":"col-center","x":412,"y":239,"wires":[]},{"id":"fdb965c8.f9e728","type":"link in","z":"9a152ded.cdff9","name":"New Update Note","links":["c986d5f5.bba4f8","edf1402c.a1828","da63f320.75bcc","ebdd3932.2c1de8"],"x":75,"y":240,"wires":[["bf89a72f.657c68"]]},{"id":"a3a12a62.452ab8","type":"ui_text","z":"4aee81d.130dd8","group":"ddbd496e.93a288","order":2,"width":0,"height":0,"name":"update text","label":"","format":" {{msg.payload}} ","layout":"row-center","x":170,"y":560,"wires":[]},{"id":"db31530a.7735b","type":"ui_button","z":"4aee81d.130dd8","name":"","group":"ddbd496e.93a288","order":3,"width":0,"height":0,"passthru":false,"label":"Check for Updates","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":170,"y":180,"wires":[["7600f12d.cf32e","501a81c3.027e5"]]},{"id":"51433c54.55af44","type":"link in","z":"4aee81d.130dd8","name":"update","links":["c803000f.cec2e","babe2a6.c6c27d8","29352168.95ba2e","d33997e3.7b5128","1a32f672.50fafa","629556b9.c99758","e4b7a78b.af9278","b039b421.71ff38","d08d2313.3d81c","eb1b989b.411858","bac9b0cb.79a11","bb2e44d.554e4b8","130354ce.aee30b","946280a5.09db7","4c3f489f.1d5368","653f2283.76f41c","84ef5ce6.7d05c","643506b0.145768"],"x":35,"y":560,"wires":[["a3a12a62.452ab8","5a50b653.49be68"]]},{"id":"838f1a14.76d1a8","type":"python3-function","z":"8f3594bc.ecc048","name":"check ssh","func":"\nwith open(\"/home/pi/shared/log/ssh.log\", \"r\") as file:\n state=file.read()\nmsg['payload']=False\nif state==\"true\":\n msg['payload']=True\nreturn msg","outputs":1,"x":260,"y":320,"wires":[["9cec1f3f.50562"]]},{"id":"d81e87b.e11c078","type":"python3-function","z":"8f3594bc.ecc048","name":"check samba","func":"\nwith open(\"/home/pi/shared/log/samba.log\", \"r\") as file:\n state=file.read()\nmsg['payload']=False\nif state==\"true\":\n msg['payload']=True\nreturn msg","outputs":1,"x":270,"y":460,"wires":[["59c337aa.061f38"]]},{"id":"9bba7a4a.e91898","type":"comment","z":"9a152ded.cdff9","name":"Temporäre Änderungen","info":"","x":160,"y":460,"wires":[]},{"id":"62e033ea.54f58c","type":"inject","z":"9a152ded.cdff9","name":"","topic":"","payload":"Started!","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":"0","x":138,"y":539,"wires":[["763eecf.c76f514","72eedb6b.329454"]]},{"id":"29e275a2.469eea","type":"ui_template","z":"4aee81d.130dd8","group":"191e6406.b089ec","name":"Open Manual (EN)","order":1,"width":6,"height":1,"format":"\n \n User Manual (EN)\n
\n","storeOutMessages":false,"fwdInMessages":false,"templateScope":"local","x":110,"y":960,"wires":[[]]},{"id":"ebf60ed3.4c254","type":"python3-function","z":"4aee81d.130dd8","name":"Compare Versions","func":"import os\n\n\nfile = '/home/pi/shared/ui/data/update.log'\nurl = 'https://raw.githubusercontent.com/OpenScanEu/OpenScan/master/update.log'\ntry:\n os.remove(file)\nexcept OSError:\n pass\nos.system('wget -O'+file+' '+url+' >/dev/null 2>&1')\n\n\nwith open(\"/home/pi/shared/ui/data/update.log\", \"r\") as file:\n versionserver=str(file.read())[:16]\nwith open(\"/home/pi/shared/log/currentversion.log\", \"r\") as file:\n versionpi=str(file.read())[:16]\n\nmsg['payload']=\"you are up to date\"\n\nif versionpi!=versionserver:\n file=\"/home/pi/.node-red/flows_raspberrypi_download.json\"\n url=\"https://raw.githubusercontent.com/OpenScanEu/OpenScan/master/update.json\"\n try:\n os.remove(file)\n except OSError:\n pass\n os.system('wget -O'+file+' '+url+' >/dev/null 2>&1')\n\n with open(\"/home/pi/shared/log/currentserverversion.log\", \"w\") as file:\n file.write(versionserver)\n os.rename(\"/home/pi/.node-red/flows_raspberrypi_download.json\",\"/home/pi/shared/ui/data/old_flows/\"+versionserver+\".json\")\n msg['payload']=\"new updates available\"\n\nreturn msg","outputs":1,"x":690,"y":180,"wires":[["d08d2313.3d81c","ccefcc90.280d9","da63f320.75bcc"]]},{"id":"a068495.e7347b8","type":"python3-function","z":"4aee81d.130dd8","name":"autoupdate checker","func":"\nwith open(\"/home/pi/shared/log/autoupdatestate.log\", \"r\") as file:\n autoupdate=file.read()\nmsg['payload']=False\nif autoupdate==\"true\":\n msg['payload']=True\nreturn msg","outputs":1,"x":310,"y":40,"wires":[["4757554e.08088c"]]},{"id":"4757554e.08088c","type":"ui_switch","z":"4aee81d.130dd8","name":"","label":"Auto-check for updates","tooltip":"Enable the auto-update check after starting the device. (Internet connection required)","group":"ddbd496e.93a288","order":1,"width":6,"height":1,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":530,"y":40,"wires":[["8266379e.ed1bb8"]]},{"id":"8266379e.ed1bb8","type":"file","z":"4aee81d.130dd8","name":"","filename":"/home/pi/shared/log/autoupdatestate.log","appendNewline":false,"createDir":true,"overwriteFile":"true","encoding":"none","x":820,"y":40,"wires":[[]]},{"id":"69253358.bf412c","type":"inject","z":"4aee81d.130dd8","name":"","topic":"","payload":"Started!","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":"2","x":100,"y":40,"wires":[["a068495.e7347b8","302f3bb7.a86654","954bf550.aa5088"]]},{"id":"302f3bb7.a86654","type":"python3-function","z":"4aee81d.130dd8","name":"update check on?","func":"\nwith open(\"/home/pi/shared/log/autoupdatestate.log\", \"r\") as file:\n autoupdate=file.read()\nif autoupdate==\"true\":\n msg['payload']=\"on\"\n return msg\n","outputs":1,"x":310,"y":80,"wires":[["501a81c3.027e5"]]},{"id":"d08d2313.3d81c","type":"link out","z":"4aee81d.130dd8","name":"","links":["51433c54.55af44"],"x":935,"y":140,"wires":[]},{"id":"7600f12d.cf32e","type":"function","z":"4aee81d.130dd8","name":"msg","func":"msg.payload =\"checking for updates\"\nreturn msg;","outputs":1,"noerr":0,"x":350,"y":220,"wires":[["eb1b989b.411858"]]},{"id":"eb1b989b.411858","type":"link out","z":"4aee81d.130dd8","name":"","links":["51433c54.55af44"],"x":475,"y":220,"wires":[]},{"id":"ba6a944f.28fbf8","type":"ui_text","z":"4aee81d.130dd8","group":"3ce32450.e0cffc","order":1,"width":0,"height":0,"name":"Your version:","label":"Your version:","format":"{{msg.payload}}","layout":"row-spread","x":330,"y":300,"wires":[]},{"id":"147a8c8b.02d703","type":"ui_text","z":"4aee81d.130dd8","group":"3ce32450.e0cffc","order":2,"width":0,"height":0,"name":"","label":"Most recent version:","format":"{{msg.payload}}","layout":"row-spread","x":360,"y":340,"wires":[]},{"id":"78fe77ae.637248","type":"python3-function","z":"4aee81d.130dd8","name":"msg","func":"\nwith open(\"/home/pi/shared/log/currentversion.log\", \"r\") as file:\n msg['payload']=file.read()\nreturn msg","outputs":1,"x":190,"y":300,"wires":[["ba6a944f.28fbf8"]]},{"id":"8f30cdc7.d8d0a","type":"python3-function","z":"4aee81d.130dd8","name":"msg","func":"\nwith open(\"/home/pi/shared/log/currentserverversion.log\", \"r\") as file:\n msg['payload']=file.read()\nreturn msg","outputs":1,"x":190,"y":340,"wires":[["147a8c8b.02d703"]]},{"id":"53d30b48.e7c2b4","type":"function","z":"4aee81d.130dd8","name":"msg","func":"msg.payload =\"installing new version\"\nreturn msg\n\n","outputs":1,"noerr":0,"x":910,"y":580,"wires":[["bb2e44d.554e4b8"]]},{"id":"7e517945.e751d8","type":"exec","z":"4aee81d.130dd8","command":"","addpay":true,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"install update","x":910,"y":480,"wires":[[],[],[]]},{"id":"bb2e44d.554e4b8","type":"link out","z":"4aee81d.130dd8","name":"","links":["51433c54.55af44"],"x":1055,"y":580,"wires":[]},{"id":"130354ce.aee30b","type":"link out","z":"4aee81d.130dd8","name":"","links":["51433c54.55af44"],"x":1055,"y":500,"wires":[]},{"id":"59489284.99141c","type":"python3-function","z":"4aee81d.130dd8","name":"msg","func":"from time import sleep\nwith open(\"/home/pi/shared/log/currentversion.log\", \"w\") as file:\n file.write(msg['payload2'])\n\nsleep(2)\nmsg['payload']=\"rebooting...\"\nreturn msg","outputs":1,"x":910,"y":540,"wires":[["130354ce.aee30b","fdbb71b7.ca9b4","a5ed604d.e6933"]]},{"id":"da63f320.75bcc","type":"link out","z":"4aee81d.130dd8","name":"","links":["fdb965c8.f9e728","e5e35ad0.2dbfd8"],"x":935,"y":220,"wires":[]},{"id":"a5ed604d.e6933","type":"link out","z":"4aee81d.130dd8","name":"","links":["772edab5.39d4f4"],"x":1055,"y":540,"wires":[]},{"id":"4ceab067.7b4f1","type":"ui_template","z":"9a152ded.cdff9","group":"ceb0b5fe.bdd2f8","name":"Background","order":1,"width":0,"height":0,"format":"","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":132,"y":340,"wires":[[]]},{"id":"ff84cab3.4d3968","type":"ui_ui_control","z":"9a152ded.cdff9","name":"","events":"all","x":420,"y":280,"wires":[[]]},{"id":"bf89a72f.657c68","type":"function","z":"9a152ded.cdff9","name":"hide/show text","func":"var oldmsg={payload:msg.payload};\n\n\nif (msg.payload===\"\"){\n msg.payload={\"group\":{\"hide\":[\"Start_Start\"]}};\n return [oldmsg,msg];}\nelse{\n msg.payload={\"group\":{\"show\":[\"Start_Start\"]}};\n}\nreturn [oldmsg,msg];\n","outputs":2,"noerr":0,"x":220,"y":240,"wires":[["6eec63ca.790bfc"],["ff84cab3.4d3968"]]},{"id":"f0569a11.933c38","type":"comment","z":"9a152ded.cdff9","name":"--------------------------------- TO DO ---------------------------------","info":"add tooltip everywhere\n\nsettings menu --> add cam parameters\n camera orientation\n color shift?!?\n \nbluetooth functionality","x":230,"y":41,"wires":[]},{"id":"349202ab.786d7e","type":"exec","z":"9a152ded.cdff9","command":"sudo chmod -R 777 /home/pi/shared/","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"set privileges","x":710,"y":480,"wires":[[],[],[]]},{"id":"7aae1e89.08d37","type":"function","z":"4aee81d.130dd8","name":"t/f","func":"if (msg.payload === true){\n msg.payload=true\n return [msg,null]\n}\nmsg.payload=\"no internet connection\"\nreturn [null,msg]\n","outputs":2,"noerr":0,"x":510,"y":180,"wires":[["ebf60ed3.4c254"],["eb1b989b.411858"]]},{"id":"f1bbe902.de5cd8","type":"link in","z":"4aee81d.130dd8","name":"Version","links":["ccefcc90.280d9","954bf550.aa5088","fdbb71b7.ca9b4"],"x":55,"y":300,"wires":[["78fe77ae.637248","8f30cdc7.d8d0a","f1199151.89ef6"]]},{"id":"ccefcc90.280d9","type":"link out","z":"4aee81d.130dd8","name":"","links":["f1bbe902.de5cd8","3a8b7430.734eec","d3eaeac4.a1c968"],"x":935,"y":180,"wires":[]},{"id":"954bf550.aa5088","type":"link out","z":"4aee81d.130dd8","name":"","links":["f1bbe902.de5cd8","3a8b7430.734eec","d3eaeac4.a1c968"],"x":175,"y":80,"wires":[]},{"id":"f1199151.89ef6","type":"python3-function","z":"4aee81d.130dd8","name":"display changelog","func":"with open(\"/home/pi/shared/ui/data/update.log\", \"r\") as file:\n text=file.read()\nmsg['payload']=text\nreturn msg","outputs":1,"x":230,"y":380,"wires":[["e084eb09.ccf548"]]},{"id":"e084eb09.ccf548","type":"ui_template","z":"4aee81d.130dd8","group":"3ce32450.e0cffc","name":"changelog","order":3,"width":16,"height":6,"format":"\n\n\n \n
","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":410,"y":380,"wires":[[]]},{"id":"8dd53d39.02c9e","type":"inject","z":"4aee81d.130dd8","name":"","topic":"Repeater","payload":"0.1","payloadType":"str","repeat":"5","crontab":"","once":true,"onceDelay":"0.1","x":120,"y":460,"wires":[["f1375b38.dc3fa8"]]},{"id":"f1375b38.dc3fa8","type":"function","z":"4aee81d.130dd8","name":"","func":"msg.path = \"shared/ui/data/old_flows\"\n\nreturn msg;","outputs":1,"noerr":0,"x":270,"y":460,"wires":[["44261472.44725c"]]},{"id":"44261472.44725c","type":"fs-ops-dir","z":"4aee81d.130dd8","name":"/media/pi/","path":"path","pathType":"msg","filter":"*","filterType":"str","dir":"files","dirType":"msg","x":420,"y":460,"wires":[["ddda14d1.b827e8"]]},{"id":"ddda14d1.b827e8","type":"ui_template","z":"4aee81d.130dd8","group":"ddbd496e.93a288","name":"File List + Install Version","order":4,"width":6,"height":6,"format":"\n\n\n\n
\n\n
\n \n install version\n
\n\n
\n","storeOutMessages":false,"fwdInMessages":false,"templateScope":"local","x":410,"y":500,"wires":[["44261472.44725c","7d89da4a.3689b4"]]},{"id":"c8844641.814568","type":"python3-function","z":"4aee81d.130dd8","name":"init exec","func":"if msg['payload']!=\"Yes\":\n return\npayload=msg['file']\n\nif payload==\"saved.json\":\n msg['payload']=\"sudo \\cp /home/pi/shared/ui/data/old_flows/\"+payload+\" /home/pi/.node-red/flows_raspberrypi.json\"\nelse:\n msg['payload']=\"sudo \\cp /home/pi/.node-red/flows_raspberrypi.json /home/pi/shared/ui/data/old_flows/saved.json && sudo \\cp /home/pi/shared/ui/data/old_flows/\"+payload+\" /home/pi/.node-red/flows_raspberrypi.json\"\n\nmsg['payload2']=payload[:16]\nreturn msg\n\n","outputs":1,"x":780,"y":540,"wires":[["7e517945.e751d8","59489284.99141c","53d30b48.e7c2b4"]]},{"id":"fdbb71b7.ca9b4","type":"link out","z":"4aee81d.130dd8","name":"","links":["f1bbe902.de5cd8","3a8b7430.734eec","d3eaeac4.a1c968"],"x":1055,"y":460,"wires":[]},{"id":"501a81c3.027e5","type":"is online","z":"4aee81d.130dd8","name":"","url":"www.google.com","action":"0","x":360,"y":180,"wires":[["7aae1e89.08d37","3bc9635e.c9683c"]]},{"id":"b9a7fb02.25c808","type":"ui_template","z":"4aee81d.130dd8","group":"191e6406.b089ec","name":"Syslog","order":7,"width":0,"height":0,"format":"\n \n Download Syslog\n
\n","storeOutMessages":false,"fwdInMessages":false,"templateScope":"local","x":810,"y":740,"wires":[[]]},{"id":"19c289e1.e54d16","type":"ui_switch","z":"4aee81d.130dd8","name":"","label":"Open Syslog","tooltip":"","group":"191e6406.b089ec","order":6,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":350,"y":740,"wires":[["4d9394a.735df6c"]]},{"id":"4d9394a.735df6c","type":"function","z":"4aee81d.130dd8","name":"","func":"var msg2 = { payload: \"sudo \\cp /var/log/syslog /home/pi/shared/ui/data/syslog.txt && sudo chmod a+rwx /home/pi/shared/ui/data/syslog.txt\"};\nif (msg.payload===true){\n msg.color = \"white\"\n msg.backgroundcolor=\"default\"\n msg.disable=false\n return [msg,msg2];\n}\nmsg.color = \"white\"\nmsg.backgroundcolor =\"white\"\nmsg.disable=true\nreturn [msg,null];","outputs":2,"noerr":0,"x":490,"y":740,"wires":[["bd3f9d51.4a861"],["11654c19.ec7f24"]]},{"id":"11654c19.ec7f24","type":"exec","z":"4aee81d.130dd8","command":"","addpay":true,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"get syslog","x":620,"y":800,"wires":[[],[],["d1c636fb.679d28"]]},{"id":"bd3f9d51.4a861","type":"delay","z":"4aee81d.130dd8","name":"","pauseType":"delay","timeout":"0.5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":650,"y":740,"wires":[["b9a7fb02.25c808"]]},{"id":"d1c636fb.679d28","type":"python3-function","z":"4aee81d.130dd8","name":"msg","func":"\nwith open(\"/home/pi/shared/log/currentversion.log\", \"r\") as file:\n msg['payload']=\">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Version in use: \"+file.read()\nreturn msg","outputs":1,"x":750,"y":800,"wires":[["172470f8.a4b5af"]]},{"id":"172470f8.a4b5af","type":"file","z":"4aee81d.130dd8","name":"","filename":"/home/pi/shared/ui/data/syslog.txt","appendNewline":true,"createDir":false,"overwriteFile":"false","encoding":"none","x":960,"y":800,"wires":[[]]},{"id":"2c6ca9d5.f0aca6","type":"function","z":"4aee81d.130dd8","name":"","func":"msg.payload=false\nreturn msg;","outputs":1,"noerr":0,"x":210,"y":740,"wires":[["19c289e1.e54d16"]]},{"id":"873c1379.6273d","type":"inject","z":"4aee81d.130dd8","name":"","topic":"","payload":"Started!","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":"","x":80,"y":740,"wires":[["2c6ca9d5.f0aca6","49b1a90e.262018"]]},{"id":"424a81dd.252ca","type":"ui_button","z":"4aee81d.130dd8","name":"","group":"ddbd496e.93a288","order":5,"width":0,"height":0,"passthru":false,"label":"Save current Version","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":120,"y":680,"wires":[["ed696308.dfe92"]]},{"id":"ed696308.dfe92","type":"python3-function","z":"4aee81d.130dd8","name":"save","func":"import time\nimport shutil\ntimestamp =time.strftime(\"20%y-%m-%d_%H.%M.\")\nsource = \"/home/pi/.node-red/flows_raspberrypi.json\"\ndestination = \"/home/pi/shared/ui/data/old_flows/saved-\"+timestamp+\"json\"\ndest = shutil.copyfile(source, destination) \n","outputs":1,"x":310,"y":680,"wires":[[]]},{"id":"8d6dd445.0f5498","type":"ui_template","z":"a946aea5.fe7cb","group":"3e00b4d5.2a3f8c","name":"","order":1,"width":13,"height":12,"format":" \n
\n Controlling a smartphone via the RPi bluetooth is not available YET. Anyway, you can trigger your smartphone via an external remote shutter control using the \"External Camera\" tab\n
\n\n\nPossible approach:
\nIn order to trigger an android camera, the keystroke \"Enter\" has to be send. To trigger the Iphone \"Volume UP\" is needed. See the following link for more details on one of those little bluetooth triggers. It works by emulating a bluetooth keyboard and sending the according two keystrokes:
\nSelfie stick remote shutter control\nIn order to setup the RPi the following library could be used, but I did not manage to send the according keystrokes. See the comment section for some further insight of what I've tried so far:
\nBluetooth HID for RPi\nIf you want to help, please feel free to contact me via email: info@openscan.eu
","storeOutMessages":true,"fwdInMessages":false,"templateScope":"local","x":140,"y":60,"wires":[[]]},{"id":"763eecf.c76f514","type":"exec","z":"9a152ded.cdff9","command":"pip3 search gphoto2","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"test if gphoto exists","x":390,"y":640,"wires":[["f19652f5.0a57c"],[],[]]},{"id":"7a8569e1.9ba768","type":"exec","z":"9a152ded.cdff9","command":"sudo pip install gphoto2","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"sudo pip install gphoto2","x":611,"y":880,"wires":[["a15f9bb9.d0e558","892b97b0.795318"],[],[]]},{"id":"a15f9bb9.d0e558","type":"exec","z":"9a152ded.cdff9","command":"sudo pip3 install gphoto2","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"sudo pip3 install gphoto2","x":611,"y":940,"wires":[["154c7a60.ca2b36"],[],[]]},{"id":"a01bfa4.ac3eb08","type":"python3-function","z":"9a152ded.cdff9","name":"msg","func":"msg['payload']=\"-- DO NOT TURN OFF THE DEVICE -- ______Installing Updates part 4/6______ ______This might take some time______\"\nmsg['color']=\"red\"\nreturn msg","outputs":1,"x":831,"y":820,"wires":[["f22d9f33.63d9b","4c3f489f.1d5368"]]},{"id":"4783e9da.73ace8","type":"inject","z":"adecba7c.a89278","name":"","topic":"","payload":"Started!","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":"","x":100,"y":60,"wires":[["8fc04df7.e0772","34f47.5fb920b9a","8c39a1b1.dc25","f71c7986.048d08","98260f7a.dd3f5"]]},{"id":"f7ce1f74.a1119","type":"ui_button","z":"adecba7c.a89278","name":"","group":"56fe100.930a8f","order":9,"width":6,"height":1,"passthru":true,"label":"Start Routine","tooltip":"","color":"","bgcolor":"","icon":"","payload":"starten","payloadType":"str","topic":"","x":570,"y":660,"wires":[["70dcdb07.fb3874"]]},{"id":"4a4b76a.cd8ef88","type":"ui_button","z":"adecba7c.a89278","name":"","group":"71843631.f4d5f8","order":3,"width":6,"height":1,"passthru":false,"label":"Update Preview","tooltip":"press to show the effect of changed settings (takes one second to load)","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":100,"y":460,"wires":[["fb907bd4.39d1c8"]]},{"id":"70dcdb07.fb3874","type":"python3-function","z":"adecba7c.a89278","name":"Run Routine","func":"import RPi.GPIO as GPIO\nimport time\nimport picamera\nfrom time import sleep\nimport gphoto2 as gp\nfrom subprocess import call\nimport sys\n\n# Zip-packer\nimport os\nimport shutil\nfrom os import path\nfrom zipfile import ZipFile\nfrom os import path\nfrom shutil import make_archive\nfrom PIL import Image\n\nwith open(\"/home/pi/shared/log/currentstatus_gp.log\", \"r\") as file:\n test=file.read()\nif test!=\"error, try restart\" and test!=\"--READY--\":\n return\n\n\n#routine settings\nwith open(\"/home/pi/shared/log/fotosperrotation.log\", \"r\") as file:\n fotosperrotation=int(file.read())\nwith open(\"/home/pi/shared/log/startdeflection.log\", \"r\") as file:\n startdeflection=int(file.read())\nwith open(\"/home/pi/shared/log/verticalpositions.log\", \"r\") as file:\n verticalpositions=int(file.read())\nwith open(\"/home/pi/shared/log/projectname.log\", \"r\") as file:\n projectname=file.read()\n\nwith open(\"/home/pi/shared/log/pin_rotor_dir.log\", \"r\") as file:\n dirpinrotor=int(file.read())\nwith open(\"/home/pi/shared/log/pin_rotor_step.log\", \"r\") as file:\n steppinrotor=int(file.read())\nwith open(\"/home/pi/shared/log/pin_turntable_dir.log\", \"r\") as file:\n dirpintt=int(file.read())\nwith open(\"/home/pi/shared/log/pin_turntable_step.log\", \"r\") as file:\n steppintt=int(file.read())\nwith open(\"/home/pi/shared/log/rotor_stepsperrotation.log\", \"r\") as file:\n rotorspr=int(file.read())\nwith open(\"/home/pi/shared/log/turntable_stepsperrotation.log\", \"r\") as file:\n ttspr=int(file.read()) \nwith open(\"/home/pi/shared/log/rotor_delay.log\", \"r\") as file:\n delayrotor=float(file.read())\nwith open(\"/home/pi/shared/log/turntable_delay.log\", \"r\") as file:\n delaytt=float(file.read()) \nwith open(\"/home/pi/shared/log/turntable_accramp.log\", \"r\") as file:\n ttramp=int(file.read())\nwith open(\"/home/pi/shared/log/turntable_acc.log\", \"r\") as file:\n ttacc=ttramp*float(file.read()) \nwith open(\"/home/pi/shared/log/rotor_accramp.log\", \"r\") as file:\n rotorramp=int(file.read())\nwith open(\"/home/pi/shared/log/rotor_acc.log\", \"r\") as file:\n rotoracc=rotorramp*float(file.read()) \n\nstartangle = rotorspr/360*startdeflection\nprojectcode =time.strftime(\"20%y-%m-%d %H.%M.%S - \")+projectname+'/'\ndirname='./shared/'+projectcode\nos.makedirs(dirname) \n\nGPIO.setwarnings(False)\nGPIO.setmode(GPIO.BCM)\nGPIO.setup(3, GPIO.OUT)\n\ndef ttrun(step_count):\n stoptest()\n GPIO.setup(dirpintt, GPIO.OUT)\n GPIO.setup(steppintt, GPIO.OUT)\n if (step_count>0):\n GPIO.output(dirpintt, GPIO.HIGH)\n if(step_count<0):\n GPIO.output(dirpintt, GPIO.LOW)\n step_count=-step_count\n for x in range(step_count):\n GPIO.output(steppintt, GPIO.HIGH)\n if x<=ttramp and x<=step_count/2:\n delay=delaytt+(ttramp-x)*delaytt/ttacc\n elif step_count-x<=ttramp and x>step_count/2:\n delay=delaytt+(ttramp-step_count+x)*delaytt/ttacc\n sleep(delay)\n GPIO.output(steppintt, GPIO.LOW)\n sleep(delay)\n\ndef rotorrun(step_count):\n stoptest()\n GPIO.setup(dirpinrotor, GPIO.OUT)\n GPIO.setup(steppinrotor, GPIO.OUT)\n if (step_count>0):\n GPIO.output(dirpinrotor, GPIO.HIGH)\n if(step_count<0):\n GPIO.output(dirpinrotor, GPIO.LOW)\n step_count=-step_count\n for x in range(step_count):\n GPIO.output(steppinrotor, GPIO.HIGH)\n if x<=rotorramp and x<=step_count/2:\n delay=delayrotor+(rotorramp-x)*delayrotor/rotoracc\n elif step_count-x<=rotorramp and x>step_count/2:\n delay=delayrotor+(rotorramp-step_count+x)*delayrotor/rotoracc\n sleep(delay)\n GPIO.output(steppinrotor, GPIO.LOW)\n sleep(delay)\n\ndef crop(filepath):\n with open(\"/home/pi/shared/log/cropx_gp.log\", \"r\") as file:\n cropx=int(file.read())\n with open(\"/home/pi/shared/log/cropy_gp.log\", \"r\") as file:\n cropy=int(file.read()) \n\n img = Image.open(filepath)\n width, height = img.size \n\n left = width*cropx/100\n top = height*cropy/100\n right = width*(100-cropx)/100\n bottom = height*(100-cropy)/100\n img= img.crop((left,top,right,bottom))\n img.save(filepath,quality=100)\n zoom=min(float(cropx)/50,float(cropy)/50)\n img = img.resize((int(float(600-12*cropx)/(1-zoom)), int(float(450-9*cropy)/(1-zoom))))\n img.save('./shared/ui/data/preview2.jpg')\n img.close()\n\ndef updatepreview():\n with open(\"/home/pi/shared/log/updatepreview_gp.log\", \"w\") as file:\n file.write(time.strftime(\"20%y-%m-%d_%H-%M-%S\"))\n\ndef stoptest():\n with open(\"/home/pi/shared/log/stopstate_gp.log\", \"r\") as file:\n if (file.read()!=\"stop\"):\n return\n saveparameters()\n with open(\"/home/pi/shared/log/stopstate_gp.log\", \"w\") as file:\n file.write(\"ready\")\n sys.exit()\n\ndef takephoto():\n stoptest()\n\n timestamp= time.strftime(\"20%y-%m-%d_%H-%M-%S\")\n filepath = dirname+'/'+ timestamp + \".jpg\"\n \n call ([\"gphoto2\",\"--capture-image-and-download\",\"--filename\", filepath])\n\n try:\n img = Image.open(filepath)\n except:\n with open(\"/home/pi/shared/log/currentstatus_gp.log\", \"w\") as file:\n file.write(\"error, try restart\")\n end()\n\n crop(filepath)\n zip(filepath)\n updatepreview()\n\ndef turntablerotation():\n\n for x in range (fotosperrotation):\n with open(\"/home/pi/shared/log/currentstatus_gp.log\", \"w\") as file:\n file.write(\"Position: \"+str(vertpos)+\"/\"+str(verticalpositions)+\" Foto: \"+str(x+1)+\"/\"+str(fotosperrotation))\n if fotosperrotation!=1:\n ttrun(ttspr/fotosperrotation)\n takephoto()\n\ndef saveparameters():\n os.mknod(dirname+\"/parameters.txt\")\n\n with open(\"/home/pi/shared/log/cameracontrast.log\", \"r\") as file:\n cameracontrast=int(file.read())\n with open(\"/home/pi/shared/log/camerabrightness.log\", \"r\") as file:\n camerabrightness=int(file.read())\n with open(\"/home/pi/shared/log/shutterspeed.log\", \"r\") as file:\n shutterspeed=int(file.read())\n\n with open(dirname+\"/parameters.txt\", \"w\") as file:\n file.write(\"Settings for OpenScanPi;\\n\")\n file.write(\"projectname;\"+str(projectname)+\"\\n\")\n file.write(\"fotosperrotation;\"+str(fotosperrotation)+\"\\n\")\n file.write(\"startdeflection;\"+str(startdeflection)+\"\\n\")\n file.write(\"verticalpositions;\"+str(verticalpositions)+\"\\n\")\n\n shutil.move('shared/temp.zip','shared/ui/data/zip/'+projectcode[:-1]+'.zip')\n shutil.rmtree(dirname)\n \n with open(\"/home/pi/shared/log/currentstatus_gp.log\", \"w\") as file:\n file.write(\"--READY--\")\n\ndef zip(filepath):\n with ZipFile(\"/home/pi/shared/temp.zip\", \"a\") as zip:\n zip.write(filepath, os.path.basename(filepath))\n os.remove(filepath)\n\nrotorrun(-startangle)\nfor x in range (verticalpositions-1):\n vertpos = x+1\n turntablerotation()\n if (verticalpositions>1):\n rotorrun(2*startangle/(verticalpositions-1))\nif (verticalpositions==1):\n startangle=-startangle\nvertpos=verticalpositions\nturntablerotation()\nrotorrun(-startangle)\n\nsaveparameters()\n\nreturn msg","outputs":1,"x":770,"y":660,"wires":[[]]},{"id":"8fc04df7.e0772","type":"function","z":"adecba7c.a89278","name":"Reset Project Name","func":"msg.payload=\"default\"\nreturn msg;","outputs":1,"noerr":0,"x":320,"y":120,"wires":[["b66ee693.2db0a8","4ef658ef.62e888"]]},{"id":"b66ee693.2db0a8","type":"ui_text_input","z":"adecba7c.a89278","name":"","label":"Project Name","tooltip":"enter project name + press enter","group":"56fe100.930a8f","order":2,"width":6,"height":1,"passthru":true,"mode":"text","delay":"300","topic":"","x":600,"y":120,"wires":[["4ef658ef.62e888"]]},{"id":"4ef658ef.62e888","type":"file","z":"adecba7c.a89278","name":"","filename":"/home/pi/shared/log/projectname.log","appendNewline":false,"createDir":true,"overwriteFile":"true","encoding":"none","x":850,"y":120,"wires":[[]]},{"id":"49d32163.4df36","type":"function","z":"adecba7c.a89278","name":"timestamp pic file","func":"var d = new Date();\nvar n = d.getTime();\nmsg.payload = \"/ui/data/preview2.jpg?ts=\" + n;\nreturn msg;","outputs":1,"noerr":0,"x":870,"y":460,"wires":[["92fc912c.20d9b"]]},{"id":"92fc912c.20d9b","type":"ui_template","z":"adecba7c.a89278","group":"71843631.f4d5f8","name":"preview","order":1,"width":15,"height":11,"format":"\n","storeOutMessages":false,"fwdInMessages":false,"templateScope":"local","x":1064,"y":460,"wires":[[]]},{"id":"49367924.ea1338","type":"python3-function","z":"adecba7c.a89278","name":"Take Preview Shot","func":"import io\nimport logging\nimport os\nimport subprocess\nimport sys\nimport random\n\nfrom PIL import Image\n\nimport gphoto2 as gp\n\nwith open(\"/home/pi/shared/log/camera.log\", \"r\") as file:\n if file.read()!=\"GPhoto2\":\n return\n\nwith open(\"/home/pi/shared/log/currentstatus_gp.log\", \"r\") as file:\n val= file.read()\n if val==\"creating zip file\" or val[:3]==\"Pos\":\n return\n\ncamera = gp.check_result(gp.gp_camera_new())\ntry:\n gp.check_result(gp.gp_camera_init(camera))\nexcept:\n with open(\"/home/pi/shared/log/currentstatus_gp.log\", \"w\") as file:\n file.write(\"no camera found\")\n return msg\nwith open(\"/home/pi/shared/log/currentstatus_gp.log\", \"w\") as file:\n file.write(\"--READY--\")\n\ndef crop(filepath):\n with open(\"/home/pi/shared/log/cropx_gp.log\", \"r\") as file:\n cropx=int(file.read())\n with open(\"/home/pi/shared/log/cropy_gp.log\", \"r\") as file:\n cropy=int(file.read()) \n img = Image.open(filepath)\n width, height = img.size \n\n left = width*cropx/100\n top = height*cropy/100\n right = width*(100-cropx)/100\n bottom = height*(100-cropy)/100\n img= img.crop((left,top,right,bottom))\n img.save(filepath)\n zoom=min(float(cropx)/50,float(cropy)/50)\n img = img.resize((int(float(600-12*cropx)/(1-zoom)), int(float(450-9*cropy)/(1-zoom))))\n img.save('./shared/ui/data/preview.jpg')\n img.close()\n\nconfig = gp.check_result(gp.gp_camera_get_config(camera))\nOK, image_format = gp.gp_widget_get_child_by_name(config, 'imageformat')\nif OK >= gp.GP_OK:\n value = gp.check_result(gp.gp_widget_get_value(image_format))\n if 'raw' in value.lower():\n return \nOK, capture_size_class = gp.gp_widget_get_child_by_name(\n config, 'capturesizeclass')\nif OK >= gp.GP_OK:\n value = gp.check_result(gp.gp_widget_get_choice(capture_size_class, 2))\n gp.check_result(gp.gp_widget_set_value(capture_size_class, value))\n gp.check_result(gp.gp_camera_set_config(camera, config))\ncamera_file = gp.check_result(gp.gp_camera_capture_preview(camera))\nfile_data = gp.check_result(gp.gp_file_get_data_and_size(camera_file))\ndata = memoryview(file_data)\n\ntarget = '/home/pi/shared/ui/data/preview2.jpg'\ncamera_file.save(target)\ncrop(\"./shared/ui/data/preview2.jpg\")\n\ngp.check_result(gp.gp_camera_exit(camera))\n\nreturn msg","outputs":1,"x":610,"y":460,"wires":[["49d32163.4df36"]]},{"id":"58bcbb07.93c134","type":"comment","z":"adecba7c.a89278","name":"System","info":"","x":81.99996948242188,"y":3069.004035949707,"wires":[]},{"id":"fb907bd4.39d1c8","type":"delay","z":"adecba7c.a89278","name":"","pauseType":"rate","timeout":"0.1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1.5","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":370,"y":460,"wires":[["49367924.ea1338"]]},{"id":"34f47.5fb920b9a","type":"exec","z":"adecba7c.a89278","command":"sudo rm -rf -d /home/pi/shared/ui/data/preview2.jpg","addpay":true,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":410,"y":60,"wires":[[],[],[]]},{"id":"5700d959.d01f28","type":"file in","z":"adecba7c.a89278","name":"","filename":"/home/pi/shared/log/currentstatus_gp.log","format":"lines","chunk":false,"sendError":false,"encoding":"none","x":380,"y":360,"wires":[["bc2a8a13.0a5878"]]},{"id":"748eca47.a660c4","type":"ui_text","z":"adecba7c.a89278","group":"56fe100.930a8f","order":1,"width":6,"height":1,"name":"","label":"Current Status:","format":" {{msg.payload}} ","layout":"row-spread","x":780,"y":360,"wires":[]},{"id":"81594d46.2d45b","type":"inject","z":"adecba7c.a89278","name":"","topic":"Repeater","payload":"0.5","payloadType":"str","repeat":"0.5","crontab":"","once":true,"onceDelay":"1","x":100,"y":360,"wires":[["5700d959.d01f28","c07d1e6b.954a2"]]},{"id":"c07d1e6b.954a2","type":"file in","z":"adecba7c.a89278","name":"","filename":"/home/pi/shared/log/updatepreview_gp.log","format":"lines","chunk":false,"sendError":false,"encoding":"none","x":380,"y":400,"wires":[["ebb89f55.4e211"]]},{"id":"ebb89f55.4e211","type":"function","z":"adecba7c.a89278","name":"check preview mod","func":"if (msg.payload!=global.get(\"updatepreview_gp\")){\n return msg\n}\n","outputs":1,"noerr":0,"x":670,"y":400,"wires":[["49d32163.4df36","bfe4d7c8.e1e618"]]},{"id":"7a4ffa47.d7dcc4","type":"ui_button","z":"adecba7c.a89278","name":"","group":"56fe100.930a8f","order":10,"width":6,"height":1,"passthru":true,"label":"Stop Routine","tooltip":"","color":"","bgcolor":"","icon":"","payload":"stop","payloadType":"str","topic":"","x":95.01732063293457,"y":660.7881126403809,"wires":[["d78dbeeb.14941"]]},{"id":"2ec25eee.175402","type":"link in","z":"adecba7c.a89278","name":"Update Preview GPhoto","links":["4bafeaee.da8274","e24779c5.096f48","1519cfac.723f1","1a794560.38424b","bb4b43c8.b49e7","4dd988ea.280aa8"],"x":215,"y":500,"wires":[["fb907bd4.39d1c8"]]},{"id":"8c39a1b1.dc25","type":"python3-function","z":"adecba7c.a89278","name":"set initial variables","func":"import subprocess\nimport gphoto2 as gp\n\nwith open(\"/home/pi/shared/log/stopstate_gp.log\", \"w\") as file:\n file.write(\"run\")\nwith open(\"/home/pi/shared/log/updatepreview_gp.log\", \"w\") as file:\n file.write(\"start\")\n\ncamera = gp.check_result(gp.gp_camera_new())\ntry:\n gp.check_result(gp.gp_camera_init(camera))\nexcept:\n with open(\"/home/pi/shared/log/currentstatus_gp.log\", \"w\") as file:\n file.write(\"no camera found\")\n return msg\nwith open(\"/home/pi/shared/log/currentstatus_gp.log\", \"w\") as file:\n file.write(\"--READY--\")","outputs":1,"x":310,"y":160,"wires":[[]]},{"id":"d78dbeeb.14941","type":"python3-function","z":"adecba7c.a89278","name":"set stop state variables","func":"with open(\"/home/pi/shared/log/currentstatus_gp.log\", \"r\") as file:\n test=file.read()\nif test==\"error, try restart\" or test==\"--READY--\" or test==\"no camera found\":\n return\n\nwith open(\"/home/pi/shared/log/stopstate_gp.log\", \"w\") as file:\n file.write(\"stop\")\nwith open(\"/home/pi/shared/log/currentstatus_gp.log\", \"w\") as file:\n file.write(\"--stopping--\")","outputs":1,"x":317.0173740386963,"y":660.8988308906555,"wires":[[]]},{"id":"bfe4d7c8.e1e618","type":"change","z":"adecba7c.a89278","name":"","rules":[{"t":"set","p":"updatepreview_gp","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":930,"y":400,"wires":[[]]},{"id":"61447c12.f8fdd4","type":"exec","z":"9a152ded.cdff9","command":"sudo apt install libgphoto2-dev -y","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"sudo apt install libgphoto2-dev","x":631,"y":760,"wires":[["24352bf6.07a994","9a10fb89.168a68"],[],[]]},{"id":"24352bf6.07a994","type":"exec","z":"9a152ded.cdff9","command":"sudo apt install gphoto2 -y","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"sudo apt install gphoto2","x":611,"y":820,"wires":[["7a8569e1.9ba768","a01bfa4.ac3eb08"],[],[]]},{"id":"afdecbd5.af9e38","type":"exec","z":"9a152ded.cdff9","command":"sudo apt-get update","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"sudo apt-get update","x":601,"y":700,"wires":[["61447c12.f8fdd4","e2a2cb15.5c9448"],[],[]]},{"id":"f19652f5.0a57c","type":"python3-function","z":"9a152ded.cdff9","name":"download gphoto","func":"if str(msg['payload'])[57:66]==\"INSTALLED\":\n return\n\nreturn msg","outputs":1,"x":593,"y":640,"wires":[["afdecbd5.af9e38","b3884b46.5aa5e8"]]},{"id":"9a10fb89.168a68","type":"python3-function","z":"9a152ded.cdff9","name":"msg","func":"msg['payload']=\"-- DO NOT TURN OFF THE DEVICE -- ______Installing Updates part 3/6______ ______This might take some time______\"\nmsg['color']=\"red\"\nreturn msg","outputs":1,"x":831,"y":760,"wires":[["f22d9f33.63d9b","4c3f489f.1d5368"]]},{"id":"f22d9f33.63d9b","type":"link out","z":"9a152ded.cdff9","name":"","links":["e5e35ad0.2dbfd8"],"x":1056,"y":780,"wires":[]},{"id":"e2a2cb15.5c9448","type":"python3-function","z":"9a152ded.cdff9","name":"msg","func":"msg['payload']=\"-- DO NOT TURN OFF THE DEVICE -- ______Installing Updates part 2/6______ ______This might take some time______\"\nmsg['color']=\"red\"\nreturn msg","outputs":1,"x":831,"y":700,"wires":[["f22d9f33.63d9b","4c3f489f.1d5368"]]},{"id":"b3884b46.5aa5e8","type":"python3-function","z":"9a152ded.cdff9","name":"msg","func":"msg['payload']=\"-- DO NOT TURN OFF THE DEVICE -- ______Installing Updates part 1/6______ ______This might take some time______\"\nmsg['color']=\"red\"\nreturn msg","outputs":1,"x":831,"y":640,"wires":[["f22d9f33.63d9b","4c3f489f.1d5368"]]},{"id":"892b97b0.795318","type":"python3-function","z":"9a152ded.cdff9","name":"msg","func":"msg['payload']=\"-- DO NOT TURN OFF THE DEVICE -- ______Installing Updates part 5/6______ ______This might take some time______\"\nmsg['color']=\"red\"\nreturn msg","outputs":1,"x":831,"y":880,"wires":[["f22d9f33.63d9b","4c3f489f.1d5368"]]},{"id":"154c7a60.ca2b36","type":"python3-function","z":"9a152ded.cdff9","name":"msg","func":"msg['payload']=\"-- DO NOT TURN OFF THE DEVICE -- ______Installing Updates part 6/6______ ______This might take some time______\"\nmsg['color']=\"red\"\nreturn msg","outputs":1,"x":831,"y":940,"wires":[["f22d9f33.63d9b","bdbf5e2c.d1a06","4c3f489f.1d5368"]]},{"id":"beb4de45.e8465","type":"python3-function","z":"9a152ded.cdff9","name":"download gphoto","func":"if str(msg['payload'])[57:66]==\"INSTALLED\":\n msg['payload']=\"All updates ready :)\"\n return msg\n\nmsg['payload']=\"install failed - please restart\"\nmsg['color']=\"red\"\nreturn msg","outputs":1,"x":791,"y":1000,"wires":[["f22d9f33.63d9b","4c3f489f.1d5368"]]},{"id":"bdbf5e2c.d1a06","type":"exec","z":"9a152ded.cdff9","command":"pip3 search gphoto2","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"test if gphoto exists","x":591,"y":1000,"wires":[["beb4de45.e8465"],[],[]]},{"id":"4c3f489f.1d5368","type":"link out","z":"9a152ded.cdff9","name":"","links":["51433c54.55af44"],"x":1056,"y":820,"wires":[]},{"id":"2f2a39be.258576","type":"ui_dropdown","z":"1f55eb2e.158f95","name":"Camera Type","label":"Camera:","tooltip":"Select the Camera you want to use","place":"---Select---","group":"3aee2d1a.bc7412","order":1,"width":0,"height":0,"passthru":true,"options":[{"label":"Raspberry Pi","value":"RPi Camera","type":"str"},{"label":"USB (DSLR)","value":"GPhoto2","type":"str"},{"label":"External","value":"External Camera","type":"str"},{"label":"Smartphone","value":"Smartphone","type":"str"}],"payload":"","topic":"","x":400,"y":60,"wires":[["e24779c5.096f48","a9bdd24a.bbfa6"]]},{"id":"a3a57181.bcbcd","type":"inject","z":"1f55eb2e.158f95","name":"","topic":"","payload":"Started!","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":"1","x":80,"y":60,"wires":[["134da78d.c277d8","a26aec9b.220d6","7b310945.697638"]]},{"id":"a9bdd24a.bbfa6","type":"python3-function","z":"1f55eb2e.158f95","name":"","func":"from time import sleep\n\nsleep(0.2)\n\nwith open(\"/home/pi/shared/log/camera.log\", \"w\") as file:\n file.write(msg['payload'])\n\nif msg['payload']==\"Smartphone\":\n msg['payload']={\"group\":{\"show\":[\"Camera_Settings_Smartphone\"],\"hide\":[\"Camera_Data\",\"Camera_Settings_RPi\",\"Camera_Settings_External_Camera\",\"Camera_Settings_Gphoto2\",\"Camera_Preview_RPi\",\"Camera_Preview_GPhoto2\"]}}\nelif msg['payload']==\"External Camera\":\n msg['payload']={\"group\":{\"show\":[\"Camera_Settings_External_Camera\"],\"hide\":[\"Camera_Data\",\"Camera_Settings_RPi\",\"Camera_Settings_Gphoto2\",\"Camera_Settings_Smartphone\",\"Camera_Preview_RPi\",\"Camera_Preview_GPhoto2\"]}}\nelif msg['payload']==\"RPi Camera\":\n msg['payload']={\"group\":{\"show\":[\"Camera_Settings_RPi\",\"Camera_Preview_RPi\",\"Camera_Data\"],\"hide\":[\"Camera_Settings_External_Camera\",\"Camera_Settings_Gphoto2\",\"Camera_Settings_Smartphone\",\"Camera_Preview_GPhoto2\"]}}\nelif msg['payload']==\"GPhoto2\":\n msg['payload']={\"group\":{\"show\":[\"Camera_Data\",\"Camera_Settings_Gphoto2\",\"Camera_Preview_GPhoto2\"],\"hide\":[\"Camera_Settings_RPi\",\"Camera_Settings_External_Camera\",\"Camera_Settings_Smartphone\",\"Camera_Preview_RPi\"]}}\nelse:\n msg['payload']={\"group\":{\"hide\":[\"Camera_Data\",\"Camera_Settings_RPi\",\"Camera_Settings_External_Camera\",\"Camera_Settings_Gphoto2\",\"Camera_Settings_Smartphone\",\"Camera_Preview_RPi\",\"Camera_Preview_GPhoto2\"]}}\nreturn msg","outputs":1,"x":590,"y":60,"wires":[["621d4ad0.a9bb24"]]},{"id":"621d4ad0.a9bb24","type":"ui_ui_control","z":"1f55eb2e.158f95","name":"","events":"all","x":760,"y":60,"wires":[[]]},{"id":"8f1e7089.edfd4","type":"file in","z":"1f55eb2e.158f95","name":"","filename":"/home/pi/shared/log/fotosperrotation.log","format":"","chunk":false,"sendError":false,"encoding":"none","x":360,"y":180,"wires":[["352f66f.c4ec79a"]]},{"id":"9971dca.1f0b42","type":"file in","z":"1f55eb2e.158f95","name":"","filename":"/home/pi/shared/log/verticalpositions.log","format":"","chunk":false,"sendError":false,"encoding":"none","x":360,"y":220,"wires":[["dd3c93e0.5e8d9"]]},{"id":"f94d10ff.8f30e","type":"file in","z":"1f55eb2e.158f95","name":"","filename":"/home/pi/shared/log/startdeflection.log","format":"","chunk":false,"sendError":false,"encoding":"none","x":350,"y":260,"wires":[["116b21c4.513e1e"]]},{"id":"116b21c4.513e1e","type":"ui_slider","z":"1f55eb2e.158f95","name":"","label":"","tooltip":"set start deflection angle","group":"3aee2d1a.bc7412","order":16,"width":0,"height":0,"passthru":true,"outs":"all","topic":"","min":"0","max":"90","step":1,"x":590,"y":260,"wires":[["756e38e.dfabbc8"]]},{"id":"3c4a41a9.9bbebe","type":"ui_text","z":"1f55eb2e.158f95","group":"3aee2d1a.bc7412","order":15,"width":0,"height":0,"name":"","label":"Start Deflection:","format":"{{msg.payload}}","layout":"row-spread","x":1100,"y":260,"wires":[]},{"id":"dd3c93e0.5e8d9","type":"ui_slider","z":"1f55eb2e.158f95","name":"","label":" ","tooltip":"set the number of vertical positions","group":"3aee2d1a.bc7412","order":18,"width":0,"height":0,"passthru":true,"outs":"all","topic":"","min":"1","max":"20","step":1,"x":590,"y":220,"wires":[["e90a6011.107b4"]]},{"id":"e90a6011.107b4","type":"file","z":"1f55eb2e.158f95","name":"","filename":"/home/pi/shared/log/verticalpositions.log","appendNewline":false,"createDir":true,"overwriteFile":"true","encoding":"none","x":821.9999961853027,"y":220.00000190734863,"wires":[["e88dfc5a.7084a"]]},{"id":"352f66f.c4ec79a","type":"ui_slider","z":"1f55eb2e.158f95","name":"","label":"","tooltip":" set the number of photos per turntable rotation","group":"3aee2d1a.bc7412","order":14,"width":0,"height":0,"passthru":true,"outs":"all","topic":"","min":"1","max":"60","step":1,"x":590,"y":180,"wires":[["c2f7f451.9b3608"]]},{"id":"c2f7f451.9b3608","type":"file","z":"1f55eb2e.158f95","name":"","filename":"/home/pi/shared/log/fotosperrotation.log","appendNewline":false,"createDir":true,"overwriteFile":"true","encoding":"none","x":821.9999771118164,"y":180.0000021457672,"wires":[["2cbedf87.9eb02"]]},{"id":"756e38e.dfabbc8","type":"python3-function","z":"1f55eb2e.158f95","name":"add unit","func":"deflection=str(msg['payload'])\nwith open(\"/home/pi/shared/log/startdeflection.log\", \"w\") as file:\n file.write(deflection)\nmsg['payload']=deflection+'°'\nreturn msg","outputs":1,"x":735.9999542236328,"y":260.01039695739746,"wires":[["3c4a41a9.9bbebe"]]},{"id":"e88dfc5a.7084a","type":"ui_text","z":"1f55eb2e.158f95","group":"3aee2d1a.bc7412","order":17,"width":0,"height":0,"name":"","label":"Vertical Positions:","format":"{{msg.payload}}","layout":"row-spread","x":1110,"y":220,"wires":[]},{"id":"2cbedf87.9eb02","type":"ui_text","z":"1f55eb2e.158f95","group":"3aee2d1a.bc7412","order":13,"width":0,"height":0,"name":"","label":"Photos per Rotation:","format":"{{msg.payload}}","layout":"row-spread","x":1120,"y":180,"wires":[]},{"id":"70425769.71eae8","type":"inject","z":"1f55eb2e.158f95","name":"","topic":"","payload":"Started!","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":"1","x":80,"y":140,"wires":[["8f1e7089.edfd4","9971dca.1f0b42","f94d10ff.8f30e"]]},{"id":"711b6e5c.5e763","type":"ui_button","z":"1f55eb2e.158f95","name":"","group":"3aee2d1a.bc7412","order":7,"width":2,"height":1,"passthru":false,"label":"⇐","tooltip":"Move turntable right","color":"","bgcolor":"","icon":"","payload":"200","payloadType":"num","topic":"","x":590,"y":520,"wires":[["5b89e67d.f7e898"]]},{"id":"6347eac4.da5e94","type":"ui_button","z":"1f55eb2e.158f95","name":"","group":"3aee2d1a.bc7412","order":8,"width":2,"height":1,"passthru":false,"label":"⇒","tooltip":"Move turntable left","color":"","bgcolor":"","icon":"","payload":"200","payloadType":"num","topic":"","x":590,"y":560,"wires":[["82cad018.f449"]]},{"id":"8e394139.3d5fe","type":"ui_button","z":"1f55eb2e.158f95","name":"","group":"3aee2d1a.bc7412","order":4,"width":2,"height":1,"passthru":false,"label":"⇑","tooltip":"Move rotor up","color":"","bgcolor":"","icon":"","payload":"500","payloadType":"num","topic":"","x":90,"y":520,"wires":[["b058957e.bfd7d8"]]},{"id":"a710b295.35cf3","type":"ui_button","z":"1f55eb2e.158f95","name":"","group":"3aee2d1a.bc7412","order":5,"width":2,"height":1,"passthru":false,"label":"⇓","tooltip":"Move rotor down","color":"","bgcolor":"","icon":"","payload":"200","payloadType":"num","topic":"","x":90,"y":560,"wires":[["d578f8e0.9e6878"]]},{"id":"1e5a566f.c9089a","type":"ui_text","z":"1f55eb2e.158f95","group":"3aee2d1a.bc7412","order":6,"width":2,"height":1,"name":"","label":"Turntable","format":"{{\"\"}}","layout":"row-center","x":580,"y":480,"wires":[]},{"id":"a87a3a22.b88ab8","type":"ui_text","z":"1f55eb2e.158f95","group":"3aee2d1a.bc7412","order":3,"width":2,"height":1,"name":"","label":"Rotor","format":"{{\"\"}}","layout":"row-center","x":90,"y":480,"wires":[]},{"id":"fd861e97.4ecda","type":"python3-function","z":"1f55eb2e.158f95","name":"TT left","func":"from time import sleep\nimport RPi.GPIO as GPIO\nGPIO.setwarnings(False)\n\nwith open(\"/home/pi/shared/log/pin_turntable_step.log\", \"r\") as file:\n STEP=int(file.read())\nwith open(\"/home/pi/shared/log/pin_turntable_dir.log\", \"r\") as file:\n DIR=int(file.read())\nwith open(\"/home/pi/shared/log/turntable_stepsperrotation.log\", \"r\") as file:\n step_count=int(file.read())\nwith open(\"/home/pi/shared/log/turntable_delay.log\", \"r\") as file:\n delaytt=float(file.read())\nwith open(\"/home/pi/shared/log/turntable_angle.log\", \"r\") as file:\n angle=float(file.read())\nwith open(\"/home/pi/shared/log/turntable_accramp.log\", \"r\") as file:\n ramp=int(file.read())\nwith open(\"/home/pi/shared/log/turntable_acc.log\", \"r\") as file:\n acc=ramp*float(file.read()) \n\n\nstep_count=int(step_count*angle/360)\n\nGPIO.setmode(GPIO.BCM)\nGPIO.setup(DIR, GPIO.OUT)\nGPIO.setup(STEP, GPIO.OUT)\nGPIO.output(DIR, 0)\ndelay=delaytt\n\nfor x in range(step_count):\n GPIO.output(STEP, GPIO.HIGH)\n if x<=ramp and x<=step_count/2:\n delay=delaytt+(ramp-x)*delaytt/acc\n elif step_count-x<=ramp and x>step_count/2:\n delay=delaytt+(ramp-step_count+x)*delaytt/acc\n sleep(delay)\n GPIO.output(STEP, GPIO.LOW)\n sleep(delay)\nGPIO.cleanup()\n\nreturn msg\n","outputs":1,"x":851,"y":520,"wires":[["1a794560.38424b"]]},{"id":"c27ffb2f.456ab8","type":"python3-function","z":"1f55eb2e.158f95","name":"TT right","func":"from time import sleep\nimport RPi.GPIO as GPIO\nGPIO.setwarnings(False)\n\nwith open(\"/home/pi/shared/log/pin_turntable_step.log\", \"r\") as file:\n STEP=int(file.read())\nwith open(\"/home/pi/shared/log/pin_turntable_dir.log\", \"r\") as file:\n DIR=int(file.read())\nwith open(\"/home/pi/shared/log/turntable_stepsperrotation.log\", \"r\") as file:\n step_count=int(file.read())\nwith open(\"/home/pi/shared/log/turntable_delay.log\", \"r\") as file:\n delaytt=float(file.read())\nwith open(\"/home/pi/shared/log/turntable_angle.log\", \"r\") as file:\n angle=float(file.read())\nwith open(\"/home/pi/shared/log/turntable_accramp.log\", \"r\") as file:\n ramp=int(file.read())\nwith open(\"/home/pi/shared/log/turntable_acc.log\", \"r\") as file:\n acc=ramp*float(file.read()) \n\nstep_count=int(step_count*angle/360)\n\nGPIO.setmode(GPIO.BCM)\nGPIO.setup(DIR, GPIO.OUT)\nGPIO.setup(STEP, GPIO.OUT)\nGPIO.output(DIR, 1)\ndelay=delaytt\n\nfor x in range(step_count):\n GPIO.output(STEP, GPIO.HIGH)\n if x<=ramp and x<=step_count/2:\n delay=delaytt+(ramp-x)*delaytt/acc\n elif step_count-x<=ramp and x>step_count/2:\n delay=delaytt+(ramp-step_count+x)*delaytt/acc\n sleep(delay)\n GPIO.output(STEP, GPIO.LOW)\n sleep(delay)\nGPIO.cleanup()\n\nreturn msg\n","outputs":1,"x":860,"y":560,"wires":[["1a794560.38424b"]]},{"id":"6f7304a1.a68a9c","type":"python3-function","z":"1f55eb2e.158f95","name":"Rotor left","func":"from time import sleep\nimport RPi.GPIO as GPIO\nGPIO.setwarnings(False)\n\nwith open(\"/home/pi/shared/log/pin_rotor_step.log\", \"r\") as file:\n STEP=int(file.read())\nwith open(\"/home/pi/shared/log/pin_rotor_dir.log\", \"r\") as file:\n DIR=int(file.read())\nwith open(\"/home/pi/shared/log/rotor_stepsperrotation.log\", \"r\") as file:\n step_count=int(file.read())\nwith open(\"/home/pi/shared/log/rotor_delay.log\", \"r\") as file:\n delaytt=float(file.read())\n\nwith open(\"/home/pi/shared/log/rotor_angle.log\", \"r\") as file:\n angle=float(file.read())\nwith open(\"/home/pi/shared/log/rotor_accramp.log\", \"r\") as file:\n ramp=int(file.read())\nwith open(\"/home/pi/shared/log/rotor_acc.log\", \"r\") as file:\n acc=ramp*float(file.read()) \n\nstep_count=int(step_count*angle/360)\n\nGPIO.setmode(GPIO.BCM)\nGPIO.setup(DIR, GPIO.OUT)\nGPIO.setup(STEP, GPIO.OUT)\nGPIO.output(DIR, 0)\n\nfor x in range(step_count):\n GPIO.output(STEP, GPIO.HIGH)\n if x<=ramp and x<=step_count/2:\n delay=delaytt+(ramp-x)*delaytt/acc\n elif step_count-x<=ramp and x>step_count/2:\n delay=delaytt+(ramp-step_count+x)*delaytt/acc\n sleep(delay)\n GPIO.output(STEP, GPIO.LOW)\n sleep(delay)\nGPIO.cleanup()\n\nreturn msg","outputs":1,"x":360,"y":520,"wires":[["1519cfac.723f1"]]},{"id":"daa346ef.853ca8","type":"python3-function","z":"1f55eb2e.158f95","name":"Rotor right","func":"from time import sleep\nimport RPi.GPIO as GPIO\nGPIO.setwarnings(False)\n\nwith open(\"/home/pi/shared/log/pin_rotor_step.log\", \"r\") as file:\n STEP=int(file.read())\nwith open(\"/home/pi/shared/log/pin_rotor_dir.log\", \"r\") as file:\n DIR=int(file.read())\nwith open(\"/home/pi/shared/log/rotor_stepsperrotation.log\", \"r\") as file:\n step_count=int(file.read())\nwith open(\"/home/pi/shared/log/rotor_delay.log\", \"r\") as file:\n delaytt=float(file.read())\nwith open(\"/home/pi/shared/log/rotor_angle.log\", \"r\") as file:\n angle=float(file.read())\nwith open(\"/home/pi/shared/log/rotor_accramp.log\", \"r\") as file:\n ramp=int(file.read())\nwith open(\"/home/pi/shared/log/rotor_acc.log\", \"r\") as file:\n acc=ramp*float(file.read()) \n\nstep_count=int(step_count*angle/360)\n\nGPIO.setmode(GPIO.BCM)\nGPIO.setup(DIR, GPIO.OUT)\nGPIO.setup(STEP, GPIO.OUT)\nGPIO.output(DIR, 1)\n\nfor x in range(step_count):\n GPIO.output(STEP, GPIO.HIGH)\n if x<=ramp and x<=step_count/2:\n delay=delaytt+(ramp-x)*delaytt/acc\n elif step_count-x<=ramp and x>step_count/2:\n delay=delaytt+(ramp-step_count+x)*delaytt/acc\n sleep(delay)\n GPIO.output(STEP, GPIO.LOW)\n sleep(delay)\nGPIO.cleanup()\n\nreturn msg","outputs":1,"x":370,"y":560,"wires":[["1519cfac.723f1"]]},{"id":"1a794560.38424b","type":"link out","z":"1f55eb2e.158f95","name":"","links":["2ec25eee.175402","35a36b3b.902074"],"x":955,"y":540,"wires":[]},{"id":"1519cfac.723f1","type":"link out","z":"1f55eb2e.158f95","name":"","links":["2ec25eee.175402","35a36b3b.902074"],"x":475,"y":540,"wires":[]},{"id":"b058957e.bfd7d8","type":"delay","z":"1f55eb2e.158f95","name":"lmt 0.2/s","pauseType":"rate","timeout":"0.1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"0.2","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":220,"y":520,"wires":[["6f7304a1.a68a9c"]]},{"id":"d578f8e0.9e6878","type":"delay","z":"1f55eb2e.158f95","name":"lmt 0.2/s","pauseType":"rate","timeout":"0.1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"0.2","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":220,"y":560,"wires":[["daa346ef.853ca8"]]},{"id":"5b89e67d.f7e898","type":"delay","z":"1f55eb2e.158f95","name":"lmt 0.2/s","pauseType":"rate","timeout":"0.1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"0.2","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":720,"y":520,"wires":[["fd861e97.4ecda"]]},{"id":"82cad018.f449","type":"delay","z":"1f55eb2e.158f95","name":"lmt 0.2/s","pauseType":"rate","timeout":"0.1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"0.2","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":720,"y":560,"wires":[["c27ffb2f.456ab8"]]},{"id":"7b310945.697638","type":"python3-function","z":"1f55eb2e.158f95","name":"","func":"with open(\"/home/pi/shared/log/camera.log\", \"r\") as file:\n msg['payload']=file.read()\nreturn msg\n","outputs":1,"x":250,"y":60,"wires":[["2f2a39be.258576"]]},{"id":"66357140.37739","type":"ui_template","z":"1f55eb2e.158f95","group":"e76adf89.87655","name":"Display File List","order":1,"width":6,"height":6,"format":"\n\n\n\n\n
\n \n Download File\n
\n\n
\n\n\n\n
\n\n","storeOutMessages":false,"fwdInMessages":false,"templateScope":"local","x":420,"y":740,"wires":[["f719a7d4.4488b8"]]},{"id":"f719a7d4.4488b8","type":"fs-ops-dir","z":"1f55eb2e.158f95","name":"/media/pi/","path":"path","pathType":"msg","filter":"*","filterType":"str","dir":"files","dirType":"msg","x":421,"y":700,"wires":[["66357140.37739"]]},{"id":"13e2ff06.88df81","type":"function","z":"1f55eb2e.158f95","name":"","func":"msg.path = \"shared/ui/data/zip\"\n\nreturn msg;","outputs":1,"noerr":0,"x":250,"y":700,"wires":[["f719a7d4.4488b8"]]},{"id":"61356f0c.3b55d","type":"inject","z":"1f55eb2e.158f95","name":"repeat 1","topic":"Repeater","payload":"0.2","payloadType":"str","repeat":"1","crontab":"","once":true,"onceDelay":"3","x":100,"y":700,"wires":[["13e2ff06.88df81"]]},{"id":"fce5ff1c.67c6c","type":"ui_button","z":"1f55eb2e.158f95","name":"Delete old files","group":"e76adf89.87655","order":2,"width":6,"height":1,"passthru":false,"label":"{{msg.payload}}","tooltip":"This can not be undone","color":"red","bgcolor":"lightblue","icon":"","payload":"Delete all local image files?","payloadType":"str","topic":"","x":420,"y":800,"wires":[["aadcd2c5.04031"]]},{"id":"f8d302ca.0ee51","type":"exec","z":"1f55eb2e.158f95","command":"","addpay":true,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":930,"y":800,"wires":[[],[],[]]},{"id":"81ad690b.b58088","type":"python3-function","z":"1f55eb2e.158f95","name":"check if busy","func":"with open(\"/home/pi/shared/log/currentstatus_rpi.log\", \"r\") as file:\n state=file.read()\nif state==\"--READY--\":\n if msg['payload']!=\"Yes\":\n return\n msg['payload']=\"sudo rm -rf -d /home/pi/shared/ui/data/zip/*.zip && sudo rm -rf /home/pi/shared/20*/\"\n return msg\nreturn","outputs":1,"x":770,"y":800,"wires":[["f8d302ca.0ee51"]]},{"id":"65d9d42c.47ea3c","type":"inject","z":"1f55eb2e.158f95","name":"repeat 10","topic":"","payload":"","payloadType":"date","repeat":"10","crontab":"","once":true,"onceDelay":"1","x":110,"y":800,"wires":[["4c388fc5.ca13e"]]},{"id":"fa8c625c.095dd","type":"ui_switch","z":"2fb4a0.ab59cb6","name":"","label":"Auto Update Preview","tooltip":"This will update the preview every 2s","group":"b0cc7e63.5b5b3","order":6,"width":5,"height":1,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"on","onvalueType":"str","onicon":"","oncolor":"","offvalue":"off","offvalueType":"str","officon":"","offcolor":"","x":520,"y":980,"wires":[["727f8c51.9ca2a4"]]},{"id":"727f8c51.9ca2a4","type":"change","z":"2fb4a0.ab59cb6","name":"","rules":[{"t":"set","p":"autoupdate","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":750,"y":980,"wires":[[]]},{"id":"e24779c5.096f48","type":"link out","z":"1f55eb2e.158f95","name":"","links":["2ec25eee.175402","35a36b3b.902074","673d8724.9543c8"],"x":555,"y":120,"wires":[]},{"id":"ce8d74bd.9d0498","type":"ui_switch","z":"1f55eb2e.158f95","name":"","label":"Light 2","tooltip":"turn second ringlight on/off","group":"3aee2d1a.bc7412","order":11,"width":3,"height":1,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"on","onvalueType":"str","onicon":"","oncolor":"","offvalue":"off","offvalueType":"str","officon":"","offcolor":"","x":430,"y":380,"wires":[["6e6c6c3a.5aee34"]]},{"id":"202bec1a.a3c274","type":"python3-function","z":"1f55eb2e.158f95","name":"Ringlight on/off","func":"from time import sleep\nimport RPi.GPIO as GPIO\n\nwith open(\"/home/pi/shared/log/pin_ringlight2.log\", \"r\") as file:\n ringlightpin=int(file.read())\nwith open(\"/home/pi/shared/log/ringlightstatus2.log\", \"r\") as file:\n state=file.read()\n\nGPIO.setwarnings(False)\nGPIO.setmode(GPIO.BCM)\nGPIO.setup(ringlightpin, GPIO.OUT)\n\nif state == \"on\":\n GPIO.output(ringlightpin, GPIO.HIGH)\nif state == \"off\":\n GPIO.output(ringlightpin, GPIO.LOW)\n\nmsg['payload']=state\n\nreturn msg","outputs":1,"x":280,"y":380,"wires":[["ce8d74bd.9d0498"]]},{"id":"3729d3b3.e74ebc","type":"ui_switch","z":"1f55eb2e.158f95","name":"","label":"Light 1","tooltip":"turn first ringlight on/off","group":"3aee2d1a.bc7412","order":10,"width":3,"height":1,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"on","onvalueType":"str","onicon":"","oncolor":"","offvalue":"off","offvalueType":"str","officon":"","offcolor":"","x":430,"y":320,"wires":[["3110f48c.1112bc"]]},{"id":"43980ca9.f0d904","type":"python3-function","z":"1f55eb2e.158f95","name":"Ringlight on/off","func":"from time import sleep\nimport RPi.GPIO as GPIO\n\nwith open(\"/home/pi/shared/log/pin_ringlight1.log\", \"r\") as file:\n ringlightpin=int(file.read())\nwith open(\"/home/pi/shared/log/ringlightstatus1.log\", \"r\") as file:\n state=file.read()\n\nGPIO.setwarnings(False)\nGPIO.setmode(GPIO.BCM)\nGPIO.setup(ringlightpin, GPIO.OUT)\n\nif state == \"on\":\n GPIO.output(ringlightpin, GPIO.HIGH)\nif state == \"off\":\n GPIO.output(ringlightpin, GPIO.LOW)\n\nmsg['payload']=state\n\nreturn msg","outputs":1,"x":280,"y":320,"wires":[["3729d3b3.e74ebc"]]},{"id":"3110f48c.1112bc","type":"python3-function","z":"1f55eb2e.158f95","name":"Ringlight on/off","func":"\nwith open(\"/home/pi/shared/log/ringlightstatus1.log\", \"r\") as file:\n oldstate=file.read()\nnewstate =msg['payload']\n\nif newstate!=oldstate:\n with open(\"/home/pi/shared/log/ringlightstatus1.log\", \"w\") as file:\n file.write(newstate)\n return msg\n","outputs":1,"x":580,"y":320,"wires":[["bb4b43c8.b49e7","43980ca9.f0d904"]]},{"id":"6e6c6c3a.5aee34","type":"python3-function","z":"1f55eb2e.158f95","name":"Ringlight on/off","func":"\nwith open(\"/home/pi/shared/log/ringlightstatus2.log\", \"r\") as file:\n oldstate=file.read()\nnewstate =msg['payload']\n\nif newstate!=oldstate:\n with open(\"/home/pi/shared/log/ringlightstatus2.log\", \"w\") as file:\n file.write(newstate)\n return msg\n","outputs":1,"x":580,"y":380,"wires":[["bb4b43c8.b49e7","202bec1a.a3c274"]]},{"id":"bb4b43c8.b49e7","type":"link out","z":"1f55eb2e.158f95","name":"","links":["2ec25eee.175402","35a36b3b.902074"],"x":735,"y":320,"wires":[]},{"id":"134da78d.c277d8","type":"python3-function","z":"1f55eb2e.158f95","name":"blink","func":"from time import sleep\nimport RPi.GPIO as GPIO\n\nsleeptime = 0.05\n\nwith open(\"/home/pi/shared/log/pin_ringlight1.log\", \"r\") as file:\n ringlightpin1=int(file.read())\nwith open(\"/home/pi/shared/log/pin_ringlight2.log\", \"r\") as file:\n ringlightpin2=int(file.read())\n\nGPIO.setwarnings(False)\nGPIO.setmode(GPIO.BCM)\nGPIO.setup(ringlightpin1, GPIO.OUT)\nGPIO.setup(ringlightpin2, GPIO.OUT)\nGPIO.output(ringlightpin2, GPIO.LOW)\n\nwith open(\"/home/pi/shared/log/ringlightstatus1.log\", \"w\") as file:\n file.write(\"off\")\nwith open(\"/home/pi/shared/log/ringlightstatus2.log\", \"w\") as file:\n file.write(\"off\")\n\nfor x in range(10):\n GPIO.output(ringlightpin1, GPIO.HIGH)\n sleep(sleeptime)\n GPIO.output(ringlightpin1, GPIO.LOW)\n sleep(sleeptime)\nmsg['payload']=\"off\"\nreturn msg","outputs":1,"x":250,"y":120,"wires":[["e24779c5.096f48"]]},{"id":"98ec4262.3cf8","type":"ui_text","z":"2fb4a0.ab59cb6","group":"a0313e96.486fc","order":5,"width":6,"height":1,"name":"","label":"Shutter Speed","format":"{{msg.payload}}","layout":"row-spread","x":1120,"y":320,"wires":[]},{"id":"ac5d3e50.4cdf6","type":"ui_slider","z":"2fb4a0.ab59cb6","name":"shutter ","label":" ","tooltip":"adjust the camera shutter speed","group":"a0313e96.486fc","order":6,"width":6,"height":1,"passthru":true,"outs":"all","topic":"","min":"1","max":"350","step":"1","x":590,"y":320,"wires":[["b077d034.aa89c"]]},{"id":"74e6fa81.3a52b4","type":"file in","z":"2fb4a0.ab59cb6","name":"","filename":"/home/pi/shared/log/shutterspeed.log","format":"","chunk":false,"sendError":false,"encoding":"none","x":330,"y":320,"wires":[["ac5d3e50.4cdf6"]]},{"id":"8489d6b8.e07288","type":"python3-function","z":"2fb4a0.ab59cb6","name":"msg","func":"msg['payload']=\"off\"\nreturn msg","outputs":1,"x":230,"y":980,"wires":[["fa8c625c.095dd"]]},{"id":"31c04784.2c6708","type":"python3-function","z":"2fb4a0.ab59cb6","name":"color","func":"if msg['payload']==\"no camera found\":\n msg['color']=\"red\"\n pass\nreturn msg","outputs":1,"x":650,"y":540,"wires":[["803f0685.7ab378"]]},{"id":"bc2a8a13.0a5878","type":"python3-function","z":"adecba7c.a89278","name":"color","func":"if msg['payload']==\"no camera found\":\n msg['color']=\"red\"\n pass\nreturn msg","outputs":1,"x":630,"y":360,"wires":[["748eca47.a660c4"]]},{"id":"e5e35ad0.2dbfd8","type":"link in","z":"9a152ded.cdff9","name":"direct status","links":["f22d9f33.63d9b","da63f320.75bcc"],"x":75,"y":280,"wires":[["6eec63ca.790bfc","bf89a72f.657c68"]]},{"id":"c3cb1ec.22720e","type":"ui_button","z":"1f55eb2e.158f95","name":"","group":"3aee2d1a.bc7412","order":22,"width":3,"height":1,"passthru":false,"label":"Shutdown","tooltip":"Use this button to safely shutdown the Raspberry Pi, wait 5-10s before switching of the power","color":"","bgcolor":"","icon":"","payload":"","payloadType":"date","topic":"","x":80,"y":860,"wires":[["7ae412d5.a5f2fc"]]},{"id":"7ae412d5.a5f2fc","type":"link out","z":"1f55eb2e.158f95","name":"","links":["95ecb5c6.d26e58"],"x":215,"y":860,"wires":[]},{"id":"95ecb5c6.d26e58","type":"link in","z":"8f3594bc.ecc048","name":"Shutdown","links":["7ae412d5.a5f2fc"],"x":115,"y":180,"wires":[["77ff3a1d.cc6224","ad1598b6.21bd68"]]},{"id":"a26aec9b.220d6","type":"python3-function","z":"1f55eb2e.158f95","name":"hide on start","func":"from time import sleep\nsleep(0.1)\nmsg['payload']={\"group\":{\"hide\":[\"Camera_Experimental\",\"Camera_Data\",\"Camera_Settings_RPi\",\"Camera_Settings_External_Camera\",\"Camera_Settings_Gphoto2\",\"Camera_Settings_Smartphone\",\"Camera_Preview_RPi\",\"Camera_Preview_GPhoto2\"]}}\nreturn msg","outputs":1,"x":430,"y":20,"wires":[["621d4ad0.a9bb24"]]},{"id":"965fe344.1ce4","type":"subflow:742aa8b9.f0ccc8","z":"1f55eb2e.158f95","name":"upload settings","env":[],"x":100,"y":940,"wires":[["2755fe47.d5fde2"]]},{"id":"d0608dc8.dacfc","type":"http in","z":"742aa8b9.f0ccc8","name":"","url":"/fileupload","method":"post","upload":true,"swaggerDoc":"","x":100,"y":200,"wires":[["dd668f7c.2796f"]]},{"id":"b3044dea.c2fc4","type":"ui_template","z":"742aa8b9.f0ccc8","group":"3aee2d1a.bc7412","name":"Upload","order":21,"width":6,"height":2,"format":"\n\n\n","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":80,"y":160,"wires":[[]]},{"id":"dd668f7c.2796f","type":"change","z":"742aa8b9.f0ccc8","name":"","rules":[{"t":"set","p":"filename","pt":"msg","to":"$env('UPLOAD_DIR') & '/' & req.files[0].originalname","tot":"jsonata"},{"t":"set","p":"payload","pt":"msg","to":"req.files[0].buffer","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":200,"wires":[["1ee0fee1.e535e1"]]},{"id":"1ee0fee1.e535e1","type":"file","z":"742aa8b9.f0ccc8","name":"","filename":"/home/pi/shared/log/loadsettings.log","appendNewline":false,"createDir":false,"overwriteFile":"true","x":571,"y":200,"wires":[["12b4182c.5c1b48","15f80acd.9b9e55"]]},{"id":"efcbec58.ac2c1","type":"link out","z":"2fb4a0.ab59cb6","name":"","links":["35a36b3b.902074","cbe4bd92.d30af"],"x":355,"y":940,"wires":[]},{"id":"7c72651b.35abac","type":"ui_template","z":"9a152ded.cdff9","group":"d8910e38.d12d1","name":"save","order":2,"width":"0","height":"0","format":"\n\n","storeOutMessages":false,"fwdInMessages":false,"templateScope":"global","x":110,"y":140,"wires":[[]]},{"id":"3e7f1f5c.4f409","type":"ui_button","z":"1f55eb2e.158f95","name":"","group":"3aee2d1a.bc7412","order":23,"width":3,"height":1,"passthru":false,"label":"Reboot","tooltip":"Use this button to restart the system. This might take a minute.","color":"","bgcolor":"","icon":"","payload":"","payloadType":"date","topic":"","x":80,"y":900,"wires":[["79927a77.c4aff4"]]},{"id":"79927a77.c4aff4","type":"link out","z":"1f55eb2e.158f95","name":"","links":["772edab5.39d4f4"],"x":215,"y":900,"wires":[]},{"id":"7e910673.79f058","type":"ui_toast","z":"742aa8b9.f0ccc8","position":"bottom right","displayTime":"2","highlight":"","sendall":true,"outputs":0,"ok":"OK","cancel":"","topic":"","name":"","x":790,"y":280,"wires":[]},{"id":"12b4182c.5c1b48","type":"python3-function","z":"742aa8b9.f0ccc8","name":"no/wrong file selected","func":"import filecmp\nimport shutil\nimport os\n\nif msg['filename']==\"./\":\n return msg\nif filecmp.cmp(\"/home/pi/shared/log/loadsettings_save.log\",\"/home/pi/shared/log/loadsettings.log\")==True:\n return\n\nwith open(\"/home/pi/shared/log/loadsettings.log\", \"rw+\") as file:\n commandraw=file.readlines()[0]\n command=commandraw.split(';')\n if command[0]!=\"Settings for OpenScanPi\":\n msg['payload']=\"wrong fileformat\"\n msg['highlight']=\"red\"\n return msg\n\n else:\n length=len(open(\"/home/pi/shared/log/loadsettings.log\").readlines())\n for x in range (1,length):\n with open(\"/home/pi/shared/log/loadsettings.log\", \"rw+\") as file:\n commandraw=file.readlines()[x]\n command=commandraw.split(';')\n if command[0]==\"zoomfactor\":\n command[0]=\"zoom\"\n if command[0]==\"projectname\":\n command[0]=\"skip\"\n try:\n if os.path.isfile(\"/home/pi/shared/log/\"+command[0]+\".log\"):\n with open(\"/home/pi/shared/log/\"+command[0]+\".log\",\"w\") as file:\n file.write(command[1])\n except:\n pass\n shutil.copy(\"/home/pi/shared/log/loadsettings.log\",\"/home/pi/shared/log/loadsettings_save.log\")\n msg['payload']=\"settings loaded\"\n return msg","outputs":1,"x":520,"y":260,"wires":[["7e910673.79f058","cafcb6ac.9d9c98","b95c4eaa.3184f"]]},{"id":"bfb61fa7.66b9b","type":"link in","z":"2fb4a0.ab59cb6","name":"update settings","links":["2755fe47.d5fde2"],"x":95,"y":320,"wires":[["74e6fa81.3a52b4","31c00602.ea26ba","640f4e8d.ce31","8c7bb9c0.9622f8","dd247d5e.6f266"]]},{"id":"bb9d4a2d.8298c8","type":"link in","z":"1f55eb2e.158f95","name":"load settings","links":["2755fe47.d5fde2"],"x":94,"y":259,"wires":[["f94d10ff.8f30e","9971dca.1f0b42","8f1e7089.edfd4"]]},{"id":"2755fe47.d5fde2","type":"link out","z":"1f55eb2e.158f95","name":"","links":["bfb61fa7.66b9b","bb9d4a2d.8298c8"],"x":215,"y":940,"wires":[]},{"id":"cafcb6ac.9d9c98","type":"function","z":"742aa8b9.f0ccc8","name":"","func":"if (msg.payload==\"settings loaded\"){\n var msg1 = { payload:\"settings loaded\" };\n return msg1;\n}","outputs":1,"noerr":0,"x":749,"y":320,"wires":[[]]},{"id":"b95c4eaa.3184f","type":"debug","z":"742aa8b9.f0ccc8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":750,"y":240,"wires":[]},{"id":"15f80acd.9b9e55","type":"debug","z":"742aa8b9.f0ccc8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":830,"y":180,"wires":[]},{"id":"487c5591.71f9dc","type":"python3-function","z":"2fb4a0.ab59cb6","name":"add unit","func":"value=str(msg['payload'])\nwith open(\"/home/pi/shared/log/camerabrightness.log\", \"w\") as file:\n file.write(value)\nmsg['payload']=value+'%'\nreturn msg","outputs":1,"x":740,"y":240,"wires":[["29b36726.080948","529400f0.1e473"]]},{"id":"e226507f.24786","type":"python3-function","z":"2fb4a0.ab59cb6","name":"add unit","func":"value=str(msg['payload'])\nwith open(\"/home/pi/shared/log/cameracontrast.log\", \"w\") as file:\n file.write(value)\nmsg['payload']=value+'%'\nreturn msg","outputs":1,"x":740,"y":280,"wires":[["a9c9d653.6f8cb8","529400f0.1e473"]]},{"id":"b077d034.aa89c","type":"python3-function","z":"2fb4a0.ab59cb6","name":"add unit","func":"value=str(msg['payload'])\nwith open(\"/home/pi/shared/log/shutterspeed.log\", \"w\") as file:\n file.write(value)\nmsg['payload']=str(float(value)/10)+'ms'\nreturn msg","outputs":1,"x":740,"y":320,"wires":[["98ec4262.3cf8","529400f0.1e473"]]},{"id":"cd8fcf3f.ef3d1","type":"ui_text","z":"2fb4a0.ab59cb6","group":"a0313e96.486fc","order":9,"width":6,"height":1,"name":"","label":"Crop X","format":"{{msg.payload}}","layout":"row-spread","x":1090,"y":360,"wires":[]},{"id":"a1e50fb8.9877e","type":"ui_slider","z":"2fb4a0.ab59cb6","name":"cropx","label":" ","tooltip":"Crop the image horizontally ","group":"a0313e96.486fc","order":10,"width":6,"height":1,"passthru":true,"outs":"all","topic":"","min":"0","max":"49","step":"1","x":590,"y":360,"wires":[["e27f139f.e0e7"]]},{"id":"8c7bb9c0.9622f8","type":"file in","z":"2fb4a0.ab59cb6","name":"","filename":"/home/pi/shared/log/cropx.log","format":"","chunk":false,"sendError":false,"encoding":"none","x":300,"y":360,"wires":[["a1e50fb8.9877e"]]},{"id":"e27f139f.e0e7","type":"python3-function","z":"2fb4a0.ab59cb6","name":"add unit","func":"value=str(msg['payload'])\nwith open(\"/home/pi/shared/log/cropx.log\", \"w\") as file:\n file.write(value)\nmsg['payload']=value+\"%\"\nreturn msg","outputs":1,"x":740,"y":360,"wires":[["cd8fcf3f.ef3d1","529400f0.1e473"]]},{"id":"6be89a0c.6c2634","type":"ui_text","z":"2fb4a0.ab59cb6","group":"a0313e96.486fc","order":11,"width":6,"height":1,"name":"","label":"Crop Y","format":"{{msg.payload}}","layout":"row-spread","x":1090,"y":400,"wires":[]},{"id":"19eafb21.e081c5","type":"ui_slider","z":"2fb4a0.ab59cb6","name":"cropy","label":" ","tooltip":"crop the image vertically","group":"a0313e96.486fc","order":12,"width":6,"height":1,"passthru":true,"outs":"all","topic":"","min":"0","max":"49","step":"1","x":590,"y":400,"wires":[["5c2bf332.6e023c"]]},{"id":"dd247d5e.6f266","type":"file in","z":"2fb4a0.ab59cb6","name":"","filename":"/home/pi/shared/log/cropy.log","format":"","chunk":false,"sendError":false,"encoding":"none","x":300,"y":400,"wires":[["19eafb21.e081c5"]]},{"id":"5c2bf332.6e023c","type":"python3-function","z":"2fb4a0.ab59cb6","name":"add unit","func":"value=str(msg['payload'])\nwith open(\"/home/pi/shared/log/cropy.log\", \"w\") as file:\n file.write(value)\nmsg['payload']=value+\"%\"\nreturn msg","outputs":1,"x":740,"y":400,"wires":[["6be89a0c.6c2634","529400f0.1e473"]]},{"id":"5fed957f.32605c","type":"file in","z":"8f3594bc.ecc048","name":"","filename":"/home/pi/shared/log/turntable_accramp.log","format":"lines","chunk":false,"sendError":false,"encoding":"none","x":310,"y":1540,"wires":[["4753306d.3366e"]]},{"id":"8aef4ad5.509ff8","type":"file","z":"8f3594bc.ecc048","name":"","filename":"/home/pi/shared/log/turntable_accramp.log","appendNewline":false,"createDir":true,"overwriteFile":"true","encoding":"none","x":790,"y":1540,"wires":[[]]},{"id":"fea88629.7fba68","type":"ui_text","z":"8f3594bc.ecc048","group":"35a0e31e.2cf06c","order":16,"width":6,"height":1,"name":"","label":"Turntable - Accel. Ramp Width (Steps)","format":"{{msg.payload}}","layout":"row-spread","x":290,"y":1500,"wires":[]},{"id":"8cb7375c.151e58","type":"file in","z":"8f3594bc.ecc048","name":"","filename":"/home/pi/shared/log/turntable_acc.log","format":"lines","chunk":false,"sendError":false,"encoding":"none","x":290,"y":1620,"wires":[["11d3a591.b0c04a"]]},{"id":"9dc0fce1.4a50c","type":"file","z":"8f3594bc.ecc048","name":"","filename":"/home/pi/shared/log/turntable_acc.log","appendNewline":false,"createDir":true,"overwriteFile":"true","encoding":"none","x":770,"y":1620,"wires":[[]]},{"id":"a1607760.8e0808","type":"ui_text","z":"8f3594bc.ecc048","group":"35a0e31e.2cf06c","order":18,"width":6,"height":1,"name":"","label":"Turntable - Accel.","format":"{{msg.payload}}","layout":"row-spread","x":230,"y":1580,"wires":[]},{"id":"4753306d.3366e","type":"ui_slider","z":"8f3594bc.ecc048","name":"","label":"","tooltip":"","group":"35a0e31e.2cf06c","order":17,"width":3,"height":1,"passthru":true,"outs":"end","topic":"","min":"1","max":"400","step":1,"x":550,"y":1540,"wires":[["8aef4ad5.509ff8"]]},{"id":"d60d6a03.0a86b8","type":"ui_text_input","z":"8f3594bc.ecc048","name":"resy","label":"","tooltip":"standard value: 2464","group":"b9933221.eac94","order":5,"width":2,"height":1,"passthru":true,"mode":"text","delay":"0","topic":"","x":550,"y":2380,"wires":[["d96df1e5.775c1"]]},{"id":"fa44fcc9.3da22","type":"ui_text_input","z":"8f3594bc.ecc048","name":"resx","label":"","tooltip":"standard value: 3280","group":"b9933221.eac94","order":3,"width":2,"height":1,"passthru":true,"mode":"text","delay":"0","topic":"","x":550,"y":2300,"wires":[["918e745a.e24398"]]},{"id":"11d3a591.b0c04a","type":"ui_slider","z":"8f3594bc.ecc048","name":"","label":"","tooltip":"","group":"35a0e31e.2cf06c","order":19,"width":3,"height":1,"passthru":true,"outs":"end","topic":"","min":"0.5","max":"3","step":"0.1","x":550,"y":1620,"wires":[["9dc0fce1.4a50c"]]},{"id":"4e7d8497.2592cc","type":"ui_text","z":"8f3594bc.ecc048","group":"35a0e31e.2cf06c","order":14,"width":6,"height":1,"name":"","label":"Turntable - Angle (°)","format":"{{msg.payload}}","layout":"row-spread","x":240,"y":1420,"wires":[]},{"id":"9df8f5c8.66f298","type":"file in","z":"8f3594bc.ecc048","name":"","filename":"/home/pi/shared/log/turntable_angle.log","format":"lines","chunk":false,"sendError":false,"encoding":"none","x":300,"y":1460,"wires":[["1e30dfea.511b2"]]},{"id":"1e30dfea.511b2","type":"ui_slider","z":"8f3594bc.ecc048","name":"angle","label":"","tooltip":"","group":"35a0e31e.2cf06c","order":15,"width":3,"height":1,"passthru":true,"outs":"end","topic":"","min":"1","max":"45","step":"1","x":550,"y":1460,"wires":[["d119c44b.9fd6b8"]]},{"id":"d119c44b.9fd6b8","type":"file","z":"8f3594bc.ecc048","name":"","filename":"/home/pi/shared/log/turntable_angle.log","appendNewline":false,"createDir":true,"overwriteFile":"true","encoding":"none","x":780,"y":1460,"wires":[[]]},{"id":"ffe898e5.260058","type":"link in","z":"8f3594bc.ecc048","name":"Reset Parameters","links":["69a5383d.bc5008","c656ef1a.1470a","5738fde9.d71fa4"],"x":35,"y":1760,"wires":[["2250d4a9.31f69c","5cd9c9a4.0211c8","b9cd3710.227528","af8dc7c4.3d3078","9af4943d.1087a8"]]},{"id":"728dc8b6.5be688","type":"link in","z":"8f3594bc.ecc048","name":"Reset Parameters","links":["69a5383d.bc5008","c656ef1a.1470a","5738fde9.d71fa4"],"x":35,"y":1300,"wires":[["91af0a0.0302bf8","e0e44c.f7272bb8","9df8f5c8.66f298","5fed957f.32605c","8cb7375c.151e58"]]},{"id":"f866730b.71e17","type":"ui_text","z":"8f3594bc.ecc048","group":"35a0e31e.2cf06c","order":25,"width":6,"height":1,"name":"","label":"Rotor - Angle (°)","format":"{{msg.payload}}","layout":"row-spread","x":220,"y":1880,"wires":[]},{"id":"b9cd3710.227528","type":"file in","z":"8f3594bc.ecc048","name":"","filename":"/home/pi/shared/log/rotor_angle.log","format":"lines","chunk":false,"sendError":false,"encoding":"none","x":280,"y":1920,"wires":[["c2a9ff06.428df"]]},{"id":"c2a9ff06.428df","type":"ui_slider","z":"8f3594bc.ecc048","name":"angle","label":"","tooltip":"","group":"35a0e31e.2cf06c","order":26,"width":3,"height":1,"passthru":true,"outs":"end","topic":"","min":"1","max":"15","step":"1","x":550,"y":1920,"wires":[["49cc1266.0803bc"]]},{"id":"49cc1266.0803bc","type":"file","z":"8f3594bc.ecc048","name":"","filename":"/home/pi/shared/log/rotor_angle.log","appendNewline":false,"createDir":true,"overwriteFile":"true","encoding":"none","x":760,"y":1920,"wires":[[]]},{"id":"af8dc7c4.3d3078","type":"file in","z":"8f3594bc.ecc048","name":"","filename":"/home/pi/shared/log/rotor_accramp.log","format":"lines","chunk":false,"sendError":false,"encoding":"none","x":290,"y":2000,"wires":[["a13baabb.129a18"]]},{"id":"ca259e0f.d050b","type":"file","z":"8f3594bc.ecc048","name":"","filename":"/home/pi/shared/log/rotor_accramp.log","appendNewline":false,"createDir":true,"overwriteFile":"true","encoding":"none","x":790,"y":2000,"wires":[[]]},{"id":"4e84f657.0ab5f8","type":"ui_text","z":"8f3594bc.ecc048","group":"35a0e31e.2cf06c","order":27,"width":6,"height":1,"name":"","label":"Rotor - Accel. Ramp Width (Steps)","format":"{{msg.payload}}","layout":"row-spread","x":280,"y":1960,"wires":[]},{"id":"9af4943d.1087a8","type":"file in","z":"8f3594bc.ecc048","name":"","filename":"/home/pi/shared/log/rotor_acc.log","format":"lines","chunk":false,"sendError":false,"encoding":"none","x":280,"y":2080,"wires":[["a06d28e9.ae7878"]]},{"id":"8993a4bc.3dc5e8","type":"file","z":"8f3594bc.ecc048","name":"","filename":"/home/pi/shared/log/rotor_acc.log","appendNewline":false,"createDir":true,"overwriteFile":"true","encoding":"none","x":760,"y":2080,"wires":[[]]},{"id":"75f19acd.b75614","type":"ui_text","z":"8f3594bc.ecc048","group":"35a0e31e.2cf06c","order":29,"width":6,"height":1,"name":"","label":"Rotor - Accel.","format":"{{msg.payload}}","layout":"row-spread","x":220,"y":2040,"wires":[]},{"id":"a13baabb.129a18","type":"ui_slider","z":"8f3594bc.ecc048","name":"r accramp","label":"","tooltip":"","group":"35a0e31e.2cf06c","order":28,"width":3,"height":1,"passthru":true,"outs":"end","topic":"","min":"1","max":"400","step":1,"x":560,"y":2000,"wires":[["ca259e0f.d050b"]]},{"id":"a06d28e9.ae7878","type":"ui_slider","z":"8f3594bc.ecc048","name":"r acc","label":"","tooltip":"","group":"35a0e31e.2cf06c","order":30,"width":3,"height":1,"passthru":true,"outs":"end","topic":"","min":"0.2","max":"3","step":"0.1","x":550,"y":2080,"wires":[["8993a4bc.3dc5e8"]]},{"id":"88db1784.122648","type":"python3-function","z":"adecba7c.a89278","name":"add unit","func":"value=str(msg['payload'])\nwith open(\"/home/pi/shared/log/cropx_gp.log\", \"w\") as file:\n file.write(value)\nmsg['payload']=value+\"%\"\nreturn msg","outputs":1,"x":700,"y":200,"wires":[["257b26b2.474f9a","4dd988ea.280aa8"]]},{"id":"adc7b8e9.7aa638","type":"python3-function","z":"adecba7c.a89278","name":"add unit","func":"value=str(msg['payload'])\nwith open(\"/home/pi/shared/log/cropy_gp.log\", \"w\") as file:\n file.write(value)\nmsg['payload']=value+\"%\"\nreturn msg","outputs":1,"x":700,"y":240,"wires":[["6767f52f.47828c","4dd988ea.280aa8"]]},{"id":"98260f7a.dd3f5","type":"file in","z":"adecba7c.a89278","name":"","filename":"/home/pi/shared/log/cropy_gp.log","format":"","chunk":false,"sendError":false,"encoding":"none","x":360,"y":240,"wires":[["a886a3c8.de827"]]},{"id":"f71c7986.048d08","type":"file in","z":"adecba7c.a89278","name":"","filename":"/home/pi/shared/log/cropx_gp.log","format":"","chunk":false,"sendError":false,"encoding":"none","x":360,"y":200,"wires":[["d54bdece.0d134"]]},{"id":"a886a3c8.de827","type":"ui_slider","z":"adecba7c.a89278","name":"cropy","label":" ","tooltip":"","group":"56fe100.930a8f","order":7,"width":6,"height":1,"passthru":true,"outs":"all","topic":"","min":"0","max":"49","step":"1","x":570,"y":240,"wires":[["adc7b8e9.7aa638"]]},{"id":"d54bdece.0d134","type":"ui_slider","z":"adecba7c.a89278","name":"cropx","label":" ","tooltip":"","group":"56fe100.930a8f","order":5,"width":6,"height":1,"passthru":true,"outs":"all","topic":"","min":"0","max":"49","step":"1","x":570,"y":200,"wires":[["88db1784.122648"]]},{"id":"257b26b2.474f9a","type":"ui_text","z":"adecba7c.a89278","group":"56fe100.930a8f","order":4,"width":6,"height":1,"name":"","label":"Crop X","format":"{{msg.payload}}","layout":"row-spread","x":860,"y":200,"wires":[]},{"id":"6767f52f.47828c","type":"ui_text","z":"adecba7c.a89278","group":"56fe100.930a8f","order":6,"width":6,"height":1,"name":"","label":"Crop Y","format":"{{msg.payload}}","layout":"row-spread","x":850,"y":240,"wires":[]},{"id":"4dd988ea.280aa8","type":"link out","z":"adecba7c.a89278","name":"","links":["2ec25eee.175402"],"x":835,"y":300,"wires":[]},{"id":"3ee52efe.ac9b52","type":"comment","z":"1f55eb2e.158f95","name":"_____________________This is all experimental and might contain some bugs :) :_____________________","info":"","x":390,"y":1180,"wires":[]},{"id":"6b783d94.a31bc4","type":"ui_button","z":"1f55eb2e.158f95","name":"","group":"71ce9ec5.16f49","order":4,"width":0,"height":0,"passthru":false,"label":"Hotspot-Scan","tooltip":"This will perform a scan of 25 images in 5 columns/5rows of +-5° around the current location","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":260,"y":1380,"wires":[["75680f36.91533"]]},{"id":"4f64db4c.310424","type":"python3-function","z":"8f3594bc.ecc048","name":"experimental","func":"\nwith open(\"/home/pi/shared/log/experimentalmode.log\", \"r\") as file:\n state=file.read()\nmsg['payload']=False\nif state==\"True\":\n msg['payload']=True\nreturn msg","outputs":1,"x":270,"y":600,"wires":[["3c3e4cda.5b04c4"]]},{"id":"3c3e4cda.5b04c4","type":"ui_switch","z":"8f3594bc.ecc048","name":"","label":"Experimental Off/On","tooltip":"Turn experimental functions (visible in Raspberry Pi Camera Menu) on or off","group":"ddd1a14a.d7351","order":3,"width":6,"height":1,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":460,"y":600,"wires":[["9a3cb97a.cc34b8"]]},{"id":"9a3cb97a.cc34b8","type":"python3-function","z":"8f3594bc.ecc048","name":"Change mode","func":"value=str(msg['payload'])\nwith open(\"/home/pi/shared/log/experimentalmode.log\", \"w\") as file:\n file.write(value)\nif value==\"True\":\n msg['payload']={\"group\":{\"show\":[\"Camera_Experimental\"]}}\n return msg\nmsg['payload']={\"group\":{\"hide\":[\"Camera_Experimental\"]}}\nreturn msg\n","outputs":1,"x":660,"y":600,"wires":[["f12acf62.482f7"]]},{"id":"5d28ec20.a94814","type":"link in","z":"1f55eb2e.158f95","name":"UI Control_Camera","links":["f12acf62.482f7"],"x":615,"y":120,"wires":[["621d4ad0.a9bb24"]]},{"id":"f12acf62.482f7","type":"link out","z":"8f3594bc.ecc048","name":"","links":["5d28ec20.a94814"],"x":775,"y":600,"wires":[]},{"id":"dfa49377.030fa","type":"ui_template","z":"1f55eb2e.158f95","group":"71ce9ec5.16f49","name":"","order":1,"width":6,"height":6,"format":" \n
\n These are experimental functions for further testing! Beware that there might be some bugs included ;)\n
\n\nHotspot function for RPi-Camera - help to capture areas in more detail.\nTaking x photos in a range of y degree vertically and horizontally around the current position.\n","storeOutMessages":true,"fwdInMessages":false,"templateScope":"local","x":240,"y":1260,"wires":[[]]},{"id":"75680f36.91533","type":"python3-function","z":"1f55eb2e.158f95","name":"Hotspot Scan","func":"import RPi.GPIO as GPIO\nimport time\nimport picamera\nfrom time import sleep\n# Zip-packer\nimport os\nimport shutil\nfrom os import path\nfrom zipfile import ZipFile\nfrom os import path\nfrom shutil import make_archive\nfrom PIL import Image\n\nfrom zipfile import ZipFile\n\n\n\n\n\nwith open(\"/home/pi/shared/log/currentstatus_rpi.log\", \"r\") as file:\n test=file.read()\nif test!=\"no camera found\" and test!=\"--READY--\":\n return\n\n#routine settings\nwith open(\"/home/pi/shared/log/fotosperrotation.log\", \"r\") as file:\n fotosperrotation=int(file.read())\nwith open(\"/home/pi/shared/log/startdeflection.log\", \"r\") as file:\n startdeflection=int(file.read())\nwith open(\"/home/pi/shared/log/verticalpositions.log\", \"r\") as file:\n verticalpositions=int(file.read())\nwith open(\"/home/pi/shared/log/projectname.log\", \"r\") as file:\n projectname=file.read()\n\n# cam settings\nwith open(\"/home/pi/shared/log/camera_resolution_x.log\", \"r\") as file:\n resx=int(file.read())\nwith open(\"/home/pi/shared/log/camera_resolution_y.log\", \"r\") as file:\n resy=int(file.read())\n\n\nwith open(\"/home/pi/shared/log/pin_rotor_dir.log\", \"r\") as file:\n dirpinrotor=int(file.read())\nwith open(\"/home/pi/shared/log/pin_rotor_step.log\", \"r\") as file:\n steppinrotor=int(file.read())\nwith open(\"/home/pi/shared/log/pin_turntable_dir.log\", \"r\") as file:\n dirpintt=int(file.read())\nwith open(\"/home/pi/shared/log/pin_turntable_step.log\", \"r\") as file:\n steppintt=int(file.read())\nwith open(\"/home/pi/shared/log/rotor_stepsperrotation.log\", \"r\") as file:\n rotorspr=int(file.read())\nwith open(\"/home/pi/shared/log/turntable_stepsperrotation.log\", \"r\") as file:\n ttspr=int(file.read()) \nwith open(\"/home/pi/shared/log/rotor_delay.log\", \"r\") as file:\n delayrotor=float(file.read())\nwith open(\"/home/pi/shared/log/turntable_delay.log\", \"r\") as file:\n delaytt=float(file.read()) \nwith open(\"/home/pi/shared/log/turntable_accramp.log\", \"r\") as file:\n ttramp=int(file.read())\nwith open(\"/home/pi/shared/log/turntable_acc.log\", \"r\") as file:\n ttacc=ttramp*float(file.read()) \nwith open(\"/home/pi/shared/log/rotor_accramp.log\", \"r\") as file:\n rotorramp=int(file.read())\nwith open(\"/home/pi/shared/log/rotor_acc.log\", \"r\") as file:\n rotoracc=rotorramp*float(file.read()) \n\nstartangle = rotorspr/360*startdeflection\nprojectcode =time.strftime(\"20%y-%m-%d %H.%M.%S - \")+projectname+'/'\ndirname='./shared/'+projectcode\nos.makedirs(dirname) \n\nGPIO.setwarnings(False)\nGPIO.setmode(GPIO.BCM)\nGPIO.setup(3, GPIO.OUT)\n\nwith open(\"/home/pi/shared/log/hotspot_angle.log\", \"r\") as file:\n deflection=2*int(file.read())\nwith open(\"/home/pi/shared/log/hotspot_photos.log\", \"r\") as file:\n fotosperrotation=int(file.read())\n\nangle=float(deflection)/float(fotosperrotation)\nverticalpositions=fotosperrotation\nstartangle=int(rotorspr/360*deflection)\n\n\ndef ttrun(step_count):\n stoptest()\n GPIO.setup(dirpintt, GPIO.OUT)\n GPIO.setup(steppintt, GPIO.OUT)\n if (step_count>0):\n GPIO.output(dirpintt, GPIO.HIGH)\n if(step_count<0):\n GPIO.output(dirpintt, GPIO.LOW)\n step_count=-step_count\n for x in range(step_count):\n GPIO.output(steppintt, GPIO.HIGH)\n if x<=ttramp and x<=step_count/2:\n delay=delaytt+(ttramp-x)*delaytt/ttacc\n elif step_count-x<=ttramp and x>step_count/2:\n delay=delaytt+(ttramp-step_count+x)*delaytt/ttacc\n sleep(delay)\n GPIO.output(steppintt, GPIO.LOW)\n sleep(delay)\n\ndef rotorrun(step_count):\n stoptest()\n GPIO.setup(dirpinrotor, GPIO.OUT)\n GPIO.setup(steppinrotor, GPIO.OUT)\n if (step_count>0):\n GPIO.output(dirpinrotor, GPIO.HIGH)\n if(step_count<0):\n GPIO.output(dirpinrotor, GPIO.LOW)\n step_count=-step_count\n for x in range(step_count):\n GPIO.output(steppinrotor, GPIO.HIGH)\n if x<=rotorramp and x<=step_count/2:\n delay=delayrotor+(rotorramp-x)*delayrotor/rotoracc\n elif step_count-x<=rotorramp and x>step_count/2:\n delay=delayrotor+(rotorramp-step_count+x)*delayrotor/rotoracc\n sleep(delay)\n GPIO.output(steppinrotor, GPIO.LOW)\n sleep(delay)\n\ndef updatepreview():\n with open(\"/home/pi/shared/log/updatepreview.log\", \"w\") as file:\n file.write(time.strftime(\"20%y-%m-%d_%H-%M-%S\"))\n\ndef stoptest():\n with open(\"/home/pi/shared/log/stopstate.log\", \"r\") as file:\n if (file.read()!=\"stop\"):\n return\n saveparameters()\n with open(\"/home/pi/shared/log/stopstate.log\", \"w\") as file:\n file.write(\"ready\")\n end() \n # producing an error to stop the routine as exit() does not work\n # need to find a better solution ;)\n\ndef takephoto():\n stoptest()\n with picamera.PiCamera() as camera:\n with open(\"/home/pi/shared/log/cameracontrast.log\", \"r\") as file:\n cameracontrast=int(file.read())\n with open(\"/home/pi/shared/log/camerabrightness.log\", \"r\") as file:\n camerabrightness=int(file.read())\n with open(\"/home/pi/shared/log/shutterspeed.log\", \"r\") as file:\n shutterspeed=int(file.read())*100\n camera.iso = 100\n camera.brightness = camerabrightness\n camera.contrast = cameracontrast\n camera.resolution=(resx, resy)\n camera.exposure_compensation = 0 \n timestamp= time.strftime(\"20%y-%m-%d_%H-%M-%S\")\n filepath = dirname+'/'+ timestamp + \".jpg\"\n sleep(0.7)\n camera.awb_mode = 'auto'\n camera.exposure_mode = 'off'\n camera.shutter_speed = shutterspeed\n camera.capture(filepath, quality=100)\n \n crop(filepath)\n zip(filepath)\n camera.close()\n updatepreview()\n\ndef turntablerotation():\n ttrun(int(-ttspr*angle/360*(fotosperrotation-1)/2))\n for x in range (fotosperrotation):\n with open(\"/home/pi/shared/log/currentstatus_rpi.log\", \"w\") as file:\n file.write(\"Position: \"+str(vertpos)+\"/\"+str(verticalpositions)+\" Foto: \"+str(x+1)+\"/\"+str(fotosperrotation))\n ttrun(int(ttspr*angle/360))\n takephoto()\n ttrun(int(-ttspr*angle/360*(fotosperrotation)/2))\n\ndef saveparameters():\n os.mknod(dirname+\"/parameters.txt\")\n\n with open(\"/home/pi/shared/log/cameracontrast.log\", \"r\") as file:\n cameracontrast=int(file.read())\n with open(\"/home/pi/shared/log/camerabrightness.log\", \"r\") as file:\n camerabrightness=int(file.read())\n with open(\"/home/pi/shared/log/shutterspeed.log\", \"r\") as file:\n shutterspeed=int(file.read())\n with open(\"/home/pi/shared/log/cropx.log\", \"r\") as file:\n cropx=int(file.read())\n with open(\"/home/pi/shared/log/cropy.log\", \"r\") as file:\n cropy=int(file.read())\n\n with open(dirname+\"/parameters.txt\", \"w\") as file:\n file.write(\"Settings for OpenScanPi;\\n\")\n file.write(\"projectname;\"+str(projectname)+\"\\n\")\n file.write(\"fotosperrotation;\"+str(fotosperrotation)+\"\\n\")\n file.write(\"startdeflection;\"+str(startdeflection)+\"\\n\")\n file.write(\"verticalpositions;\"+str(verticalpositions)+\"\\n\")\n file.write(\"camerabrightness;\"+str(camerabrightness)+\"\\n\")\n file.write(\"shutterspeed;\"+str(shutterspeed)+\"\\n\")\n file.write(\"cameracontrast;\"+str(cameracontrast)+\"\\n\")\n file.write(\"cropx;\"+str(cropx)+\"\\n\")\n file.write(\"cropy;\"+str(cropy)+\"\\n\")\n\n zip(dirname+\"/parameters.txt\")\n\n shutil.move('shared/temp.zip','shared/ui/data/zip/'+projectcode[:-1]+'.zip')\n shutil.rmtree(dirname)\n \n with open(\"/home/pi/shared/log/currentstatus_rpi.log\", \"w\") as file:\n file.write(\"--READY--\")\n\ndef zip(filepath):\n with ZipFile(\"/home/pi/shared/temp.zip\", \"a\") as zip:\n zip.write(filepath, os.path.basename(filepath))\n os.remove(filepath)\n \ndef crop(filepath):\n with open(\"/home/pi/shared/log/cropx.log\", \"r\") as file:\n cropx=int(file.read())\n with open(\"/home/pi/shared/log/cropy.log\", \"r\") as file:\n cropy=int(file.read()) \n\n img = Image.open(filepath)\n width, height = img.size \n\n left = width*cropx/100\n top = height*cropy/100\n right = width*(100-cropx)/100\n bottom = height*(100-cropy)/100\n img= img.crop((left,top,right,bottom))\n img.save(filepath, quality=100)\n zoom=min(float(cropx)/50,float(cropy)/50)\n img = img.resize((int(float(600-12*cropx)/(1-zoom)), int(float(450-9*cropy)/(1-zoom))))\n img.save('./shared/ui/data/preview.jpg')\n img.close()\n\n\n\nrotorrun(-int(startangle/2))\nfor x in range (verticalpositions-1):\n vertpos = x+1\n turntablerotation()\n rotorrun(int(rotorspr*angle/360))\nturntablerotation()\nrotorrun(-int(rotorspr*angle/360)*verticalpositions+int(startangle/2))\nsaveparameters()\n\nreturn msg","outputs":1,"x":450,"y":1380,"wires":[["eedbeec5.3e917"]]},{"id":"eedbeec5.3e917","type":"link out","z":"1f55eb2e.158f95","name":"","links":["35a36b3b.902074","cbe4bd92.d30af"],"x":566,"y":1380,"wires":[]},{"id":"dca69567.c4ee58","type":"inject","z":"1f55eb2e.158f95","name":"","topic":"","payload":"Started!","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":"","x":80,"y":1300,"wires":[["7e9117fd.1be028","e9b34ac9.a3d448"]]},{"id":"6f516ad6.ca23d4","type":"ui_slider","z":"1f55eb2e.158f95","name":"Angle","label":"Angle","tooltip":"","group":"71ce9ec5.16f49","order":3,"width":3,"height":1,"passthru":true,"outs":"end","topic":"","min":"1","max":"30","step":"1","x":570,"y":1300,"wires":[["7502f2b8.de3b5c"]]},{"id":"7a1ff9d3.6655d8","type":"ui_slider","z":"1f55eb2e.158f95","name":"Photos","label":"Photos","tooltip":"","group":"71ce9ec5.16f49","order":2,"width":3,"height":1,"passthru":true,"outs":"end","topic":"","min":"1","max":"10","step":"1","x":580,"y":1340,"wires":[["9d19f8e3.251678"]]},{"id":"7502f2b8.de3b5c","type":"python3-function","z":"1f55eb2e.158f95","name":"add unit","func":"deflection=str(msg['payload'])\nwith open(\"/home/pi/shared/log/hotspot_angle.log\", \"w\") as file:\n file.write(deflection)\nmsg['payload']=deflection+'°'\nreturn msg","outputs":1,"x":720,"y":1300,"wires":[[]]},{"id":"7e9117fd.1be028","type":"file in","z":"1f55eb2e.158f95","name":"","filename":"/home/pi/shared/log/hotspot_angle.log","format":"","chunk":false,"sendError":false,"encoding":"none","x":330,"y":1300,"wires":[["6f516ad6.ca23d4"]]},{"id":"e9b34ac9.a3d448","type":"file in","z":"1f55eb2e.158f95","name":"","filename":"/home/pi/shared/log/hotspot_photos.log","format":"","chunk":false,"sendError":false,"encoding":"none","x":340,"y":1340,"wires":[["7a1ff9d3.6655d8"]]},{"id":"9d19f8e3.251678","type":"python3-function","z":"1f55eb2e.158f95","name":"add unit","func":"deflection=str(msg['payload'])\nwith open(\"/home/pi/shared/log/hotspot_photos.log\", \"w\") as file:\n file.write(deflection)\nmsg['payload']=deflection+'°'\nreturn msg","outputs":1,"x":720,"y":1340,"wires":[[]]},{"id":"5012b5d6.f9de9c","type":"inject","z":"1f55eb2e.158f95","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":120,"y":1480,"wires":[["b5073409.e58448"]]},{"id":"b5073409.e58448","type":"python3-function","z":"1f55eb2e.158f95","name":"strip string to numbers only","func":"import re\n\nwith open(\"/home/pi/shared/log/currentserverversion.log\", \"r\") as file:\n string=file.read()\nresult = re.sub('[^0-9]','', string)\n\nmsg['payload']=result\nreturn msg","outputs":1,"x":360,"y":1480,"wires":[["a0e1b68c.47aa28"]]},{"id":"a0e1b68c.47aa28","type":"debug","z":"1f55eb2e.158f95","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":610,"y":1480,"wires":[]},{"id":"cd61a719.2c6558","type":"python3-function","z":"4aee81d.130dd8","name":"check ip address","func":"import socket \n\nhost_name = socket.gethostname() \nhost_ip = socket.gethostbyname(host_name) \n\nmsg['payload']=host_ip\nmsg['payload']=host_name\nreturn msg","outputs":1,"x":390,"y":860,"wires":[["d772f1ef.2e1a7"]]},{"id":"d772f1ef.2e1a7","type":"ui_text","z":"4aee81d.130dd8","group":"191e6406.b089ec","order":3,"width":0,"height":0,"name":"","label":"Hostname:","format":"{{msg.payload}}","layout":"row-spread","x":610,"y":860,"wires":[]},{"id":"431082a5.090fac","type":"python3-function","z":"4aee81d.130dd8","name":"check ip address","func":"import socket \n\nhost_name = socket.gethostname() \nhost_ip = socket.gethostbyname(host_name) \n\nmsg['payload']=host_ip\nreturn msg","outputs":1,"x":390,"y":900,"wires":[["4b8b6792.257758"]]},{"id":"4b8b6792.257758","type":"ui_text","z":"4aee81d.130dd8","group":"191e6406.b089ec","order":4,"width":0,"height":0,"name":"","label":"Your local IP:","format":"{{msg.payload}}","layout":"row-spread","x":610,"y":900,"wires":[]},{"id":"3bc9635e.c9683c","type":"python3-function","z":"4aee81d.130dd8","name":"manual en","func":"import os.path\nimport os\n\nif msg['payload']!=True:\n return\n\nfile = '/home/pi/shared/log/manual_en_new.log'\nurl = ' https://raw.githubusercontent.com/OpenScanEu/OpenScan/master/Manual_en.log'\nos.system('wget -q -O'+file+url)\n\nwith open(\"/home/pi/shared/log/manual_en_new.log\", \"r\") as file:\n newversion=file.read()\nwith open(\"/home/pi/shared/log/manual_en.log\", \"r\") as file:\n oldversion=file.read()\n\nif oldversion==newversion:\n return\n \nfile = '/home/pi/shared/ui/data/Manual_en.pdf'\nurl = ' https://github.com/OpenScanEu/OpenScan/raw/master/Manual_en.pdf'\ntry:\n os.remove(file)\nexcept OSError:\n pass\nos.system('wget -q -O'+file+url)\nstatinfo=os.stat(file)\nif(os.path.exists(file)==False) or statinfo.st_size==0:\n return\n\n\nwith open(\"/home/pi/shared/log/manual_en.log\", \"w\") as file:\n file.write(newversion)\nmsg['payload']=\"New Manual downloaded (see Info-Tab)\"\nreturn msg\n\n\n\n","outputs":1,"x":530,"y":140,"wires":[["c180d6dd.40f2d8"]]},{"id":"c180d6dd.40f2d8","type":"ui_toast","z":"4aee81d.130dd8","position":"dialog","displayTime":"5","highlight":"","sendall":true,"outputs":1,"ok":"OK","cancel":"","topic":"","name":"","x":690,"y":140,"wires":[[]]},{"id":"49b1a90e.262018","type":"delay","z":"4aee81d.130dd8","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":180,"y":860,"wires":[["cd61a719.2c6558","431082a5.090fac"]]},{"id":"7d89da4a.3689b4","type":"python3-function","z":"4aee81d.130dd8","name":"Confirm","func":"msg['payload']=\"Install new Version?\"\nreturn msg\n","outputs":1,"x":620,"y":480,"wires":[["9f31e928.e6aa48"]]},{"id":"9f31e928.e6aa48","type":"ui_toast","z":"4aee81d.130dd8","position":"dialog","displayTime":"5","highlight":"","sendall":true,"outputs":1,"ok":"No","cancel":"Yes","topic":"","name":"","x":630,"y":540,"wires":[["c8844641.814568"]]},{"id":"4c388fc5.ca13e","type":"python3-function","z":"1f55eb2e.158f95","name":"diskspace","func":"import os\nimport subprocess\n\nos.system(\"df| awk -F '%' 'NR==2{print $1}'>tmp\")\npercentage=open('tmp', 'r').read()[-4:-1]\nos.remove('tmp')\n\nmsg['payload']=\"Delete all images (\"+percentage+\"% used)\"\n\n\n\nreturn msg\n","outputs":1,"x":260,"y":800,"wires":[["fce5ff1c.67c6c"]]},{"id":"c9bd7a3.7723a88","type":"python3-function","z":"9a152ded.cdff9","name":"download files","func":"import os.path\nimport os\nfrom time import sleep\n# Download background\n\nsleep(1)\n\nflag=False\n\ndef download(file,url):\n if(os.path.exists(file)==False or os.stat(file)==0):\n try:\n os.system('wget -O'+file+' '+url)\n flag=True\n except:\n pass\n return\n statinfo=os.stat(file)\n if(statinfo.st_size==0):\n try:\n os.system('wget -O'+file+' '+url)\n flag=True\n except:\n pass \n return\n\n\n\nfile = '/home/pi/shared/ui/data/bmc-new-btn-logo.svg'\nurl = 'https://cdn.buymeacoffee.com/buttons/bmc-new-btn-logo.svg'\ndownload(file,url)\n\nfile = '/home/pi/.node-red/settings_openscan_mini.js'\nurl = 'https://raw.githubusercontent.com/OpenScanEu/OpenScan/master/settings_mini.js'\ndownload(file,url)\n\nfile = '/home/pi/.node-red/settings_openscan.js'\nurl = 'https://raw.githubusercontent.com/OpenScanEu/OpenScan/master/settings.js'\ndownload(file,url)\n\nfile = '/home/pi/shared/ui/data/logosmall.jpg'\nurl = 'https://raw.githubusercontent.com/OpenScanEu/OpenScan/master/temp/Logosmall.jpg'\ndownload(file,url)\n\nfile = '/home/pi/shared/ui/data/Manual_en.pdf'\nurl = ' https://github.com/OpenScanEu/OpenScan/raw/master/Manual_en.pdf'\ndownload(file,url)\n\nif flag==True:\n os.system(\"sudo systemctl restart nodered\")\n\nreturn msg","outputs":1,"x":720,"y":540,"wires":[[]]},{"id":"aadcd2c5.04031","type":"ui_toast","z":"1f55eb2e.158f95","position":"dialog","displayTime":"5","highlight":"","sendall":true,"outputs":1,"ok":"No","cancel":"Yes","topic":"","name":"","x":610,"y":800,"wires":[["81ad690b.b58088"]]},{"id":"1ba25587.a47c9a","type":"link out","z":"8f3594bc.ecc048","name":"","links":["673d8724.9543c8"],"x":355,"y":120,"wires":[]},{"id":"673d8724.9543c8","type":"link in","z":"1f55eb2e.158f95","name":"ringlight","links":["1ba25587.a47c9a","e24779c5.096f48"],"x":95,"y":320,"wires":[["43980ca9.f0d904","202bec1a.a3c274"]]},{"id":"d140939e.8f689","type":"python3-function","z":"9a152ded.cdff9","name":"create new files + content","func":"import os.path\nfrom time import sleep\n\nflag=False\n\ndef new_file(filepath,content):\n if os.path.isfile(filepath):\n if os.stat(filepath).st_size==0:\n with open(filepath, \"w\") as file:\n file.write(content)\n flag=True\n else:\n pass\n else:\n with open(filepath, \"w\") as file:\n file.write(content)\n flag=True\n\nnew_file('/home/pi/shared/log/autoupdatestate.log',\"true\")\nnew_file('/home/pi/shared/log/camera.log',\"External Camera\")\nnew_file('/home/pi/shared/log/camera_resolution_x.log',\"3280\")\nnew_file('/home/pi/shared/log/camera_resolution_y.log',\"2464\")\nnew_file('/home/pi/shared/log/camerabrightness.log',\"50\")\nnew_file('/home/pi/shared/log/cameracontrast.log',\"0\")\nnew_file('/home/pi/shared/log/cropx.log',\"0\")\nnew_file('/home/pi/shared/log/cropx_gp.log',\"0\")\nnew_file('/home/pi/shared/log/cropy.log',\"0\")\nnew_file('/home/pi/shared/log/cropy_gp.log',\"0\")\nnew_file('/home/pi/shared/log/currentserverversion.log',\"1;\")\nnew_file('/home/pi/shared/log/currentstatus_ext.log',\"--READY--\")\nnew_file('/home/pi/shared/log/currentstatus_gp.log',\"no camera found\")\nnew_file('/home/pi/shared/log/currentstatus_rpi.log',\"--READY--\")\nnew_file('/home/pi/shared/log/currentversion.log',\"1\")\nnew_file('/home/pi/shared/log/experimentalmode.log',\"false\")\nnew_file('/home/pi/shared/log/fotosperrotation.log',\"1\")\nnew_file('/home/pi/shared/log/hotspot_angle.log',\"5\")\nnew_file('/home/pi/shared/log/hotspot_photos.log',\"5\")\nnew_file('/home/pi/shared/log/loadsettings.log',\"1;\")\nnew_file('/home/pi/shared/log/loadsettings_save.log',\"1;\")\nnew_file('/home/pi/shared/log/picamera_activation.log',\"true\")\nnew_file('/home/pi/shared/log/pin_externalcam.log',\"10\")\nnew_file('/home/pi/shared/log/pin_ringlight1.log',\"17\")\nnew_file('/home/pi/shared/log/pin_ringlight2.log',\"27\")\nnew_file('/home/pi/shared/log/pin_rotor_dir.log',\"5\")\nnew_file('/home/pi/shared/log/pin_rotor_step.log',\"6\")\nnew_file('/home/pi/shared/log/pin_turntable_dir.log',\"9\")\nnew_file('/home/pi/shared/log/pin_turntable_step.log',\"11\")\nnew_file('/home/pi/shared/log/projectname.log',\"default\")\nnew_file('/home/pi/shared/log/ringlightstatus1.log',\"10\")\nnew_file('/home/pi/shared/log/ringlightstatus2.log',\"10\")\nnew_file('/home/pi/shared/log/releasetime_ext.log',\"10\")\nnew_file('/home/pi/shared/log/rotor_acc.log',\"1\")\nnew_file('/home/pi/shared/log/rotor_accramp.log',\"200\")\nnew_file('/home/pi/shared/log/rotor_angle.log',\"5\")\nnew_file('/home/pi/shared/log/rotor_delay.log',\"0.0005\")\nnew_file('/home/pi/shared/log/rotor_stepsperrotation.log',\"17067\")\nnew_file('/home/pi/shared/log/samba.log',\"true\")\nnew_file('/home/pi/shared/log/shutterspeed.log',\"300\")\nnew_file('/home/pi/shared/log/ssh.log',\"true\")\nnew_file('/home/pi/shared/log/startdeflection.log',\"0\")\nnew_file('/home/pi/shared/log/stopstate.log',\"run\")\nnew_file('/home/pi/shared/log/stopstate_ext.log',\"run\")\nnew_file('/home/pi/shared/log/stopstate_gp.log',\"run\")\nnew_file('/home/pi/shared/log/timeperfoto_ext.log',\"0.5\")\nnew_file('/home/pi/shared/log/turntable_acc.log',\"1\")\nnew_file('/home/pi/shared/log/turntable_accramp.log',\"200\")\nnew_file('/home/pi/shared/log/turntable_angle.log',\"10\")\nnew_file('/home/pi/shared/log/turntable_delay.log',\"0.0005\")\nnew_file('/home/pi/shared/log/turntable_stepsperrotation.log',\"3200\")\nnew_file('/home/pi/shared/log/updatepreview.log',\"start\")\nnew_file('/home/pi/shared/log/updatepreview_gp.log',\"1\")\nnew_file('/home/pi/shared/log/verticalpositions.log',\"1\")\nnew_file('/home/pi/shared/log/zoom.log',\"1\")\nnew_file('/home/pi/shared/ui/data/update.log',\"1\")\nnew_file('/home/pi/shared/log/manual_en.log',\"1\")\nnew_file('/home/pi/shared/log/manual_en_new.log',\"1\")\nnew_file('/home/pi/shared/log/email.log',\"\")\nnew_file('/home/pi/shared/log/feedback_status.log',\"\")\nnew_file('/home/pi/shared/log/feedback_terms.log',\"False\")\nnew_file(\"/home/pi/shared/log/openscan_model.log\",\"none\")\nnew_file(\"/home/pi/shared/log/awb_red.log\",\"1.7\")\nnew_file(\"/home/pi/shared/log/awb_blue.log\",\"1.7\")\nnew_file(\"/home/pi/shared/log/angle_min.log\",\"-20\")\nnew_file(\"/home/pi/shared/log/angle_max.log\",\"90\")\nnew_file(\"/home/pi/shared/log/preview.log\",\"True\")\nnew_file(\"/home/pi/shared/log/startangle.log\",\"0\")\nnew_file(\"/home/pi/shared/log/delay_ext.log\",\"1200\")\nnew_file(\"/home/pi/shared/log/camera_type.log\",\"v2\")\n\n\nif flag==True:\n os.system(\"sudo systemctl restart nodered\")\n\nreturn msg","outputs":1,"x":510,"y":540,"wires":[["349202ab.786d7e","c9bd7a3.7723a88"]]},{"id":"72eedb6b.329454","type":"python3-function","z":"9a152ded.cdff9","name":"create path","func":"import os.path\n\nmsg['flag']=False\n\ndef new_path(path):\n if(os.path.exists(path)==False):\n os.mkdir(path)\n msg['flag']=True\n else:\n pass\n\nnew_path(\"/home/pi/shared/\")\nnew_path(\"/home/pi/shared/ui\")\nnew_path(\"/home/pi/shared/ui/data/\")\nnew_path(\"/home/pi/shared/ui/data/old_flows\")\nnew_path(\"/home/pi/shared/ui/data/zip\")\nnew_path(\"/home/pi/shared/log\")\nreturn msg","outputs":1,"x":310,"y":540,"wires":[["d140939e.8f689"]]},{"id":"4fe772d.3bfca8c","type":"ui_template","z":"83cc546d.8e6a58","group":"9cc33f2c.6a6cd","name":"File List + Install Version","order":4,"width":8,"height":6,"format":"\n\n\n\n
\n \n Upload Files&Get Feedback*\n
\n \n
\n\n\n\n
\n","storeOutMessages":false,"fwdInMessages":false,"templateScope":"local","x":350,"y":240,"wires":[["c6539c45.73af7","35713797.ed2f88"]]},{"id":"c6539c45.73af7","type":"fs-ops-dir","z":"83cc546d.8e6a58","name":"/media/pi/","path":"path","pathType":"msg","filter":"*","filterType":"str","dir":"files","dirType":"msg","x":360,"y":200,"wires":[["4fe772d.3bfca8c"]]},{"id":"cbfb4612.e19ce8","type":"function","z":"83cc546d.8e6a58","name":"","func":"msg.path = \"shared/ui/data/zip\"\n\nreturn msg;","outputs":1,"noerr":0,"x":210,"y":200,"wires":[["c6539c45.73af7"]]},{"id":"debbd5a6.475648","type":"inject","z":"83cc546d.8e6a58","name":"5s","topic":"Repeater","payload":"0.1","payloadType":"str","repeat":"5","crontab":"","once":true,"onceDelay":"0.1","x":90,"y":200,"wires":[["cbfb4612.e19ce8"]]},{"id":"36782e47.3af692","type":"inject","z":"83cc546d.8e6a58","name":"0.5s","topic":"Repeater","payload":"0.1","payloadType":"str","repeat":"0.5","crontab":"","once":true,"onceDelay":"0.2","x":90,"y":140,"wires":[["72691735.e2c858"]]},{"id":"72691735.e2c858","type":"python3-function","z":"83cc546d.8e6a58","name":"msg","func":"\nwith open(\"/home/pi/shared/log/feedback_status.log\", \"r\") as file:\n test=file.read()\nmsg['payload']=test\nreturn msg","outputs":1,"x":210,"y":140,"wires":[["8c890f91.a3a0d"]]},{"id":"8c890f91.a3a0d","type":"ui_text","z":"83cc546d.8e6a58","group":"9cc33f2c.6a6cd","order":2,"width":8,"height":1,"name":"","label":"Status:","format":"{{msg.payload}}","layout":"row-spread","x":360,"y":140,"wires":[]},{"id":"35713797.ed2f88","type":"python3-function","z":"83cc546d.8e6a58","name":"routine","func":"import os\nimport re \nimport zipfile\nimport os\nfrom PIL import Image\nimport uuid\nfrom zipfile import ZipFile\nfrom time import sleep\n\npath_status=\"/home/pi/shared/log/feedback_status.log\"\nkey=uuid.uuid4().hex[:30].replace('0','X').replace('O','Y')\nfolder=\"/home/pi/shared/ui/data/zip/\"\nfile=msg['file']\nfilepath=folder+file\npath_temp=\"/home/pi/shared/temp/\"\nregex = '^\\w+([\\.-]?\\w+)*@\\w+([\\.-]?\\w+)*(\\.\\w{2,3})+$'\ntry:\n with open(\"/home/pi/shared/log/email.log\", \"r\") as file:\n email=file.read()\nexcept:\n email=\"no email address\"\n \nwith open(\"/home/pi/shared/log/feedback_terms.log\", \"r\") as file:\n terms=file.read()\npw=\"MKN3iOE4u9qICzHzBmjwuWNt8UD62aP8uPxcOqsrwramqrMcoPJd7dJLz44B4VGRUOKk9W5C4viKrrINagKxvmrLDajrgg8Wkh4I\"\nuser=\"upload\"\nserver=\"openscanfeedback.dnsuser.de:1312\"\npw_down=\"nnEDBxDrDPFPWKZIylxbL21U9QhUrnBWIqsnYUgmLPsCd1ZiJtClrS2bxc8wJq7DSIZNOoiWnMNrLnuJadNagCKhsDCyCVRiUBpf\"\nuser_down=\"download\"\ntarget=\"/home/pi/shared/log/temp\"\n\ndef check_terms():\n if terms==\"False\":\n status(\"please agree to the terms of use\")\n end()\n\ndef status(text):\n with open(path_status, \"w+\") as file:\n file.write(text)\n\ndef check(email): \n if(re.search(regex,email)): \n return\n else: \n status(\"invalid email address\")\n end()\ndef onlinetest():\n if os.system(\"nc -w 1 openscanfeedback.dnsuser.de 1312\")==0:\n status(\"server is online\")\n else:\n status(\"server not reachable\")\n end()\n\ndef createzip():\n zip = zipfile.ZipFile(filepath)\n list=zip.namelist()\n \n if(os.path.exists(path_temp)==True):\n os.system(\"sudo rm -r \"+path_temp)\n os.mkdir(path_temp)\n \n middle=int(len(list)/2)-1\n \n for x in range (3):\n f=zip.open(list[x])\n content = f.read()\n path=path_temp+str(x+1)+\".jpg\"\n f = open(path, 'wb')\n f.write(content)\n f.close()\n \n img = Image.open(path)\n img.save(path, quality=92)\n img.close()\n \n try:\n f=zip.open(\"parameters.txt\")\n content=f.read()\n f.close()\n except:\n content=\"no parameters\"\n \n zip.close()\n \n f = open(path_temp+\"parameter\", 'wb')\n f.write(content)\n f.close()\n \n f = open(path_temp+\"key\", 'wb')\n f.write(key)\n f.close()\n \n f = open(path_temp+\"email\", 'wb')\n f.write(email)\n f.close()\n \n files=[\"1.jpg\",\"2.jpg\",\"3.jpg\",\"parameter\",\"email\",\"key\"]\n \n for file in files:\n addzip(path_temp+file)\n os.system(\"sudo rm -r \"+path_temp)\n\ndef addzip(filepath):\n with ZipFile(\"/home/pi/shared/\"+key+\".zip\", \"a\") as zip:\n zip.write(filepath, os.path.basename(filepath))\n os.remove(filepath) \n\ndef upload():\n command=\"curl -k --user \"+user+\":\"+pw+\" sftp://\"+server+\"/\"+user+\"/ -T \"+filepath\n os.system(command)\n os.remove(filepath)\n\ndef confirmation():\n \n with open(target, \"w\") as file:\n file.write(\"upload failed\")\n try:\n os.system(\"curl -k --user \"+user_down+\":\"+pw_down+\" sftp://\"+server+\"/\"+user_down+\"/\"+key+\" -o \"+target)\n with open(target, \"r\") as file:\n test=file.read()\n os.remove(target)\n return test\n except:\n test=\"upload failed\"\n return test\n\n\ncheck_terms()\ncheck(email)\nstatus(\"checking connection\")\ntry:\n onlinetest()\nexcept:\n status(\"connection failed\")\n return msg\nstatus(\"compressing file\")\ntry:\n createzip()\nexcept:\n status(\"file error\")\n return msg\nfilepath=\"/home/pi/shared/\"+key+\".zip\"\nstatus(\"uploading file\")\ntry:\n upload()\nexcept:\n status(\"upload failed\")\n return msg\nsleep(4)\nstatus(\"waiting for confirmation\")\nsleep(3)\nstatus(confirmation())\nmsg['payload']=key\n\nreturn msg","outputs":1,"x":550,"y":240,"wires":[[]]},{"id":"1f893b4d.c33635","type":"python3-function","z":"83cc546d.8e6a58","name":"status","func":"path_status=\"/home/pi/shared/log/feedback_status.log\"\n\n\ndef status(text):\n with open(path_status, \"w+\") as file:\n file.write(text)\nstatus(\"please, select a file\")","outputs":1,"x":250,"y":80,"wires":[[]]},{"id":"a615591a.346c18","type":"inject","z":"83cc546d.8e6a58","name":"start","topic":"Repeater","payload":"0.1","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":"0.2","x":90,"y":80,"wires":[["1f893b4d.c33635","1c857ba7.03d3b4"]]},{"id":"a423a63b.db0d68","type":"ui_text_input","z":"83cc546d.8e6a58","name":"","label":"Your Email","tooltip":"","group":"9cc33f2c.6a6cd","order":3,"width":8,"height":1,"passthru":false,"mode":"text","delay":"0","topic":"","x":250,"y":300,"wires":[["6bb696d3.951ae8"]]},{"id":"6bb696d3.951ae8","type":"python3-function","z":"83cc546d.8e6a58","name":"status","func":"import re \n \nregex = '^\\w+([\\.-]?\\w+)*@\\w+([\\.-]?\\w+)*(\\.\\w{2,3})+$'\nemail=msg['payload']\n \nwith open(\"/home/pi/shared/log/email.log\", \"w\") as file:\n file.write(email)\n\nreturn msg","outputs":1,"x":390,"y":300,"wires":[["1c857ba7.03d3b4"]]},{"id":"1c857ba7.03d3b4","type":"python3-function","z":"83cc546d.8e6a58","name":"status","func":"from time import sleep\nsleep(0.5)\nwith open(\"/home/pi/shared/log/email.log\", \"r\") as file:\n msg['payload']=file.read()\nreturn msg","outputs":1,"x":110,"y":300,"wires":[["a423a63b.db0d68"]]},{"id":"eb154738.620e58","type":"ui_template","z":"83cc546d.8e6a58","group":"9cc33f2c.6a6cd","name":"Get Feedback","order":1,"width":8,"height":5,"format":" \n
\n Get Feedback\n
\n Here, you can select and upload parts of your projects to my server and get feedback on the image quality. Three images and the routine parameters will be transfered via SFTP. I will manually review those images for their quality and send you a detailed report to the given email address :)\n\n\n","storeOutMessages":true,"fwdInMessages":false,"templateScope":"local","x":240,"y":20,"wires":[[]]},{"id":"5fdc9e5.d51f46","type":"ui_template","z":"83cc546d.8e6a58","group":"9cc33f2c.6a6cd","name":"Further thoughts","order":5,"width":8,"height":5,"format":" \n
\n Further thoughts:\n
\n This is the first step of adding some cloud-capabilities to the OpenScan Project :) I am already experimenting with cloud-processing solutions that might simplify the overall scanning process drastically in the future.\n\n\n","storeOutMessages":true,"fwdInMessages":false,"templateScope":"local","x":260,"y":360,"wires":[[]]},{"id":"7e951847.2eb768","type":"python3-function","z":"2fb4a0.ab59cb6","name":"Preview for features","func":"import time\nimport picamera\nfrom time import sleep\nimport subprocess\nfrom PIL import Image\n\nwith open(\"/home/pi/shared/log/feedback_terms.log\", \"r\") as file:\n terms=file.read()\nif terms==\"False\":\n msg['payload']=\"Please read and agree to the Terms of Use (See Settings Menu) before you can use this function\"\n return None,msg\n\nwith open(\"/home/pi/shared/log/currentstatus_rpi.log\", \"r\") as file:\n state=file.read()\n if state[:3]==\"Pos\":\n return\n\nwith open(\"/home/pi/shared/log/currentstatus_rpi.log\", \"w\") as file:\n file.write(\"initalizing\")\n\nwith open(\"/home/pi/shared/log/camera.log\", \"r\") as file:\n if file.read()!=\"RPi Camera\":\n return\n\nif subprocess.check_output([\"vcgencmd\",\"get_camera\"])[-2:-1]==\"0\":\n with open(\"/home/pi/shared/log/currentstatus_rpi.log\", \"w\") as file:\n file.write(\"no camera found\")\n return\n\nwith open(\"/home/pi/shared/log/shutterspeed.log\", \"r\") as file:\n shutterspeed=int(file.read())*100\nwith open(\"/home/pi/shared/log/camera_resolution_x.log\", \"r\") as file:\n resx=int(file.read())\nwith open(\"/home/pi/shared/log/camera_resolution_y.log\", \"r\") as file:\n resy=int(file.read())\nwith open(\"/home/pi/shared/log/currentstatus_rpi.log\", \"r\") as file:\n currentstatus=file.read()\n\ndef crop(filepath):\n with open(\"/home/pi/shared/log/cropx.log\", \"r\") as file:\n cropx=int(file.read())\n with open(\"/home/pi/shared/log/cropy.log\", \"r\") as file:\n cropy=int(file.read()) \n img = Image.open(filepath)\n width, height = img.size \n\n left = width*cropx/100\n top = height*cropy/100\n right = width*(100-cropx)/100\n bottom = height*(100-cropy)/100\n img= img.crop((left,top,right,bottom))\n img.save(filepath)\n zoom=min(float(cropx)/50,float(cropy)/50)\n #img = img.resize((int(float(600-12*cropx)/(1-zoom)), int(float(450-9*cropy)/(1-zoom))))\n img = img.resize((int(float(1800-36*cropx)/(1-zoom)), int(float(1350-27*cropy)/(1-zoom))))\n img.save('./shared/ui/data/preview.jpg')\n img.close()\n\nsleep(0.2)\n\nwith picamera.PiCamera() as camera:\n with open(\"/home/pi/shared/log/cameracontrast.log\", \"r\") as file:\n cameracontrast=int(file.read())\n with open(\"/home/pi/shared/log/camerabrightness.log\", \"r\") as file:\n camerabrightness=int(file.read())\n camera.iso = 100\n camera.brightness = camerabrightness\n camera.contrast = cameracontrast\n camera.resolution=(resx, resy)\n camera.exposure_compensation = 0 \n sleep(0.4)\n camera.awb_mode = 'auto'\n camera.exposure_mode = 'off'\n camera.shutter_speed = shutterspeed\n camera.capture(\"./shared/ui/data/preview.jpg\",quality=90)\n crop(\"./shared/ui/data/preview.jpg\")\nreturn msg","outputs":2,"x":720,"y":740,"wires":[["20169233.d7cbbe","a95de614.115ff8"],["8d1935d6.62ce88"]]},{"id":"47f867fe.5cc098","type":"ui_button","z":"2fb4a0.ab59cb6","name":"","group":"b0cc7e63.5b5b3","order":3,"width":5,"height":1,"passthru":false,"label":"Get Features","tooltip":"Calculate Features on the current preview image","color":"","bgcolor":"","icon":"","payload":"autoupdate","payloadType":"global","topic":"","x":90,"y":760,"wires":[["15a78612.54d26a"]]},{"id":"20169233.d7cbbe","type":"python3-function","z":"2fb4a0.ab59cb6","name":"features","func":"import os\nimport os\nfrom PIL import Image\nimport uuid\n\nfrom time import sleep\nrepeats=4\ndelay=3\n\nfilepath=\"/home/pi/shared/ui/data/preview.jpg\"\n\nwith open(\"/home/pi/shared/log/feedback_terms.log\", \"r\") as file:\n terms=file.read()\n\nkey=uuid.uuid4().hex[:30].replace('0','X').replace('O','Y')\n\n\npw=\"MKN3iOE4u9qICzHzBmjwuWNt8UD62aP8uPxcOqsrwramqrMcoPJd7dJLz44B4VGRUOKk9W5C4viKrrINagKxvmrLDajrgg8Wkh4I\"\nuser=\"feature\"\n#server=\"openscanfeedback.dnsuser.de:1312\"\nserver=\"openscanfeedback.dnsuser.de\"\nport=str(1312)\npw_down=\"nnEDBxDrDPFPWKZIylxbL21U9QhUrnBWIqsnYUgmLPsCd1ZiJtClrS2bxc8wJq7DSIZNOoiWnMNrLnuJadNagCKhsDCyCVRiUBpf\"\nuser_down=\"download\"\ntarget=\"/home/pi/shared/log/\"+key+\".jpg\"\n\nos.system(\"sudo cp \"+filepath+\" \"+target)\n\ndef check_terms():\n #if terms==\"False\":\n # status(\"please agree to the terms of use\")\n # end()\n pass\n\ndef status(text):\n with open(\"/home/pi/shared/log/currentstatus_rpi.log\", \"w\") as file:\n file.write(text)\n msg['payload']=text\n pass\n\ndef onlinetest():\n if os.system(\"nc -w 1 \"+server+\" \"+port)==0:\n status(\"server is online\")\n \n else:\n status(\"server not reachable\")\n end()\n pass\n\ndef upload():\n command=\"curl -k --user \"+user+\":\"+pw+\" sftp://\"+server+\":\"+port+\"/\"+user+\"/ -T \"+target\n if os.system(command)!=0:\n status(\"upload failed\")\n end()\n\n\ndef download():\n command=\"curl -k --user \"+user_down+\":\"+pw_down+\" sftp://\"+server+\":\"+port+\"/\"+user_down+\"/\"+key+\".jpg -o \"+filepath\n test=os.system(command)\n return test\n\ncheck_terms()\nstatus(\"checking connection\")\ntry:\n onlinetest()\nexcept:\n status(\"connection failed\")\n return msg\n\nstatus(\"uploading file\")\ntry:\n upload()\nexcept:\n status(\"upload failed\")\n return msg\nsleep(delay/2)\nstatus(\"waiting for file\")\nsleep(delay/2)\n\nfor x in range (repeats):\n if download()!=0:\n status(\"try: (\"+str(x+1)+\")\")\n sleep(delay/2)\n else:\n os.system(\"sudo rm \"+target)\n status(\"--READY--\")\n return msg\n\nstatus(\"--READY--\")\nreturn msg","outputs":1,"x":920,"y":740,"wires":[["a95de614.115ff8"]]},{"id":"8d1935d6.62ce88","type":"ui_toast","z":"2fb4a0.ab59cb6","position":"dialog","displayTime":"3","highlight":"","sendall":true,"outputs":1,"ok":"OK","cancel":"","topic":"","name":"","x":930,"y":780,"wires":[[]]},{"id":"66c6a1c0.72658","type":"ui_button","z":"adecba7c.a89278","name":"","group":"71843631.f4d5f8","order":5,"width":6,"height":1,"passthru":false,"label":"Get Features","tooltip":"Calculate Features on the current preview image","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":410,"y":520,"wires":[["6ac1b433.96b5fc"]]},{"id":"8ccfea60.25a098","type":"python3-function","z":"adecba7c.a89278","name":"features","func":"import os\nimport os\nfrom PIL import Image\nimport uuid\n\nfrom time import sleep\nrepeats=4\ndelay=3\n\nfilepath=\"/home/pi/shared/ui/data/preview2.jpg\"\n\nwith open(\"/home/pi/shared/log/feedback_terms.log\", \"r\") as file:\n terms=file.read()\n\nkey=uuid.uuid4().hex[:30].replace('0','X').replace('O','Y')\n\n\npw=\"MKN3iOE4u9qICzHzBmjwuWNt8UD62aP8uPxcOqsrwramqrMcoPJd7dJLz44B4VGRUOKk9W5C4viKrrINagKxvmrLDajrgg8Wkh4I\"\nuser=\"feature\"\n#server=\"openscanfeedback.dnsuser.de:1312\"\nserver=\"openscanfeedback.dnsuser.de\"\nport=str(1312)\npw_down=\"nnEDBxDrDPFPWKZIylxbL21U9QhUrnBWIqsnYUgmLPsCd1ZiJtClrS2bxc8wJq7DSIZNOoiWnMNrLnuJadNagCKhsDCyCVRiUBpf\"\nuser_down=\"download\"\ntarget=\"/home/pi/shared/log/\"+key+\".jpg\"\n\nos.system(\"sudo cp \"+filepath+\" \"+target)\n\ndef check_terms():\n #if terms==\"False\":\n # status(\"please agree to the terms of use\")\n # end()\n pass\n\ndef status(text):\n with open(\"/home/pi/shared/log/currentstatus_gp.log\", \"w\") as file:\n file.write(text)\n msg['payload']=text\n pass\n\ndef onlinetest():\n if os.system(\"nc -w 1 \"+server+\" \"+port)==0:\n status(\"server is online\")\n \n else:\n status(\"server not reachable\")\n end()\n pass\n\ndef upload():\n command=\"curl -k --user \"+user+\":\"+pw+\" sftp://\"+server+\":\"+port+\"/\"+user+\"/ -T \"+target\n if os.system(command)!=0:\n status(\"upload failed\")\n end()\n\n\ndef download():\n command=\"curl -k --user \"+user_down+\":\"+pw_down+\" sftp://\"+server+\":\"+port+\"/\"+user_down+\"/\"+key+\".jpg -o \"+filepath\n test=os.system(command)\n return test\n\ncheck_terms()\nstatus(\"checking connection\")\ntry:\n onlinetest()\nexcept:\n status(\"connection failed\")\n return msg\n\nstatus(\"uploading file\")\ntry:\n upload()\nexcept:\n status(\"upload failed\")\n return msg\nsleep(delay/2)\nstatus(\"waiting for file\")\nsleep(delay/2)\n\nfor x in range (repeats):\n if download()!=0:\n status(\"try: (\"+str(x+1)+\")\")\n sleep(delay/2)\n else:\n os.system(\"sudo rm \"+target)\n status(\"--READY--\")\n return msg\n\nstatus(\"--READY--\")\nreturn msg","outputs":1,"x":840,"y":520,"wires":[["49d32163.4df36"]]},{"id":"ff8edc2b.1036f","type":"ui_toast","z":"adecba7c.a89278","position":"dialog","displayTime":"3","highlight":"","sendall":true,"outputs":1,"ok":"OK","cancel":"","topic":"","name":"","x":850,"y":560,"wires":[[]]},{"id":"6ac1b433.96b5fc","type":"python3-function","z":"adecba7c.a89278","name":"Take Preview Shot","func":"import io\nimport logging\nimport os\nimport subprocess\nimport sys\nimport random\n\nfrom PIL import Image\n\nimport gphoto2 as gp\n\nwith open(\"/home/pi/shared/log/feedback_terms.log\", \"r\") as file:\n terms=file.read()\nif terms==\"False\":\n msg['payload']=\"Please read and agree to the Terms of Use (See Settings Menu) before you can use this function\"\n return None,msg\n\nwith open(\"/home/pi/shared/log/camera.log\", \"r\") as file:\n if file.read()!=\"GPhoto2\":\n return\n\nwith open(\"/home/pi/shared/log/currentstatus_gp.log\", \"r\") as file:\n val= file.read()\n if val==\"creating zip file\" or val[:3]==\"Pos\":\n return\n\ncamera = gp.check_result(gp.gp_camera_new())\ntry:\n gp.check_result(gp.gp_camera_init(camera))\nexcept:\n with open(\"/home/pi/shared/log/currentstatus_gp.log\", \"w\") as file:\n file.write(\"no camera found\")\n return\nwith open(\"/home/pi/shared/log/currentstatus_gp.log\", \"w\") as file:\n file.write(\"initializing\")\n\ndef crop(filepath):\n with open(\"/home/pi/shared/log/cropx_gp.log\", \"r\") as file:\n cropx=int(file.read())\n with open(\"/home/pi/shared/log/cropy_gp.log\", \"r\") as file:\n cropy=int(file.read()) \n img = Image.open(filepath)\n width, height = img.size \n\n left = width*cropx/100\n top = height*cropy/100\n right = width*(100-cropx)/100\n bottom = height*(100-cropy)/100\n img= img.crop((left,top,right,bottom))\n img.save(filepath)\n zoom=min(float(cropx)/50,float(cropy)/50)\n img = img.resize((int(float(600-12*cropx)/(1-zoom)), int(float(450-9*cropy)/(1-zoom))))\n img.save('./shared/ui/data/preview.jpg')\n img.close()\n\nconfig = gp.check_result(gp.gp_camera_get_config(camera))\nOK, image_format = gp.gp_widget_get_child_by_name(config, 'imageformat')\nif OK >= gp.GP_OK:\n value = gp.check_result(gp.gp_widget_get_value(image_format))\n if 'raw' in value.lower():\n return \nOK, capture_size_class = gp.gp_widget_get_child_by_name(\n config, 'capturesizeclass')\nif OK >= gp.GP_OK:\n value = gp.check_result(gp.gp_widget_get_choice(capture_size_class, 2))\n gp.check_result(gp.gp_widget_set_value(capture_size_class, value))\n gp.check_result(gp.gp_camera_set_config(camera, config))\ncamera_file = gp.check_result(gp.gp_camera_capture_preview(camera))\nfile_data = gp.check_result(gp.gp_file_get_data_and_size(camera_file))\ndata = memoryview(file_data)\n\ntarget = '/home/pi/shared/ui/data/preview2.jpg'\ncamera_file.save(target)\ncrop(\"./shared/ui/data/preview2.jpg\")\n\ngp.check_result(gp.gp_camera_exit(camera))\n\nreturn msg","outputs":2,"x":610,"y":520,"wires":[["8ccfea60.25a098","49d32163.4df36"],["ff8edc2b.1036f"]]},{"id":"47d81eee.aa6c9","type":"python3-function","z":"8f3594bc.ecc048","name":"","func":"msg['payload']=\"This is a free piece of software and it is provided 'as is', without any warranty. There might be functions that need a connection to the internet: By pressing 'GET FEATURES' you agree that the shown preview image will be transfered, stored and processed via SFTP. By pressing 'UPLOAD FILES&GET FEEDBACK' you agree, that the following data will be transmitted, stored and processed via SFTP to my (Thomas Megel, OpenScan, Halle, Germany) server: three compressed images of the chosen photo-set, routine parameters, email address, IP address. I will use those information to create a detailed feedback on the image quality/scan settings and send a response to the given email address. The email address and IP will be deleted after 7 days. The images and routine parameters might be used for further experiments (e.g. machine learning to automate the process). If you have any questions you can contact me at info@openscan.eu. The connection used, is a direct, encrypted line between your device and my server - no AWS, no Google analytics, no Facebook whatsoever ... THE SOFTWARE IS PROVIDED 'AS IS' WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE\"\nreturn msg","outputs":1,"x":390,"y":2540,"wires":[["25350216.1ce10e"]]},{"id":"25350216.1ce10e","type":"ui_toast","z":"8f3594bc.ecc048","position":"dialog","displayTime":"3","highlight":"","sendall":true,"outputs":1,"ok":"OK","cancel":"","topic":"","name":"","x":530,"y":2540,"wires":[[]]},{"id":"c6fb8548.665608","type":"ui_button","z":"8f3594bc.ecc048","name":"","group":"ddd1a14a.d7351","order":8,"width":6,"height":1,"passthru":false,"label":"Terms of Use","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":130,"y":2540,"wires":[["47d81eee.aa6c9"]]},{"id":"676a0709.e278f8","type":"ui_switch","z":"8f3594bc.ecc048","name":"","label":"Read&Agree:","tooltip":"","group":"ddd1a14a.d7351","order":9,"width":6,"height":1,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":600,"y":2500,"wires":[["fca4a6.0acebb58"]]},{"id":"35136f29.d068","type":"inject","z":"8f3594bc.ecc048","name":"start","topic":"Repeater","payload":"false","payloadType":"bool","repeat":"","crontab":"","once":true,"onceDelay":"0.2","x":110,"y":2500,"wires":[["bf8fc315.00951"]]},{"id":"fca4a6.0acebb58","type":"python3-function","z":"8f3594bc.ecc048","name":"Terms of Use","func":"with open(\"/home/pi/shared/log/feedback_terms.log\", \"w+\") as file:\n file.write(str(msg['payload']))\n\nreturn msg","outputs":1,"x":870,"y":2500,"wires":[[]]},{"id":"bf8fc315.00951","type":"python3-function","z":"8f3594bc.ecc048","name":"Terms of Use","func":"with open(\"/home/pi/shared/log/feedback_terms.log\", \"r\") as file:\n terms=file.read()\n if terms==\"True\":\n msg['payload']=True\n else:\n msg['payload']=False\nreturn msg","outputs":1,"x":350,"y":2500,"wires":[["676a0709.e278f8"]]},{"id":"15a78612.54d26a","type":"python3-function","z":"2fb4a0.ab59cb6","name":"Auto Update off","func":"msg2={\"payload\":\"disabled auto-update preview for the feature calculation\"}\n\nif msg['payload']==\"on\":\n msg['payload']=\"off\"\n return None,msg,msg2\n\nreturn msg","outputs":3,"x":260,"y":760,"wires":[["7e951847.2eb768"],["b843fb6.f818708","fa8c625c.095dd"],["9605e9b6.f62f98"]]},{"id":"b843fb6.f818708","type":"change","z":"2fb4a0.ab59cb6","name":"","rules":[{"t":"set","p":"autoupdate","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":490,"y":780,"wires":[["7b2329c6.f52058"]]},{"id":"9605e9b6.f62f98","type":"ui_toast","z":"2fb4a0.ab59cb6","position":"bottom right","displayTime":"5","highlight":"","sendall":true,"outputs":0,"ok":"OK","cancel":"","topic":"","name":"","x":470,"y":820,"wires":[]},{"id":"785e3c32.e55414","type":"inject","z":"2fb4a0.ab59cb6","name":"","topic":"","payload":"Started!","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":"","x":80,"y":980,"wires":[["8489d6b8.e07288"]]},{"id":"6d0d0b.9c7c62f4","type":"ui_toast","z":"2fb4a0.ab59cb6","position":"dialog","displayTime":"3","highlight":"","sendall":true,"outputs":1,"ok":"OK","cancel":"","topic":"","name":"","x":710,"y":1120,"wires":[[]]},{"id":"5ca1eb04.d492a4","type":"python3-function","z":"2fb4a0.ab59cb6","name":"set image as fullscreen","func":"import time\ntime.sleep(1)\ntimestamp =str(int(time.time()))\nmsg['payload']=''\nreturn msg","outputs":1,"x":520,"y":1120,"wires":[["6d0d0b.9c7c62f4"]]},{"id":"e3fb5260.5d613","type":"ui_button","z":"2fb4a0.ab59cb6","name":"","group":"b0cc7e63.5b5b3","order":4,"width":5,"height":1,"passthru":false,"label":"Fullscreen","tooltip":"This will open the current preview in a larger window","color":"","bgcolor":"","icon":"","payload":"off","payloadType":"str","topic":"","x":90,"y":1120,"wires":[["53caf877.dcd7e8"]]},{"id":"5a50b653.49be68","type":"python3-function","z":"4aee81d.130dd8","name":"PopUp new Version","func":"from time import sleep\nsleep (1)\n\nif msg['payload']==\"new updates available\":\n msg['payload']=\"-- New Updates Available --- Install & reboot now?\"\n return msg","outputs":1,"x":190,"y":600,"wires":[["f8c24f06.ee9ec"]]},{"id":"f8c24f06.ee9ec","type":"ui_toast","z":"4aee81d.130dd8","position":"dialog","displayTime":"3","highlight":"","sendall":true,"outputs":1,"ok":"No","cancel":"Yes","topic":"","name":"","x":490,"y":600,"wires":[["fc87e670.3212f8"]]},{"id":"fc87e670.3212f8","type":"python3-function","z":"4aee81d.130dd8","name":"msg","func":"import os\n\nif msg['payload']!=\"Yes\":\n return\nwith open(\"/home/pi/shared/log/currentserverversion.log\", \"r\") as file:\n msg['file']=file.read()+\".json\"\n\nif os.stat(\"/home/pi/shared/ui/data/old_flows/\"+msg['file']).st_size==0:\n return\n\nreturn msg","outputs":1,"x":630,"y":600,"wires":[["c8844641.814568"]]},{"id":"7b2329c6.f52058","type":"python3-function","z":"2fb4a0.ab59cb6","name":"sleep","func":"from time import sleep\nwith open(\"/home/pi/shared/log/currentstatus_rpi.log\", \"w\") as file:\n file.write(\"initalizing\")\n\nsleep(1.3)\n\nreturn msg","outputs":1,"x":670,"y":780,"wires":[["7e951847.2eb768"]]},{"id":"53caf877.dcd7e8","type":"change","z":"2fb4a0.ab59cb6","name":"","rules":[{"t":"set","p":"autoupdate","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":290,"y":1120,"wires":[["5ca1eb04.d492a4","fa8c625c.095dd"]]},{"id":"850ed87b.3ffcd8","type":"ui_button","z":"9a152ded.cdff9","name":"","group":"f7451b10.d6c048","order":7,"width":"10","height":"2","passthru":false,"label":"INSTALL SIMPLIFIED USER INTERFACE","tooltip":"","color":"","bgcolor":"red","icon":"","payload":"","payloadType":"str","topic":"","x":165,"y":1219,"wires":[["35ea5e3c.4f82c2"]]},{"id":"f1202a3e.553818","type":"ui_toast","z":"9a152ded.cdff9","position":"dialog","displayTime":"5","highlight":"","sendall":true,"outputs":1,"ok":"No","cancel":"Yes","raw":false,"topic":"","name":"","x":795,"y":1219,"wires":[["ea2d7f3c.1d412"]]},{"id":"ea2d7f3c.1d412","type":"python3-function","z":"9a152ded.cdff9","name":"Download and Install","func":"import os\n\nif msg['payload']!=\"Yes\":\n return\n\nfile = '/home/pi/.node-red/temp'\nurl = 'https://raw.githubusercontent.com/OpenScanEu/OpenScan/master/update_universal.json'\ntry:\n os.remove(file)\nexcept OSError:\n pass\nos.system('wget -O'+file+' '+url+' >/dev/null 2>&1')\n\nsize = os.stat(file).st_size\nif size<1000:\n msg['payload']=\"received not enough data - check internet connection and try again\"\n os.remove(file)\n return None,msg\n\nfile1 = '/home/pi/.node-red/temp2'\nos.system('wget -O'+file1+' '+url+' >/dev/null 2>&1')\n\nif os.stat(file1).st_size!=size:\n msg['payload']=\"wrong filesize - check internet connection and try again\"\n os.remove(file1)\n return None,msg\n\nos.system('sudo cp /home/pi/.node-red/temp2 /home/pi/.node-red/flows_raspberrypi.json')\nos.remove(file)\nos.remove(file1)\nmsg['payload']=\"Restarting now, please be patient, this will take 3-5min :)\"\nreturn msg","outputs":2,"x":986,"y":1219,"wires":[["8d5ee713.f05898","3350027c.cfb2fe"],["800f6262.9460d"]]},{"id":"c20583b2.4fb09","type":"function","z":"9a152ded.cdff9","name":"t/f","func":"if (msg.payload === true){\n msg.payload=\"Install new Firmware? (SEVERAL AUTOMATIC RESTARTS)\"\n return [msg,null]\n}\nmsg.payload=\"no internet connection\"\nreturn [null,msg]\n","outputs":2,"noerr":0,"x":455,"y":1219,"wires":[["2137ba67.795796"],["84ef5ce6.7d05c"]]},{"id":"35ea5e3c.4f82c2","type":"is online","z":"9a152ded.cdff9","name":"","url":"www.google.com","action":"0","x":325,"y":1219,"wires":[["c20583b2.4fb09"]]},{"id":"84ef5ce6.7d05c","type":"link out","z":"9a152ded.cdff9","name":"","links":["51433c54.55af44"],"x":560,"y":1279,"wires":[]},{"id":"800f6262.9460d","type":"ui_toast","z":"9a152ded.cdff9","position":"dialog","displayTime":"5","highlight":"","sendall":true,"outputs":1,"ok":"OK","cancel":"","raw":true,"topic":"","name":"Error handling","x":1185,"y":1259,"wires":[[]]},{"id":"8d5ee713.f05898","type":"ui_toast","z":"9a152ded.cdff9","position":"dialog","displayTime":"5","highlight":"","sendall":true,"outputs":1,"ok":"OK","cancel":"","raw":false,"topic":"","name":"","x":1175,"y":1219,"wires":[[]]},{"id":"3350027c.cfb2fe","type":"link out","z":"9a152ded.cdff9","name":"","links":["772edab5.39d4f4"],"x":1115,"y":1180,"wires":[]},{"id":"5279867e.00ae18","type":"python3-function","z":"9a152ded.cdff9","name":"install node-red-module + increase gpu","func":"import os\n\npath=\"/home/pi/.node-red/node_modules/node-red-node-ui-table\"\n\nif(os.path.exists(path)==False):\n os.system(\"cd /home/pi/.node-red && npm i node-red-node-ui-table\")\n os.system(\"node-red-restart\")\nelse:\n pass\n\nif os.popen('vcgencmd get_mem gpu').read()[0:8]!=\"gpu=256M\":\n os.system(\"sudo sed -i -e 's/gpu_mem=128/gpu_mem=256/g' /boot/config.txt\")\n os.system(\"reboot -h\")","outputs":1,"x":425,"y":1159,"wires":[[]]},{"id":"2137ba67.795796","type":"python3-function","z":"9a152ded.cdff9","name":"check module","func":"import os\n\npath=\"/home/pi/.node-red/node_modules/node-red-node-ui-table\"\n\nif(os.path.exists(path)==False):\n msg['payload']=\"dependencies are missing, installing now. (Internet Connection required)\"\n return None,msg\nelse:\n return msg,None","outputs":2,"x":625,"y":1219,"wires":[["f1202a3e.553818"],["884bab9d.175bb8","8b55b4e9.0e0be8"]]},{"id":"884bab9d.175bb8","type":"python3-function","z":"9a152ded.cdff9","name":"install","func":"import os\nos.system(\"cd /home/pi/.node-red && npm i node-red-node-ui-table\")\nos.system(\"node-red-restart\")","outputs":1,"x":775,"y":1259,"wires":[[]]},{"id":"8b55b4e9.0e0be8","type":"ui_toast","z":"9a152ded.cdff9","position":"dialog","displayTime":"5","highlight":"","sendall":true,"outputs":1,"ok":"OK","cancel":"","raw":false,"topic":"","name":"","x":795,"y":1299,"wires":[[]]},{"id":"6a7eef9d.2fb59","type":"inject","z":"9a152ded.cdff9","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":155,"y":1159,"wires":[["5279867e.00ae18"]]},{"id":"c0cd0d3e.939f6","type":"ui_template","z":"9a152ded.cdff9","group":"f7451b10.d6c048","name":"","order":3,"width":10,"height":"10","format":" \n
Improved Firmware
\n -- highly recommended :) --\n\n\n
There is a new firmware, which has been improved in many ways:\n\n- routine is 50-70% faster
\n- interface is more stable
\n- better image quality
\n- ...
\n- Changelog at Github
\n
\nNote, that the simplified GUI is not supporting DSLR via USB yet. (Pi Camera is fully functional :)
You can go back to your current firmware at any given time.\n\n","storeOutMessages":true,"fwdInMessages":false,"templateScope":"local","x":125,"y":1279,"wires":[[]]}]