BGE patch: New Delay sensor (derived from patch #17472)
authorBenoit Bolsee <benoit.bolsee@online.be>
Sat, 16 Aug 2008 20:45:37 +0000 (20:45 +0000)
committerBenoit Bolsee <benoit.bolsee@online.be>
Sat, 16 Aug 2008 20:45:37 +0000 (20:45 +0000)
Introduction of a new Delay sensor that can be used to
generate positive and negative triggers at precise time,
expressed in number of frames.
The delay parameter defines the length of the initial
OFF period. A positive trigger is generated at the end
of this period. The duration parameter defines the
length of the ON period following the OFF period.
A negative trigger is generated at the end of the ON period.
If duration is 0, the sensor stays ON and there is no
negative trigger.
The sensor runs the OFF-ON cycle once unless the repeat
option is set: the OFF-ON cycle repeats indefinately
(or the OFF cycle if duration is 0).

The new generic SCA_ISensor::reset() Python function
can be used at any time to restart the sensor: the
current cycle is interrupted and no trigger is generated.

13 files changed:
projectfiles_vc7/gameengine/gamelogic/SCA_GameLogic.vcproj
source/blender/blenkernel/intern/sca.c
source/blender/blenloader/intern/writefile.c
source/blender/makesdna/DNA_sensor_types.h
source/blender/src/buttons_logic.c
source/gameengine/Converter/KX_ConvertSensors.cpp
source/gameengine/GameLogic/SCA_DelaySensor.cpp [new file with mode: 0644]
source/gameengine/GameLogic/SCA_DelaySensor.h [new file with mode: 0644]
source/gameengine/GameLogic/SCA_ISensor.cpp
source/gameengine/GameLogic/SCA_ISensor.h
source/gameengine/PyDoc/GameLogic.py
source/gameengine/PyDoc/SCA_DelaySensor.py [new file with mode: 0644]
source/gameengine/PyDoc/SCA_ISensor.py

index 7e2db4f564fbd99f9abfa38a84ad80f83a0c026f..5f14b5a09a1c0108ed6b8f881a5869b64cd8baa2 100644 (file)
                        <File
                                RelativePath="..\..\..\source\gameengine\GameLogic\SCA_ANDController.cpp">
                        </File>
+                       <File
+                               RelativePath="..\..\..\source\gameengine\GameLogic\SCA_DelaySensor.cpp">
+                       </File>
                        <File
                                RelativePath="..\..\..\source\gameengine\GameLogic\SCA_EventManager.cpp">
                        </File>
                        <File
                                RelativePath="..\..\..\source\gameengine\GameLogic\SCA_ANDController.h">
                        </File>
+                       <File
+                               RelativePath="..\..\..\source\gameengine\GameLogic\SCA_DelaySensor.h">
+                       </File>
                        <File
                                RelativePath="..\..\..\source\gameengine\GameLogic\SCA_EventManager.h">
                        </File>
index fcf1c7ce311fcc3aabba5be136efe7b9e9755e41..47d11bb9d298f42e4104dba76556dac27efb0c9b 100644 (file)
@@ -153,6 +153,9 @@ void init_sensor(bSensor *sens)
        case SENS_ACTUATOR:
                sens->data= MEM_callocN(sizeof(bActuatorSensor), "actsens");
                break;
+       case SENS_DELAY:
+               sens->data= MEM_callocN(sizeof(bDelaySensor), "delaysens");
+               break;
        case SENS_MOUSE:
                ms=sens->data= MEM_callocN(sizeof(bMouseSensor), "mousesens");
                ms->type= LEFTMOUSE;
index 3a70438dd136d7197b611a7eebaea2510c473ded..b462233528aa5b10016dc9f2e4e9eb2162d6b347 100644 (file)
@@ -608,6 +608,9 @@ static void write_sensors(WriteData *wd, ListBase *lb)
                case SENS_ACTUATOR:
                        writestruct(wd, DATA, "bActuatorSensor", 1, sens->data);
                        break;
+               case SENS_DELAY:
+                       writestruct(wd, DATA, "bDelaySensor", 1, sens->data);
+                       break;
                case SENS_COLLISION:
                        writestruct(wd, DATA, "bCollisionSensor", 1, sens->data);
                        break;
index c0306f4373067180a52405affcb19f46222d3fce..b5d8511c6981e94979d4228ba3338749c360ddcd 100644 (file)
@@ -88,6 +88,13 @@ typedef struct bActuatorSensor {
        char name[32];
 } bActuatorSensor;
 
+typedef struct bDelaySensor {
+    short delay;
+       short duration;
+       short flag;
+       short pad;
+} bDelaySensor;
+
 typedef struct bCollisionSensor {
        char name[32];          /* property name */
        char materialName[32];  /* material      */
@@ -204,6 +211,7 @@ typedef struct bJoystickSensor {
 #define SENS_MESSAGE   10
 #define SENS_JOYSTICK  11
 #define SENS_ACTUATOR  12
+#define SENS_DELAY     13
 /* sensor->flag */
 #define SENS_SHOW              1
 #define SENS_DEL               2
@@ -254,5 +262,7 @@ typedef struct bJoystickSensor {
 #define SENS_JOY_HAT                   2
 #define SENS_JOY_HAT_DIR               0
 
+#define SENS_DELAY_REPEAT              1
+
 #endif
 
index cdb667145731491ba06d3972a4e9074a92699b08..e16e058e0936ff84c7eebbcc6fa75795bb59a44c 100644 (file)
@@ -683,6 +683,8 @@ static char *sensor_name(int type)
                return "Property";
        case SENS_ACTUATOR:
                return "Actuator";
+       case SENS_DELAY:
+               return "Delay";
        case SENS_MOUSE:
                return "Mouse";
        case SENS_COLLISION:
@@ -704,7 +706,7 @@ static char *sensor_name(int type)
 static char *sensor_pup(void)
 {
        /* the number needs to match defines in game.h */
-       return "Sensors %t|Always %x0|Keyboard %x3|Mouse %x5|"
+       return "Sensors %t|Always %x0|Delay %x13|Keyboard %x3|Mouse %x5|"
                "Touch %x1|Collision %x6|Near %x2|Radar %x7|"
                "Property %x4|Random %x8|Ray %x9|Message %x10|Joystick %x11|Actuator %x12";
 }
@@ -1000,6 +1002,7 @@ static int get_col_sensor(int type)
 {
        switch(type) {
        case SENS_ALWAYS:               return TH_BUT_ACTION;
+       case SENS_DELAY:                return TH_BUT_ACTION;
        case SENS_TOUCH:                return TH_BUT_NEUTRAL;
        case SENS_COLLISION:    return TH_BUT_SETTING;
        case SENS_NEAR:                 return TH_BUT_SETTING1; 
@@ -1070,8 +1073,8 @@ static short draw_sensorbuttons(bSensor *sens, uiBlock *block, short xco, short
        bRaySensor       *raySens      = NULL;
        bMessageSensor   *mes          = NULL;
        bJoystickSensor  *joy              = NULL;
-       bActuatorSensor  *as          = NULL;
-
+       bActuatorSensor  *as           = NULL;
+       bDelaySensor     *ds               = NULL;
        short ysize;
        char *str;
        
@@ -1297,6 +1300,27 @@ static short draw_sensorbuttons(bSensor *sens, uiBlock *block, short xco, short
                        yco-= ysize;
                        break;
                }
+       case SENS_DELAY:
+               {
+                       ysize= 48;
+                       
+                       glRects(xco, yco-ysize, xco+width, yco);
+                       uiEmboss((float)xco, (float)yco-ysize,
+                               (float)xco+width, (float)yco, 1);
+                       
+                       draw_default_sensor_header(sens, block, xco, yco, width);
+                       ds = sens->data;
+                       
+                       uiDefButS(block, NUM, 0, "Delay",(short)(10+xco),(short)(yco-44),(short)((width-22)*0.4+10), 19,
+                               &ds->delay, 0.0, 5000.0, 0, 0, "Delay in number of frames before the positive trigger");
+                       uiDefButS(block, NUM, 0, "Dur",(short)(10+xco+(width-22)*0.4+10),(short)(yco-44),(short)((width-22)*0.4-10), 19,
+                               &ds->duration, 0.0, 5000.0, 0, 0, "If >0, delay in number of frames before the negative trigger following the positive trigger");
+                       uiDefButBitS(block, TOG, SENS_DELAY_REPEAT, 0, "REP",(short)(xco + 10 + (width-22)*0.8),(short)(yco - 44),
+                               (short)(0.20 * (width-22)), 19, &ds->flag, 0.0, 0.0, 0, 0,
+                               "Toggle repeat option. If selected, the sensor restarts after Delay+Dur frames");
+                       yco-= ysize;
+                       break;
+               }
        case SENS_MOUSE:
                {
                        ms= sens->data;
index 76a12fb7f42e4bc81bdfc48a027b0efb329b4300..4806df3609048794b39b0565590c39f8b9a1bb37 100644 (file)
@@ -65,6 +65,7 @@ probably misplaced */
 #include "SCA_JoystickSensor.h"
 #include "KX_NetworkMessageSensor.h"
 #include "SCA_ActuatorSensor.h"
+#include "SCA_DelaySensor.h"
 
 
 #include "SCA_PropertySensor.h"
@@ -281,6 +282,22 @@ void BL_ConvertSensors(struct Object* blenderobject,
                                break;
                        }
                        
+               case  SENS_DELAY:
+                       {
+                               // we can reuse the Always event manager for the delay sensor
+                               SCA_EventManager* eventmgr = logicmgr->FindEventManager(SCA_EventManager::ALWAYS_EVENTMGR);
+                               if (eventmgr)
+                               {
+                                       bDelaySensor* delaysensor = (bDelaySensor*)sens->data;
+                                       gamesensor = new SCA_DelaySensor(eventmgr, 
+                                               gameobj,
+                                               delaysensor->delay,
+                                               delaysensor->duration,
+                                               (delaysensor->flag & SENS_DELAY_REPEAT) != 0);
+                               }
+                               break;
+                       }
+
                case SENS_COLLISION:
                        {
                                SCA_EventManager* eventmgr = logicmgr->FindEventManager(SCA_EventManager::TOUCH_EVENTMGR);
diff --git a/source/gameengine/GameLogic/SCA_DelaySensor.cpp b/source/gameengine/GameLogic/SCA_DelaySensor.cpp
new file mode 100644 (file)
index 0000000..4d05250
--- /dev/null
@@ -0,0 +1,257 @@
+/**
+ * Delay trigger
+ *
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU 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.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef WIN32
+// This warning tells us about truncation of __long__ stl-generated names.
+// It can occasionally cause DevStudio to have internal compiler warnings.
+#pragma warning( disable : 4786 )     
+#endif
+
+#include "SCA_DelaySensor.h"
+#include "SCA_LogicManager.h"
+#include "SCA_EventManager.h"
+
+/* ------------------------------------------------------------------------- */
+/* Native functions                                                          */
+/* ------------------------------------------------------------------------- */
+
+SCA_DelaySensor::SCA_DelaySensor(class SCA_EventManager* eventmgr,
+                                                                SCA_IObject* gameobj,
+                                                                int delay,
+                                                                int duration,
+                                                                bool repeat,
+                                                                PyTypeObject* T)
+       : SCA_ISensor(gameobj,eventmgr, T), 
+       m_delay(delay),
+       m_duration(duration),
+       m_repeat(repeat)
+{
+       Init();
+}
+
+void SCA_DelaySensor::Init()
+{
+       m_lastResult = false;
+       m_frameCount = -1;
+       m_reset = true;
+}
+
+SCA_DelaySensor::~SCA_DelaySensor()
+{
+       /* intentionally empty */
+}
+
+CValue* SCA_DelaySensor::GetReplica()
+{
+       CValue* replica = new SCA_DelaySensor(*this);
+       // this will copy properties and so on...
+       CValue::AddDataToReplica(replica);
+
+       return replica;
+}
+
+
+
+bool SCA_DelaySensor::IsPositiveTrigger()
+{ 
+       return (m_invert ? !m_lastResult : m_lastResult);
+}
+
+bool SCA_DelaySensor::Evaluate(CValue* event)
+{
+       bool trigger = false;
+       bool result;
+
+       if (m_frameCount==-1) {
+               // this is needed to ensure ON trigger in case delay==0
+               // and avoid spurious OFF trigger when duration==0
+               m_lastResult = false;
+               m_frameCount = 0;
+       }
+
+       if (m_frameCount<m_delay) {
+               m_frameCount++;
+               result = false;
+       } else if (m_duration > 0) {
+               if (m_frameCount < m_delay+m_duration) {
+                       m_frameCount++;
+                       result = true;
+               } else {
+                       result = false;
+                       if (m_repeat)
+                               m_frameCount = -1;
+               }
+       } else {
+               result = true;
+               if (m_repeat)
+                       m_frameCount = -1;
+       }
+       if ((m_reset && m_level) || result != m_lastResult)
+               trigger = true;
+       m_reset = false;
+       m_lastResult = result;
+       return trigger;
+}
+
+/* ------------------------------------------------------------------------- */
+/* Python functions                                                          */
+/* ------------------------------------------------------------------------- */
+
+/* Integration hooks ------------------------------------------------------- */
+PyTypeObject SCA_DelaySensor::Type = {
+       PyObject_HEAD_INIT(&PyType_Type)
+       0,
+       "SCA_DelaySensor",
+       sizeof(SCA_DelaySensor),
+       0,
+       PyDestructor,
+       0,
+       __getattr,
+       __setattr,
+       0, //&MyPyCompare,
+       __repr,
+       0, //&cvalue_as_number,
+       0,
+       0,
+       0,
+       0
+};
+
+PyParentObject SCA_DelaySensor::Parents[] = {
+       &SCA_DelaySensor::Type,
+       &SCA_ISensor::Type,
+       &SCA_ILogicBrick::Type,
+       &CValue::Type,
+       NULL
+};
+
+PyMethodDef SCA_DelaySensor::Methods[] = {
+       /* setProperty */
+       {"setDelay", (PyCFunction) SCA_DelaySensor::sPySetDelay, METH_VARARGS, SetDelay_doc},
+       {"setDuration", (PyCFunction) SCA_DelaySensor::sPySetDuration, METH_VARARGS, SetDuration_doc},
+       {"setRepeat", (PyCFunction) SCA_DelaySensor::sPySetRepeat, METH_VARARGS, SetRepeat_doc},
+       /* getProperty */
+       {"getDelay", (PyCFunction) SCA_DelaySensor::sPyGetDelay, METH_NOARGS, GetDelay_doc},
+       {"getDuration", (PyCFunction) SCA_DelaySensor::sPyGetDuration, METH_NOARGS, GetDuration_doc},
+       {"getRepeat", (PyCFunction) SCA_DelaySensor::sPyGetRepeat, METH_NOARGS, GetRepeat_doc},
+       {NULL,NULL} //Sentinel
+};
+
+PyObject* SCA_DelaySensor::_getattr(const STR_String& attr) {
+       _getattr_up(SCA_ISensor);
+}
+
+char SCA_DelaySensor::SetDelay_doc[] = 
+"setDelay(delay)\n"
+"\t- delay: length of the initial OFF period as number of frame\n"
+"\t         0 for immediate trigger\n"
+"\tSet the initial delay before the positive trigger\n";
+PyObject* SCA_DelaySensor::PySetDelay(PyObject* self, PyObject* args, PyObject* kwds)
+{
+       int delay;
+       
+       if(!PyArg_ParseTuple(args, "i", &delay)) {
+               return NULL;
+       }
+       if (delay < 0) {
+               PyErr_SetString(PyExc_ValueError, "Delay cannot be negative");
+               return NULL;
+       }
+       m_delay = delay;
+       Py_Return;
+}
+
+char SCA_DelaySensor::SetDuration_doc[] = 
+"setDuration(duration)\n"
+"\t- duration: length of the ON period in number of frame after the initial off period\n"
+"\t            0 for no ON period\n"
+"\tSet the duration of the ON pulse after initial delay.\n"
+"\tIf > 0, a negative trigger is fired at the end of the ON pulse.\n";
+PyObject* SCA_DelaySensor::PySetDuration(PyObject* self, PyObject* args, PyObject* kwds)
+{
+       int duration;
+       
+       if(!PyArg_ParseTuple(args, "i", &duration)) {
+               return NULL;
+       }
+       if (duration < 0) {
+               PyErr_SetString(PyExc_ValueError, "Duration cannot be negative");
+               return NULL;
+       }
+       m_duration = duration;
+       Py_Return;
+}
+
+char SCA_DelaySensor::SetRepeat_doc[] = 
+"setRepeat(repeat)\n"
+"\t- repeat: 1 if the initial OFF-ON cycle should be repeated indefinately\n"
+"\t          0 if the initial OFF-ON cycle should run only once\n"
+"\tSet the sensor repeat mode\n";
+PyObject* SCA_DelaySensor::PySetRepeat(PyObject* self, PyObject* args, PyObject* kwds)
+{
+       int repeat;
+       
+       if(!PyArg_ParseTuple(args, "i", &repeat)) {
+               return NULL;
+       }
+       m_repeat = (repeat != 0);
+       Py_Return;
+}
+
+char SCA_DelaySensor::GetDelay_doc[] = 
+"getDelay()\n"
+"\tReturn the delay parameter value\n";
+PyObject* SCA_DelaySensor::PyGetDelay(PyObject* self)
+{
+       return PyInt_FromLong(m_delay);
+}
+
+char SCA_DelaySensor::GetDuration_doc[] = 
+"getDuration()\n"
+"\tReturn the duration parameter value\n";
+PyObject* SCA_DelaySensor::PyGetDuration(PyObject* self)
+{
+       return PyInt_FromLong(m_duration);
+}
+
+char SCA_DelaySensor::GetRepeat_doc[] = 
+"getRepeat()\n"
+"\tReturn the repeat parameter value\n";
+PyObject* SCA_DelaySensor::PyGetRepeat(PyObject* self)
+{
+       return BoolToPyArg(m_repeat);
+}
+
+/* eof */
diff --git a/source/gameengine/GameLogic/SCA_DelaySensor.h b/source/gameengine/GameLogic/SCA_DelaySensor.h
new file mode 100644 (file)
index 0000000..a997fab
--- /dev/null
@@ -0,0 +1,77 @@
+/**
+ * SCA_DelaySensor.h
+ *
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU 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.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef __KX_DELAYSENSOR
+#define __KX_DELAYSENSOR
+#include "SCA_ISensor.h"
+
+class SCA_DelaySensor : public SCA_ISensor
+{
+       Py_Header;
+       bool                    m_lastResult;
+       bool                    m_repeat;
+       int                             m_delay; 
+       int                             m_duration;
+       int                             m_frameCount;
+
+public:
+       SCA_DelaySensor(class SCA_EventManager* eventmgr,
+                                       SCA_IObject* gameobj,
+                                       int delay,
+                                       int duration,
+                                       bool repeat,
+                                       PyTypeObject* T =&Type);
+       virtual ~SCA_DelaySensor();
+       virtual CValue* GetReplica();
+       virtual bool Evaluate(CValue* event);
+       virtual bool IsPositiveTrigger();
+       virtual void Init();
+
+
+       /* --------------------------------------------------------------------- */
+       /* Python interface ---------------------------------------------------- */
+       /* --------------------------------------------------------------------- */
+       
+       virtual PyObject* _getattr(const STR_String& attr);
+
+       /* setProperty */
+       KX_PYMETHOD_DOC(SCA_DelaySensor,SetDelay);
+       KX_PYMETHOD_DOC(SCA_DelaySensor,SetDuration);
+       KX_PYMETHOD_DOC(SCA_DelaySensor,SetRepeat);
+       /* getProperty */
+       KX_PYMETHOD_DOC_NOARGS(SCA_DelaySensor,GetDelay);
+       KX_PYMETHOD_DOC_NOARGS(SCA_DelaySensor,GetDuration);
+       KX_PYMETHOD_DOC_NOARGS(SCA_DelaySensor,GetRepeat);
+
+};
+
+#endif //__KX_ALWAYSSENSOR
+
index 2dc49924062e28fcbceaa5801ccf1410f365bd69..f99b9b789d70f25071c891a29fd039ffbcf1a846 100644 (file)
@@ -189,6 +189,8 @@ PyMethodDef SCA_ISensor::Methods[] = {
         METH_NOARGS, GetLevel_doc},
        {"setLevel", (PyCFunction) SCA_ISensor::sPySetLevel, 
         METH_VARARGS, SetLevel_doc},
+       {"reset", (PyCFunction) SCA_ISensor::sPyReset, 
+        METH_NOARGS, Reset_doc},
        {NULL,NULL} //Sentinel
 };
 
@@ -390,4 +392,15 @@ PyObject* SCA_ISensor::PySetUseNegPulseMode(PyObject* self, PyObject* args, PyOb
        Py_Return;
 }
 
+char SCA_ISensor::Reset_doc[] = 
+"reset()\n"
+"\tReset sensor internal state, effect depends on the type of sensor and settings.\n"
+"\tThe sensor is put in its initial state as if it was just activated.\n";
+PyObject* SCA_ISensor::PyReset(PyObject* self)
+{
+       Init();
+       Py_Return;
+}
+
+
 /* eof */
index d5dabbce3ee9d3a5a8341d18af082ef66cfa4703..fc8f0bd001107ed3097c8296dd488f00a3a3651e 100644 (file)
@@ -148,6 +148,7 @@ public:
        KX_PYMETHOD_DOC(SCA_ISensor,SetInvert);
        KX_PYMETHOD_DOC_NOARGS(SCA_ISensor,GetLevel);
        KX_PYMETHOD_DOC(SCA_ISensor,SetLevel);
+       KX_PYMETHOD_DOC_NOARGS(SCA_ISensor,Reset);
 
 };
 
index 965c0522bd7ebea64fb0baad2fd45c3cf55e1182..c911ce8ec60102c133e39a084446ffbed62c28c2 100644 (file)
@@ -42,6 +42,7 @@ Documentation for the GameLogic Module.
                - L{SCA_MouseSensor}
                - L{SCA_PropertySensor} 
                - L{SCA_RandomSensor} 
+               - L{SCA_DelaySensor}
        
        You can also access actuators linked to the controller::
                # To get an actuator attached to the controller:
diff --git a/source/gameengine/PyDoc/SCA_DelaySensor.py b/source/gameengine/PyDoc/SCA_DelaySensor.py
new file mode 100644 (file)
index 0000000..46b74f4
--- /dev/null
@@ -0,0 +1,56 @@
+# $Id$
+# Documentation for SCA_DelaySensor
+from SCA_IActuator import *
+
+class SCA_DelaySensor(SCA_ISensor):
+       """
+       The Delay sensor generates positive and negative triggers at precise time,
+       expressed in number of frames. The delay parameter defines the length
+       of the initial OFF period. A positive trigger is generated at the end of this period. 
+       The duration parameter defines the length of the ON period following the OFF period.
+       There is a negative trigger at the end of the ON period. If duration is 0, the sensor
+       stays ON and there is no negative trigger.
+       The sensor runs the OFF-ON cycle once unless the repeat option is set: the
+       OFF-ON cycle repeats indefinately (or the OFF cycle if duration is 0).
+       Use SCA_ISensor::reset() at any time to restart sensor.
+       """
+       def setDelay(delay):
+               """
+               Set the initial delay before the positive trigger.
+               
+               @param delay: length of the initial OFF period as number of frame, 0 for immediate trigger
+               @type delay: integer
+               """
+       def setDuration(duration):
+               """
+               Set the duration of the ON pulse after initial delay and the generation of the positive trigger.
+               If duration is greater than 0, a negative trigger is sent at the end of the ON pulse.
+               
+               @param duration: length of the ON period in number of frame after the initial OFF period
+               @type duration: integer
+               """     
+       def setRepeat(repeat):
+               """
+               Set if the sensor repeat mode.
+               
+               @param repeat: 1 if the OFF-ON cycle should be repeated indefinately, 0 if it should run once.
+               @type repeat: integer
+               """             
+       def getDelay():
+               """
+               Return the delay parameter value.
+               
+               @rtype: integer
+               """
+       def getDuration():
+               """
+               Return the duration parameter value
+               
+               @rtype: integer
+               """
+       def getRepeat():
+               """
+               Return the repeat parameter value
+               
+               @rtype: KX_TRUE or KX_FALSE
+               """
index 0ebc2debb314a8525b6e8de5f24dda3b2dd1fe25..33f0e976284c548afbb0783c69a78bde84ea3301 100644 (file)
@@ -77,4 +77,10 @@ class SCA_ISensor(SCA_ILogicBrick):
                @param level: Detect level instead of edge? (KX_TRUE, KX_FALSE)
                @type level: boolean
                """
+       def reset():
+               """
+               Reset sensor internal state, effect depends on the type of sensor and settings.
+               
+               The sensor is put in its initial state as if it was just activated.
+               """