com.alarexgroup.m2mplf.adapters.io
Class PulseAdapter

java.lang.Object
  extended by com.alarexgroup.m2mplf.adapters.io.PulseAdapter
All Implemented Interfaces:
ATCommanderListener
public class PulseAdapter
extends java.lang.Object
implements ATCommanderListener

Adapter works as reader of GPIO 10 pulses.
It's restrictions are described in device documentation.
Warning, it's not possible to use this at the same time with active PinAdapter and PortAdapter!!!

import com.alarexgroup.m2mplf.M2Mlet;
import com.alarexgroup.m2mplf.adapters.io.PulseAdapter;
import com.alarexgroup.m2mplf.adapters.io.PulseAdapterListener;
import com.alarexgroup.m2mplf.adapters.io.exceptions.PulseIOException;

public class MyFirstM2M extends M2Mlet implements 
public PulseAdapter pulseAdapter;
    
    
    public MyFirstM2M() {
    }
    
    
    public void appStart() {
        pulseAdapter = PulseAdapter.getPulseAdapter(this);
            pulseAdapter.createLimitPulseCounter(5);
        
        
    }
    
    public void onPulseCounterReached(long value) {
        //Called after 5 read impulses
    }
    
}

Field Summary
static int MODE_LIMIT_COUNTER
          Reader's mode - limited counter
static int MODE_START_STOP_COUNTER
          Reader's mode - start/stop counter
 
Constructor Summary
PulseAdapter()
           
 
Method Summary
 void callReadCurrentPulseCount()
          Read current status of the reader.
 void createLimitPulseCounter(long limit)
          Initializes reader in the mode of counting the impulses until given value.
 void createStartStopPulseCounter()
          Initializes the reader in start/stop mode.
 void destroyCounter()
          Terminates the reader's work, releases module's resources.
static PulseAdapter getPulseAdapter(PulseAdapterListener listener)
          Method initializes this adapter and returns refferece to it's instance
 void onURCEvent(java.lang.String urc)
          Internal method, please don't use
 void restartPulseCounter(long restartFromCount)
          Restart - continues reading from given value
 void startOrResetPulseCounter()
          Reset the reader's status.
 void stopPulseCounter()
          Stops the counting of the pulses.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MODE_LIMIT_COUNTER

public static final int MODE_LIMIT_COUNTER
Reader's mode - limited counter

See Also:
Constant Field Values

MODE_START_STOP_COUNTER

public static final int MODE_START_STOP_COUNTER
Reader's mode - start/stop counter

See Also:
Constant Field Values
Constructor Detail

PulseAdapter

public PulseAdapter()
Method Detail

getPulseAdapter

public static PulseAdapter getPulseAdapter(PulseAdapterListener listener)
Method initializes this adapter and returns refferece to it's instance

Parameters:
listener - Class implementing listener
Returns:
refference to adapter

createStartStopPulseCounter

public void createStartStopPulseCounter()
Initializes the reader in start/stop mode.
In this mode it's possible to repeatedly read current counter status, pause and run it from 0 or current value.
Processing of information about current impulse count is realized through PulseAdapterListener.onPulseCounterReached(long, int)

createLimitPulseCounter

public void createLimitPulseCounter(long limit)
Initializes reader in the mode of counting the impulses until given value.
If the given limit of pulses is reached, method PulseAdapterListener.onPulseCounterReached(long, int) is called. Returned value is time in which the limit was reached.

Parameters:
limit - - Number of impulses needed for calling the PulseAdapterListener.onPulseCounterReached(long, int) method

destroyCounter

public void destroyCounter()
Terminates the reader's work, releases module's resources. Then it's possible to work with PinAdapter and PortAdapter.
To run the reader again call method createStartStopPulseCounter(), createLimitPulseCounter(long)

startOrResetPulseCounter

public void startOrResetPulseCounter()
Reset the reader's status. Method is meant only for the start/stop mode, more: createStartStopPulseCounter()

restartPulseCounter

public void restartPulseCounter(long restartFromCount)
Restart - continues reading from given value

Parameters:
restartFromCount - New status of new counting

callReadCurrentPulseCount

public void callReadCurrentPulseCount()
Read current status of the reader. After calling this method method PulseAdapterListener.onPulseCounterReached(long, int) will be called automatically

stopPulseCounter

public void stopPulseCounter()
Stops the counting of the pulses. Method PulseAdapterListener.onPulseCounterReached(long, int) is called along with information about current pulse count.
It's possible to restart counting using the startOrResetPulseCounter() from 0 value or from last read value using restartPulseCounter(long)

onURCEvent

public void onURCEvent(java.lang.String urc)
Internal method, please don't use

Specified by:
onURCEvent in interface ATCommanderListener
Parameters:
urc - - URC string