/* ----------------------------------------------------------------------------- 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 deleteOb(inst)= 0;; fun cbCommand(inst, from, action, param, rep, punit)= let punit -> [ptype phouse punit] in let hd (strextr param) -> lparam in if lparam == nil then nil else let hd lparam -> command in let (hd tl lparam) -> house in let atoi (hd tl tl lparam) -> unit in let (hd tl tl tl lparam) -> value in if (strcmpi house phouse) then nil else if (unit == nil) || ((unit == punit) || ((unit == (punit + 1)) && (!strcmpi ptype "MS13E"))) then ( if (!strcmpi command "AllOff") then ( SendPluginEvent inst "Off" nil nil; 0; ) else if (!strcmpi command "AllLightsOn") then ( if ((!strcmp ptype "LM12") || (!strcmp ptype "LM15ES")) then SendPluginEvent inst "On" nil nil else nil; 0; ) else if (!strcmpi command "UnitOn") then ( if (unit == punit + 1) && (!strcmpi ptype "MS13E") then SendPluginEvent inst "Light On" nil nil else SendPluginEvent inst "On" nil nil; 0; ) else if (!strcmpi command "UnitOff") then ( if (unit == punit + 1) && (!strcmpi ptype "MS13E") then SendPluginEvent inst "Light Off" nil nil else SendPluginEvent inst "Off" nil nil; 0; ) else if (!strcmpi command "UnitDim") then ( if ((!strcmp ptype "LM12") || (!strcmp ptype "LM15ES")) then SendPluginEvent inst "Dim" value nil else nil; 0; ) else if (!strcmpi command "UnitBright") then ( if ((!strcmp ptype "LM12") || (!strcmp ptype "LM15ES")) then SendPluginEvent inst "Bright" value nil else nil; 0; ) else nil; ) else nil; 0;; fun cbOn(inst, from, action, param, rep, punit)= let punit -> [ptype phouse punit] in SendPluginEvent inst "Send command" strcatn "UnitOn "::phouse::" "::(itoa punit)::nil nil; 0;; fun cbOff(inst, from, action, param, rep, punit)= let punit -> [ptype phouse punit] in SendPluginEvent inst "Send command" strcatn "UnitOff "::phouse::" "::(itoa punit)::nil nil; 0;; fun cbBright(inst, from, action, param, rep, punit)= if (atoi param) == nil then nil else let punit -> [ptype phouse punit] in SendPluginEvent inst "Send command" strcatn "UnitBright "::phouse::" "::(itoa punit)::" "::param::nil nil; 0;; fun cbDim(inst, from, action, param, rep, punit)= if (atoi param) == nil then nil else let punit -> [ptype phouse punit] in SendPluginEvent inst "Send command" strcatn "UnitDim "::phouse::" "::(itoa punit)::" "::param::nil nil; 0;; fun newOb(inst)= let (getPluginInstanceParam inst "type") -> stype in let (getPluginInstanceParam inst "house") -> house in let atoi (getPluginInstanceParam inst "unit") -> unit in let [stype house unit] -> punit in ( PluginRegisterAction inst "Get command" mkfun6 @cbCommand punit; PluginRegisterAction inst "On" mkfun6 @cbOn punit; PluginRegisterAction inst "Off" mkfun6 @cbOff punit; PluginRegisterAction inst "Bright" mkfun6 @cbBright punit; PluginRegisterAction inst "Dim" mkfun6 @cbDim punit; setPluginInstanceCbDel inst @deleteOb; ); 0;; fun IniPlug(file)= PlugRegister @newOb nil; setPluginEditor @dynamicedit; 0;;