/* ----------------------------------------------------------------------------- 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 ----------------------------------------------------------------------------- */ /* Version : 1.0 First version : 05/08/2010 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 -> [ctrlport ctrlspeed ctrlbytesize ctrlparity ctrlstopbits ctrlendchar ctrlinit] in ["port" (getSelectedEdCtrlSelect ctrlport)]:: ["speed" (getSelectedEdCtrlSelect ctrlspeed)]:: ["bytesize" (getSelectedEdCtrlSelect ctrlbytesize)]:: ["parity" itoa (getSelectedEdCtrlSelectPos ctrlparity)]:: ["stopbits" itoa (getSelectedEdCtrlSelectPos ctrlstopbits)]:: ["lastchar" itoa (getSelectedEdCtrlSelectPos ctrlendchar)]:: ["init" itoa (getEdCtrlCheckState ctrlinit)]:: nil;; /*! \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 185] -> [iw ih] in ( setEdWindowSize winstr iw ih; let (getPluginInstanceParam inst "port") -> sport in let if sport == nil then "0" else sport -> sport in let (getPluginInstanceParam inst "speed") -> speed in let if speed == nil then "9600" else speed -> speed in let (getPluginInstanceParam inst "bytesize") -> bytesize in let if bytesize == nil then "8" else bytesize -> bytesize in let atoi (getPluginInstanceParam inst "parity") -> parity in let if parity == nil then 0 else parity -> parity in let atoi (getPluginInstanceParam inst "stopbits") -> stopbits in let if stopbits == nil then 0 else stopbits -> stopbits in // 0 equal to onestopbit let atoi (getPluginInstanceParam inst "lastchar") -> lastchar in let if lastchar == nil then 0 else lastchar -> lastchar in let atoi (getPluginInstanceParam inst "init") -> init in let if init == nil then 1 else init -> init in let 10 -> ypos in let crEdCtrlLabel winstr 10 (ypos + 2) 160 20 (loc "OS3DSERIAL_0002") nil -> labeltitle in let crEdCtrlSelect winstr 180 ypos 200 120 EDWIN_RESIZE_MW -> ctrlport in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DSERIAL_0008") nil -> labelspeed in let crEdCtrlSelect winstr 180 ypos 200 120 EDWIN_RESIZE_MW -> ctrlspeed in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DSERIAL_0001") nil -> labelbyte in let crEdCtrlSelect winstr 180 ypos 200 120 EDWIN_RESIZE_MW -> ctrlbytesize in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DSERIAL_0004") nil -> labelparity in let crEdCtrlSelect winstr 180 ypos 200 120 EDWIN_RESIZE_MW -> ctrlparity in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DSERIAL_0009") nil -> labelstopbits in let crEdCtrlSelect winstr 180 ypos 200 120 EDWIN_RESIZE_MW -> ctrlstopbits in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DSERIAL_0003") nil -> labelendchar in let crEdCtrlSelect winstr 180 ypos 200 120 EDWIN_RESIZE_MW -> ctrlendchar in let crEdCtrlCheck winstr 10 (set ypos = ypos + 25) 280 20 (loc "OS3DSERIAL_0010") EDWIN_RESIZE_MW -> ctrlinit in ( let 0 -> i in while i < 256 do ( addEdCtrlSelect ctrlport itoa i; set i = i + 1; ); selectEdCtrlSelect ctrlport sport; fillEdCtrlSelect ctrlspeed "110"::"300"::"600"::"1200"::"2400"::"4800"::"9600"::"14400"::"19200"::"38400"::"56000"::"57600"::"115200"::"128000"::"256000"::nil; selectEdCtrlSelect ctrlspeed speed; fillEdCtrlSelect ctrlbytesize "4"::"5"::"6"::"7"::"8"::nil; selectEdCtrlSelect ctrlbytesize bytesize; fillEdCtrlSelect ctrlparity "NONE"::"ODD"::"EVEN"::"MARK"::"SPACE"::nil; selectEdCtrlSelectByPos ctrlparity parity; fillEdCtrlSelect ctrlstopbits "1"::"1.5"::"2"::nil; selectEdCtrlSelectByPos ctrlstopbits stopbits; fillEdCtrlSelect ctrlendchar "NONE"::"CR (/13)"::"CRLF (/13/10)"::nil; selectEdCtrlSelectByPos ctrlendchar lastchar; setEdCtrlCheckState ctrlinit init; [mkfun1 @cbCloseEdit [ctrlport ctrlspeed ctrlbytesize ctrlparity ctrlstopbits ctrlendchar ctrlinit] nil]; ); );;