/* ----------------------------------------------------------------------------- This source file is part of OpenSpace3D For the latest info, see http://www.openspace3d.com Copyright (c) 2012 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 ----------------------------------------------------------------------------- */ fun getSeqs(l)= let sizelist l -> size in let nil -> ndata in let 0 -> i in let nil -> nl in ( while i < size do ( let nth_list l i -> elem in let strToListSep elem "," -> pseq in let (hd pseq) -> name in ( set ndata = [(strcat "seq_" (itoa i)) name]::ndata; set ndata = [(strcat "timeout_" (itoa i)) (nth_list pseq 1)]::ndata; if (isStringInListi nl name) then nil else ( set ndata = ["ACTION" name]::ndata; set ndata = ["EVENT" strcat "Waiting for " name]::ndata; set ndata = ["EVENT" strcat name " valided"]::ndata; set nl = name::nl; ); ); set i = i + 1; ); ndata; );; fun cbCloseEdit(p)= let p -> [ctrlseq ctrlfail ctrlinit] in let getEdCtrlListElems ctrlseq -> lseqs in let getEdCtrlCheckState ctrlfail -> errorfail in let getEdCtrlCheckState ctrlinit -> init in ["errorfail" itoa errorfail]:: ["init" itoa init]:: getSeqs lseqs;; fun loadSeq(inst)= let nil -> ndata in let 0 -> i in ( let getPluginInstanceParam inst (strcat "seq_" (itoa i)) -> seqname in let getPluginInstanceParam inst (strcat "timeout_" (itoa i)) -> timeout in while (seqname != nil) do ( let strcatnSep seqname::timeout::nil "," -> elem in set ndata = if i == 0 then elem::nil else lcat ndata elem::nil; set i = i + 1; set seqname = getPluginInstanceParam inst (strcat "seq_" (itoa i)); set timeout = getPluginInstanceParam inst (strcat "timeout_" (itoa i)); ); ndata; );; fun cbSetList(ctrlstr, p)= let p -> [ctrllist ctrlseqname ctrltimeout] in let getEdCtrlTextLineValue ctrlseqname -> value in if (value == nil) || (!strcmp "" strtrim value) then nil else let getSelectedEdCtrlListExt ctrllist -> [pos name _ _] in ( let ftoa getEdCtrlFloatValue ctrltimeout -> timeout in let strcatnSep value::timeout::nil "," -> nvalue in ( renameEdCtrlListElementByPos ctrllist pos nvalue; selectEdCtrlListByPos ctrllist pos; ); ); 0;; fun cbAddList(ctrlstr, p)= let p -> [ctrllist ctrlseqname ctrltimeout] in let getEdCtrlTextLineValue ctrlseqname -> value in if (value == nil) || (!strcmp "" strtrim value) then nil else let getEdCtrlListElems ctrllist -> lelem in ( //if (isStringInListiPos lelem value 0 (strlen value)) then nil else let ftoa getEdCtrlFloatValue ctrltimeout -> timeout in let strcatnSep value::timeout::nil "," -> nvalue in ( addEdCtrlList ctrllist nvalue nil nil; //selectEdCtrlList ctrllist nvalue; setEdCtrlTextLineValue ctrlseqname ""; setEdCtrlFloatValue ctrltimeout 0.0; ); ); 0;; fun fillSeqCtrls(value, p)= let p -> [ctrlseqname ctrltimeout] in let strToListSep value "," -> pseq in ( setEdCtrlTextLineValue ctrlseqname (hd pseq); setEdCtrlFloatValue ctrltimeout (atof (nth_list pseq 1)); ); 0;; fun cbSelectSeq(ctrlstr, pos, elem, lval, type, p)= fillSeqCtrls elem p; 0;; fun cbDelList(ctrlstr, p)= let p -> [ctrllist ctrlseqname ctrltimeout] in let getSelectedEdCtrlList ctrllist -> [name _ _] in ( delEdCtrlList ctrllist name; let getSelectedEdCtrlList ctrllist -> [sname _ _] in fillSeqCtrls sname [ctrlseqname ctrltimeout]; ); 0;; fun cbMoveUp(ctrlstr, p)= let p -> [ctrllist ctrlseqname ctrltimeout] in let getSelectedEdCtrlListExt ctrllist -> [pos _ _ _] in ( moveEdCtrlListElementUpByPos ctrllist pos; selectEdCtrlListByPos ctrllist (pos-1); ); 0;; fun cbMoveDown(ctrlstr, p)= let p -> [ctrllist ctrlseqname ctrltimeout] in let getSelectedEdCtrlListExt ctrllist -> [pos _ _ _] in ( moveEdCtrlListElementDownByPos ctrllist pos; selectEdCtrlListByPos ctrllist (pos+1); ); 0;; fun dynamicedit(ewinstr, inst, viewstr, applybtn)= let [400 310] -> [iw ih] in let 10 -> ypos in ( setEdWindowSize ewinstr iw ih; let atoi (getPluginInstanceParam inst "errorfail") -> errorfail in let if errorfail == nil then 0 else errorfail -> errorfail in let atoi (getPluginInstanceParam inst "init") -> init in let if init == nil then 1 else init -> init in let crEdFrameWindow _channel ewinstr 0 0 iw 230 EDWIN_RESIZE_MW nil (loc "OS3DSEQUENTIALINPUT_0006") (loc "OS3DSEQUENTIALINPUT_0007") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 210 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlList winstr 10 (set ypos = 10) (iw - 15) 120 LB_BORDER|LB_VSCROLL|ET_TABFOCUS EDWIN_RESIZE_MW|EDWIN_RESIZE_MH -> ctrlseq in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 125) + 2) 160 20 (loc "OS3DSEQUENTIALINPUT_0004") nil -> labelseqname in let crEdCtrlTextLine winstr 180 ypos 140 20 nil nil EDWIN_RESIZE_MW -> ctrlseqname in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DSEQUENTIALINPUT_0005") nil -> labeltimeout in let crEdCtrlFloat winstr 180 ypos 100 20 0.0 0.0 1000000.0 1.0 0 nil EDWIN_RESIZE_MW -> ctrltimeout in let crEdCtrlButton winstr 10 (set ypos = ypos + 25) 60 20 (loc "OS3DSEQUENTIALINPUT_0001") EDWIN_RESIZE_MW -> ctrlbtnadd in let crEdCtrlButton winstr 75 ypos 60 20 (loc "OS3DSEQUENTIALINPUT_0010") EDWIN_RESIZE_MW -> ctrlbtnset in let crEdCtrlButton winstr 140 ypos 60 20 (loc "OS3DSEQUENTIALINPUT_0009") EDWIN_RESIZE_MW -> ctrlbtndel in let crEdCtrlButton winstr (iw - 140) ypos 65 20 (loc "OS3DSEQUENTIALINPUT_0012") EDWIN_RESIZE_MW -> ctrlbtnup in let crEdCtrlButton winstr (iw - 70) ypos 65 20 (loc "OS3DSEQUENTIALINPUT_0002") EDWIN_RESIZE_MW -> ctrlbtndown in let crEdFrameWindow _channel ewinstr 0 0 iw 80 EDWIN_RESIZE_MW nil (loc "OS3DSEQUENTIALINPUT_0008") (loc "OS3DSEQUENTIALINPUT_0007") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 60 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlCheck winstr 10 (set ypos = 10) 280 20 (loc "OS3DSEQUENTIALINPUT_0003") EDWIN_RESIZE_MW -> ctrlfail in let crEdCtrlCheck winstr 10 (set ypos = ypos + 25) 280 20 (loc "OS3DSEQUENTIALINPUT_0011") EDWIN_RESIZE_MW -> ctrlinit in ( fillEdCtrlList ctrlseq (loadSeq inst); setEdCtrlListCbClick ctrlseq mkfun6 @cbSelectSeq [ctrlseqname ctrltimeout]; setEdCtrlButtonCb ctrlbtnadd mkfun2 @cbAddList [ctrlseq ctrlseqname ctrltimeout]; setEdCtrlButtonCb ctrlbtnset mkfun2 @cbSetList [ctrlseq ctrlseqname ctrltimeout]; setEdCtrlButtonCb ctrlbtndel mkfun2 @cbDelList [ctrlseq ctrlseqname ctrltimeout]; setEdCtrlButtonCb ctrlbtnup mkfun2 @cbMoveUp [ctrlseq ctrlseqname ctrltimeout]; setEdCtrlButtonCb ctrlbtndown mkfun2 @cbMoveDown [ctrlseq ctrlseqname ctrltimeout]; setEdCtrlCheckState ctrlinit init; setEdCtrlCheckState ctrlfail errorfail; [mkfun1 @cbCloseEdit [ctrlseq ctrlfail ctrlinit] nil]; ); );;