/* ----------------------------------------------------------------------------- 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, x10device)= _DSx10Device x10device; 0;; fun cbCommand(inst, from, action, param, rep, x10device)= 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 atoi (hd tl tl tl lparam) -> value in ( if (!strcmpi command "AllUnitsOff") then ( _X10allUnitOff x10device house; 0; ) else if (!strcmpi command "AllLightsOn") then ( _X10allLightsOn x10device house; 0; ) else if (!strcmpi command "UnitOn") then ( _X10unitOn x10device house unit; 0; ) else if (!strcmpi command "UnitOff") then ( _X10unitOff x10device house unit; 0; ) else if (!strcmpi command "UnitDim") then ( _X10unitDim x10device house unit value; 0; ) else if (!strcmpi command "UnitBright") then ( _X10unitBright x10device house unit value; 0; ) else nil; ); 0;; fun cbAllUnitsOff(x10device, inst, house)= SendPluginEvent inst "Command" strcatn "AllUnitsOff "::house::nil nil; 0;; fun cbAllLightsOn(x10device, inst, house)= SendPluginEvent inst "Command" strcatn "AllLightsOn "::house::nil nil; 0;; fun cbUnitOn(x10device, inst, house, unit)= SendPluginEvent inst "Command" strcatn "UnitOn "::house::" "::(itoa unit)::nil nil; 0;; fun cbUnitOff(x10device, inst, house, unit)= SendPluginEvent inst "Command" strcatn "UnitOff "::house::" "::(itoa unit)::nil nil; 0;; fun cbUnitDim(x10device, inst, house, unit, value)= SendPluginEvent inst "Command" strcatn "UnitDim "::house::" "::(itoa unit)::" "::(itoa value)::nil nil; 0;; fun cbUnitBright(x10device, inst, house, unit, value)= SendPluginEvent inst "Command" strcatn "UnitBright "::house::" "::(itoa unit)::" "::(itoa value)::nil nil; 0;; fun newOb(inst)= let atoi (getPluginInstanceParam inst "sport") -> sport in let if sport == nil then 1 else sport -> sport in let _CRx10Device _channel sport -> x10device in ( if (x10device != nil) then nil else addLogMessage (loc "OS3DX10CM11_0008"); _CBx10AllUnitsOff x10device @cbAllUnitsOff inst; _CBx10AllLightsOn x10device @cbAllLightsOn inst; _CBx10UnitOn x10device @cbUnitOn inst; _CBx10UnitOff x10device @cbUnitOff inst; _CBx10UnitDim x10device @cbUnitDim inst; _CBx10UnitBright x10device @cbUnitBright inst; PluginRegisterAction inst "Command" mkfun6 @cbCommand x10device; setPluginInstanceCbDel inst mkfun2 @deleteOb x10device; ); 0;; fun IniPlug(file)= PlugRegister @newOb nil; setPluginEditor @dynamicedit; 0;;