/*
-----------------------------------------------------------------------------
This source file is part of OpenSpace3D
For the latest info, see http://www.openspace3d.com
Copyright (c) 2016 I-maginer
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA, or go to
http://www.gnu.org/copyleft/lesser.txt
-----------------------------------------------------------------------------
*/
/*
Version : 1.0
First version : 09/20/2016
Author : Bourineau Bastien
*/
/*! \brief Callback on plugIT instance editor closed
*
* Prototype: fun [] [[S S] r1]
*
* \return [[S S] r1] : parameters to save in the instance XML data
**/
fun cbCloseEdit(p)=
let p -> [ctrlcmd ctrlinit] in
["cmd" (getEdCtrlEditTextValue ctrlcmd)]::
["init" itoa (getEdCtrlCheckState ctrlinit)]::
nil;;
fun cbPresetSelect(ctrl, pos, elem, ctrlcmd)=
let if pos == 1 then
"hostname -I"
else if pos == 2 then
"vcgencmd measure_temp"
else if pos == 3 then
"vcgencmd measure_volts core"
else if pos == 4 then
"vcgencmd get_mem arm && vcgencmd get_mem gpu"
else if pos == 5 then
"free -oh"
else if pos == 6 then
"echo $(($( cmd in
if (cmd == nil) then nil else
setEdCtrlEditTextValue ctrlcmd cmd;
0;;
/*! \brief Callback on plugIT instance editor opened
*
* Prototype: fun [EdWindow PInstance V3Dview] I
*
* \param EdWindow : editor window structure
* \param PInstance : plugIT instance
* \param V3Dview : default 3D view structure
*
* \return @fun [] [[S S] r1] : Callback to call on close
**/
fun dynamicedit(winstr, inst, viewstr, applybtn)=
let [400 125] -> [iw ih] in
(
setEdWindowSize winstr iw ih;
let getPluginInstanceParam inst "cmd" -> cmd in
let if cmd == nil then "" else cmd -> cmd in
let atoi (getPluginInstanceParam inst "init") -> init in
let if init == nil then 0 else init -> init in
let 10 -> ypos in
let crEdCtrlLabel winstr 10 ypos + 2 90 20 (loc "OS3DSYSCMD_0001") nil -> labelpreset in
let crEdCtrlSelect winstr 120 ypos (iw - 130) 130 EDWIN_RESIZE_MW -> ctrlpreset in
let crEdCtrlLabel winstr 10 (set ypos = ypos + 25) + 2 90 20 (loc "OS3DSYSCMD_0002") nil -> labelcmd in
let crEdCtrlEditText winstr 120 ypos (iw - 130) 60 cmd ET_VSCROLL|ET_BORDER EDWIN_RESIZE_MW -> ctrlcmd in
let crEdCtrlCheck winstr 10 (set ypos = ypos + 65) 280 20 (loc "OS3DSYSCMD_0003") EDWIN_RESIZE_MW -> ctrlinit in
(
fillEdCtrlSelect ctrlpreset "Preset"::"IP address"::"RPI current temperature"::"RPI current voltage"::"RPI memory"::"RPI memory status"::"CPU real time frequency"::"Reboot system"::"Halt system"::nil;
setEdCtrlSelectCb ctrlpreset mkfun4 @cbPresetSelect ctrlcmd;
setEdCtrlCheckState ctrlinit init;
[mkfun1 @cbCloseEdit [ctrlcmd ctrlinit] nil];
);
);;