Code Examples
A repository of 155 code examples for BeepBeep
nialm.DetectAppliance Class Reference

Static Public Member Functions

static void main (String[] args)
 

Detailed Description

Definition at line 32 of file DetectAppliance.java.

Member Function Documentation

◆ main()

static void nialm.DetectAppliance.main ( String []  args)
static

Step 2: send to a Moore machine

Definition at line 34 of file DetectAppliance.java.

35  {
36  ///
37  Fork f = new Fork(2);
38  // First branch: peak detection
39  Processor peak_finder = new PeakFinderLocalMaximum(5);
40  Connector.connect(f, 0, peak_finder, 0);
41  // Threshold to avoid finding peaks due to noise
42  Threshold peak_th = new Threshold(100);
43  Connector.connect(peak_finder, peak_th);
44  // Dampen to avoid double peaks
45  Processor peak_damper = new Limit(10);
46  Connector.connect(peak_th, peak_damper);
47 
48  // Second branch: plateau detection
49  Processor plateau_finder = new PlateauFinder()
50  .setPlateauRange(5).setRelative(true);
51  Connector.connect(f, 1, plateau_finder, 0);
52  // Threshold to avoid finding plateaus due to noise
53  Threshold plateau_th = new Threshold(100);
54  Connector.connect(plateau_finder, plateau_th);
55  Processor plateau_damper = new Limit(10);
56  Connector.connect(plateau_th, plateau_damper);
57  ///
58 
59  //! Step 2: send to a Moore machine
60  ApplianceMooreMachine amm =
61  new ApplianceMooreMachine(1000, 700, -700, 150);
62  Connector.connect(peak_damper, 0, amm, 0);
63  Connector.connect(plateau_damper, 0, amm, 1);
64 
65  // Connect input to a fake signal to see how it works
66  GenerateSignalNoise signal = new GenerateSignalNoise(10f,
67  new Object[] {0, 333, -150, 0, -175, 0},
68  new Object[] {70, 3, 2, 100, 4, 60});
69  Connector.connect(signal, 1, f, 0);
70 
71  // Connect the output and print at the console
72  ApplyFunction to_list = new ApplyFunction(
73  new Bags.ToList(Number.class, Number.class));
74  Connector.connect(signal, 0, to_list, 0);
75  Connector.connect(amm, 0, to_list, 1);
76  //!
77 
78  // Pull events
79  Pullable p = to_list.getPullableOutput();
80  while (p.hasNext())
81  {
82  System.out.println(p.pull());
83  }
84  }
Basic usage of the signal processing processors.
Definition: FakeSignal.java:18

The documentation for this class was generated from the following file: