[{"data":1,"prerenderedAt":420},["ShallowReactive",2],{"docs-nav-docs_en":3,"docs-page-\u002Fen\u002Fpython-scripts\u002Faccessing-variables":190,"docs-surround-\u002Fen\u002Fpython-scripts\u002Faccessing-variables":417},[4],{"title":5,"path":6,"stem":7,"children":8},"En","\u002Fen","en",[9,13,37,50,68,86,105,119,138,159,176],{"title":10,"path":6,"stem":11,"navTitle":12},"QInsight Documentation","en\u002Findex","Overview",{"title":14,"navTitle":15,"path":16,"stem":17,"children":18,"page":36},"Getting Started",null,"\u002Fen\u002Fgetting-started","en\u002F01.getting-started",[19,23,27,31],{"title":20,"path":21,"stem":22,"navTitle":20},"What is QENEX Suite","\u002Fen\u002Fgetting-started\u002Fwhat-is-qenex-suite","en\u002F01.getting-started\u002F1.what-is-qenex-suite",{"title":24,"path":25,"stem":26,"navTitle":24},"What is QInsight","\u002Fen\u002Fgetting-started\u002Fwhat-is-qinsight","en\u002F01.getting-started\u002F2.what-is-qinsight",{"title":28,"path":29,"stem":30,"navTitle":28},"Installation","\u002Fen\u002Fgetting-started\u002Finstallation","en\u002F01.getting-started\u002F3.installation",{"title":32,"path":33,"stem":34,"navTitle":35},"The QInsight user interface","\u002Fen\u002Fgetting-started\u002Fthe-qinsight-interface","en\u002F01.getting-started\u002F4.the-qinsight-interface","User interface",false,{"title":38,"navTitle":15,"path":39,"stem":40,"children":41,"page":36},"First Project","\u002Fen\u002Ffirst-project","en\u002F02.first-project",[42,46],{"title":43,"path":44,"stem":45,"navTitle":43},"Create a project","\u002Fen\u002Ffirst-project\u002Fcreate-a-project","en\u002F02.first-project\u002F1.create-a-project",{"title":47,"path":48,"stem":49,"navTitle":47},"Project structure","\u002Fen\u002Ffirst-project\u002Fproject-structure","en\u002F02.first-project\u002F2.project-structure",{"title":51,"navTitle":15,"path":52,"stem":53,"children":54,"page":36},"Connecting a Device","\u002Fen\u002Fconnecting-a-device","en\u002F03.connecting-a-device",[55,59,63],{"title":56,"path":57,"stem":58,"navTitle":56},"Add a driver","\u002Fen\u002Fconnecting-a-device\u002Fadd-a-driver","en\u002F03.connecting-a-device\u002F1.add-a-driver",{"title":60,"path":61,"stem":62,"navTitle":60},"Add a protocol","\u002Fen\u002Fconnecting-a-device\u002Fadd-a-protocol","en\u002F03.connecting-a-device\u002F2.add-a-protocol",{"title":64,"path":65,"stem":66,"navTitle":67},"Link a driver and a protocol","\u002Fen\u002Fconnecting-a-device\u002Flink-driver-and-protocol","en\u002F03.connecting-a-device\u002F3.link-driver-and-protocol","Linking",{"title":69,"navTitle":15,"path":70,"stem":71,"children":72,"page":36},"Variables","\u002Fen\u002Fvariables","en\u002F04.variables",[73,77,82],{"title":74,"path":75,"stem":76,"navTitle":74},"What is a variable","\u002Fen\u002Fvariables\u002Fwhat-is-a-variable","en\u002F04.variables\u002F1.what-is-a-variable",{"title":78,"path":79,"stem":80,"navTitle":81},"Conversion and presentation","\u002Fen\u002Fvariables\u002Fconversion-and-presentation","en\u002F04.variables\u002F2.conversion-and-presentation","Conversion & presentation",{"title":83,"path":84,"stem":85,"navTitle":83},"Add a variable","\u002Fen\u002Fvariables\u002Fadd-a-variable","en\u002F04.variables\u002F3.add-a-variable",{"title":87,"navTitle":15,"path":88,"stem":89,"children":90,"page":36},"Visualization","\u002Fen\u002Fvisualization","en\u002F05.visualization",[91,96,100],{"title":92,"path":93,"stem":94,"navTitle":95},"Create a workspace","\u002Fen\u002Fvisualization\u002Fcreate-a-workspace","en\u002F05.visualization\u002F1.create-a-workspace","Workspace",{"title":97,"path":98,"stem":99,"navTitle":97},"Add a control","\u002Fen\u002Fvisualization\u002Fadd-a-control","en\u002F05.visualization\u002F2.add-a-control",{"title":101,"path":102,"stem":103,"navTitle":104},"Bind a control to a variable","\u002Fen\u002Fvisualization\u002Fbind-a-control","en\u002F05.visualization\u002F3.bind-a-control","Bind a control",{"title":106,"navTitle":15,"path":107,"stem":108,"children":109,"page":36},"Running and Monitoring","\u002Fen\u002Frunning","en\u002F06.running",[110,114],{"title":111,"path":112,"stem":113,"navTitle":111},"Start and stop","\u002Fen\u002Frunning\u002Fstart-and-stop","en\u002F06.running\u002F1.start-and-stop",{"title":115,"path":116,"stem":117,"navTitle":118},"Watching live data","\u002Fen\u002Frunning\u002Fwatching-live-data","en\u002F06.running\u002F2.watching-live-data","Live data",{"title":120,"navTitle":15,"path":121,"stem":122,"children":123,"page":36},"Logging and Replay","\u002Fen\u002Flogging-and-replay","en\u002F07.logging-and-replay",[124,128,133],{"title":125,"path":126,"stem":127,"navTitle":125},"Logging data","\u002Fen\u002Flogging-and-replay\u002Flogging-data","en\u002F07.logging-and-replay\u002F1.logging-data",{"title":129,"path":130,"stem":131,"navTitle":132},"Replaying a log","\u002Fen\u002Flogging-and-replay\u002Freplaying-a-log","en\u002F07.logging-and-replay\u002F2.replaying-a-log","Replay",{"title":134,"path":135,"stem":136,"navTitle":137},"Exporting data","\u002Fen\u002Flogging-and-replay\u002Fexporting-data","en\u002F07.logging-and-replay\u002F3.exporting-data","Export",{"title":139,"navTitle":15,"path":140,"stem":141,"children":142,"page":36},"Python Scripts","\u002Fen\u002Fpython-scripts","en\u002F08.python-scripts",[143,147,151,155],{"title":144,"path":145,"stem":146,"navTitle":12},"Scripts overview","\u002Fen\u002Fpython-scripts\u002Fscripts-overview","en\u002F08.python-scripts\u002F1.scripts-overview",{"title":148,"path":149,"stem":150,"navTitle":148},"Accessing variables","\u002Fen\u002Fpython-scripts\u002Faccessing-variables","en\u002F08.python-scripts\u002F2.accessing-variables",{"title":152,"path":153,"stem":154,"navTitle":152},"Example script","\u002Fen\u002Fpython-scripts\u002Fexample-script","en\u002F08.python-scripts\u002F3.example-script",{"title":156,"path":157,"stem":158,"navTitle":156},"CSV post-processing","\u002Fen\u002Fpython-scripts\u002Fcsv-post-processing","en\u002F08.python-scripts\u002F4.csv-post-processing",{"title":160,"navTitle":15,"path":161,"stem":162,"children":163,"page":36},"Custom extensions","\u002Fen\u002Fcustom-extensions","en\u002F09.custom-extensions",[164,168,172],{"title":165,"path":166,"stem":167,"navTitle":165},"Custom driver","\u002Fen\u002Fcustom-extensions\u002Fcustom-driver","en\u002F09.custom-extensions\u002F1.custom-driver",{"title":169,"path":170,"stem":171,"navTitle":169},"Custom protocol","\u002Fen\u002Fcustom-extensions\u002Fcustom-protocol","en\u002F09.custom-extensions\u002F2.custom-protocol",{"title":173,"path":174,"stem":175,"navTitle":173},"Custom Control","\u002Fen\u002Fcustom-extensions\u002Fcustom-control","en\u002F09.custom-extensions\u002F3.custom-control",{"title":177,"navTitle":15,"path":178,"stem":179,"children":180,"page":36},"Reference","\u002Fen\u002Freference","en\u002F10.reference",[181,186],{"title":182,"path":183,"stem":184,"navTitle":185},"Drivers, protocols, and controls","\u002Fen\u002Freference\u002Fdrivers-protocols-controls","en\u002F10.reference\u002F1.drivers-protocols-controls","Drivers, protocols, controls",{"title":187,"path":188,"stem":189,"navTitle":187},"Troubleshooting","\u002Fen\u002Freference\u002Ftroubleshooting","en\u002F10.reference\u002F2.troubleshooting",{"id":191,"title":148,"body":192,"description":411,"extension":412,"meta":413,"navTitle":148,"navigation":414,"path":149,"seo":415,"stem":150,"__hash__":416},"docs_en\u002Fen\u002F08.python-scripts\u002F2.accessing-variables.md",{"type":193,"value":194,"toc":406},"minimark",[195,199,213,248,279,284,287,291,302,310,353,360,374,392,396,402],[196,197,148],"h1",{"id":198},"accessing-variables",[200,201,202,203,207,208,212],"p",{},"Every project variable is available in a script as an object ",[204,205,206],"strong",{},"under its own\nname",". A variable named ",[209,210,211],"code",{},"OilTemp"," is therefore used directly:",[214,215,220],"pre",{"className":216,"code":217,"language":218,"meta":219,"style":219},"language-python shiki shiki-themes github-light github-dark","temp = OilTemp.RawValue         # read the raw value\nOilTemp.RawValue = 42           # write a value (the type converts automatically)\neng = OilTemp.EngValue          # the engineering value (after conversion), read-only\nprint(OilTemp.Name, OilTemp.Id) # the variable name and Id\n","python","",[209,221,222,230,236,242],{"__ignoreMap":219},[223,224,227],"span",{"class":225,"line":226},"line",1,[223,228,229],{},"temp = OilTemp.RawValue         # read the raw value\n",[223,231,233],{"class":225,"line":232},2,[223,234,235],{},"OilTemp.RawValue = 42           # write a value (the type converts automatically)\n",[223,237,239],{"class":225,"line":238},3,[223,240,241],{},"eng = OilTemp.EngValue          # the engineering value (after conversion), read-only\n",[223,243,245],{"class":225,"line":244},4,[223,246,247],{},"print(OilTemp.Name, OilTemp.Id) # the variable name and Id\n",[249,250,251,258,269],"ul",{},[252,253,254,257],"li",{},[204,255,256],{},"RawValue"," — the raw value, read and write,",[252,259,260,263,264,268],{},[204,261,262],{},"EngValue"," — the value after conversion (see\n",[265,266,78],"a",{"href":267},"\u002Fvariables\u002Fconversion-and-presentation","),\ncurrently read-only,",[252,270,271,274,275,278],{},[204,272,273],{},"Name",", ",[204,276,277],{},"Id"," — the variable identification.",[280,281,283],"h2",{"id":282},"shared-script-scope","Shared script scope",[200,285,286],{},"All scripts of a project share one scope — whatever the Startup script\nprepares (functions, connections, counters) can be used by periodic scripts\nand cleaned up by the Shutdown script.",[280,288,290],{"id":289},"reacting-to-a-value-change","Reacting to a value change",[200,292,293,294,297,298,301],{},"A script in the ",[204,295,296],{},"OnValueChanged"," mode is bound to a specific variable.\nThe trigger condition is tuned in ",[204,299,300],{},"Parameters",":",[214,303,308],{"className":304,"code":306,"language":307},[305],"language-text","source=eng;mode=above;threshold=50;hysteresis=2\n","text",[209,309,306],{"__ignoreMap":219},[249,311,312,326,344],{},[252,313,314,317,318,321,322,325],{},[209,315,316],{},"source"," — evaluate the ",[209,319,320],{},"raw"," or the ",[209,323,324],{},"eng"," value,",[252,327,328,331,332,335,336,339,340,343],{},[209,329,330],{},"mode"," — ",[209,333,334],{},"delta"," (change larger than the threshold), ",[209,337,338],{},"above","\u002F",[209,341,342],{},"below","\n(crossing a limit, with hysteresis),",[252,345,346,274,349,352],{},[209,347,348],{},"threshold",[209,350,351],{},"hysteresis"," — the threshold and hysteresis.",[200,354,355,356,359],{},"A trigger can also be set conveniently right on the variable (the Variables\nsection, ",[204,357,358],{},"On-change triggers → Add trigger","):",[200,361,362,369],{},[363,364],"img",{"alt":365,"className":366,"src":368},"An on-change trigger on a variable",[367],"img-light","\u002Fimg\u002FQInsight_tut_8_2_trigger_light.png",[363,370],{"alt":365,"className":371,"src":373},[372],"img-dark","\u002Fimg\u002FQInsight_tut_8_2_trigger_dark.png",[200,375,376,377,274,380,383,384,387,388,391],{},"When triggered, the engine passes context in the variables\n",[209,378,379],{},"qenex_trigger_variable_name",[209,381,382],{},"qenex_trigger_old_value",",\n",[209,385,386],{},"qenex_trigger_new_value",", and ",[209,389,390],{},"qenex_trigger_delta",".",[280,393,395],{"id":394},"next","Next",[200,397,398,399,391],{},"The whole example put together —\n",[265,400,152],{"href":401},"\u002Fpython-scripts\u002Fexample-script",[403,404,405],"style",{},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":219,"searchDepth":238,"depth":238,"links":407},[408,409,410],{"id":282,"depth":232,"text":283},{"id":289,"depth":232,"text":290},{"id":394,"depth":232,"text":395},"Variables as objects in a script — RawValue, EngValue, and OnValueChanged triggers.","md",{},true,{"title":148,"description":411},"S8UskGO90PNBeJJiHP9CaNot-sxKH-6T6dtTn3Sww9Y",[418,419],{"title":144,"path":145,"stem":146,"navTitle":12,"children":-1},{"title":152,"path":153,"stem":154,"navTitle":152,"children":-1},1783626657072]