This commit is contained in:
Norbert Wigbels 2025-02-08 16:53:10 +01:00
parent 72608437e0
commit 1e80fb3da1
342 changed files with 94580 additions and 0 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
3dprint/g_mp4_cover.amf Normal file

Binary file not shown.

BIN
3dprint/g_mp4_cover.stl Normal file

Binary file not shown.

1
README.1st Normal file
View file

@ -0,0 +1 @@
/* no comment */

Binary file not shown.

View file

@ -0,0 +1,19 @@
CodePlug f. AnyTone 878
reduziert auf
Stadt Stade mit Relais DB0XJ
https://www.repeaterbook.com/row_repeaters/details.php?state_id=DE&ID=2544
Channel:
2 DB0XJ - digitale Channel: Timeslot 1 & 2
2 DB0XJ - FM-Channel: Carrier & CTCSS-squelch
3 analoge Channel: APRS, Anruf 2m & 70cm
APRS-Setup f. Europa
eigene RadioID eintragen:
"Radio-ID List" ID und Rufzeichen eintragen
Im Bereich APRS entsprechend.
Im Bereich Optional-Setting/Power-on entsprechend.
73, DO7NJW, Norbert

Binary file not shown.

View file

@ -0,0 +1,190 @@
<?xml version="1.0" ?>
<stepconf>
<property name="ahomepos" type="int" value="0"/>
<property name="ahomesw" type="int" value="0"/>
<property name="ahomevel" type="float" value="0.05"/>
<property name="alatchdir" type="int" value="0"/>
<property name="aleadscrew" type="int" value="8"/>
<property name="amaxacc" type="int" value="1200"/>
<property name="amaxlim" type="int" value="9999"/>
<property name="amaxvel" type="int" value="360"/>
<property name="amicrostep" type="int" value="2"/>
<property name="aminlim" type="int" value="-9999"/>
<property name="apulleyden" type="int" value="1"/>
<property name="apulleynum" type="int" value="1"/>
<property name="ascale" type="int" value="0"/>
<property name="asteprev" type="int" value="200"/>
<property name="axes" type="int" value="0"/>
<property name="classicladder" type="bool" value="False"/>
<property name="createshortcut" type="bool" value="True"/>
<property name="createsymlink" type="bool" value="True"/>
<property name="customhal" type="int" value="1"/>
<property name="digitsin" type="float" value="15.0"/>
<property name="digitsout" type="float" value="15.0"/>
<property name="dirhold" type="float" value="3000.0"/>
<property name="dirsetup" type="float" value="3000.0"/>
<property name="drivertype" type="string" value="other"/>
<property name="floatsin" type="float" value="10.0"/>
<property name="floatsout" type="float" value="10.0"/>
<property name="halui" type="bool" value="True"/>
<property name="ioaddr" type="string" value="0x378"/>
<property name="ioaddr2" type="string" value="Enter Address"/>
<property name="ioaddr3" type="string" value="Enter Address"/>
<property name="ladderconnect" type="bool" value="True"/>
<property name="ladderhaltype" type="int" value="0"/>
<property name="laddername" type="string" value="custom.clp"/>
<property name="latency" type="float" value="35000.0"/>
<property name="machinename" type="string" value="3040t"/>
<property name="manualtoolchange" type="bool" value="True"/>
<property name="md5sums" type="eval" value="[]"/>
<property name="modbus" type="bool" value="False"/>
<property name="number_pports" type="int" value="1"/>
<property name="period" type="int" value="25000"/>
<property name="pin1" type="string" value="unused-output"/>
<property name="pin10" type="string" value="unused-input"/>
<property name="pin10inv" type="bool" value="False"/>
<property name="pin11" type="string" value="unused-input"/>
<property name="pin11inv" type="bool" value="False"/>
<property name="pin12" type="string" value="unused-input"/>
<property name="pin12inv" type="bool" value="False"/>
<property name="pin13" type="string" value="estop-ext"/>
<property name="pin13inv" type="bool" value="False"/>
<property name="pin14" type="string" value="unused-output"/>
<property name="pin14inv" type="bool" value="False"/>
<property name="pin15" type="string" value="unused-input"/>
<property name="pin15inv" type="bool" value="False"/>
<property name="pin16" type="string" value="unused-output"/>
<property name="pin16inv" type="bool" value="False"/>
<property name="pin17" type="string" value="unused-output"/>
<property name="pin17inv" type="bool" value="False"/>
<property name="pin1inv" type="bool" value="False"/>
<property name="pin2" type="string" value="xstep"/>
<property name="pin2inv" type="bool" value="False"/>
<property name="pin3" type="string" value="xdir"/>
<property name="pin3inv" type="bool" value="True"/>
<property name="pin4" type="string" value="ystep"/>
<property name="pin4inv" type="bool" value="False"/>
<property name="pin5" type="string" value="ydir"/>
<property name="pin5inv" type="bool" value="False"/>
<property name="pin6" type="string" value="zstep"/>
<property name="pin6inv" type="bool" value="False"/>
<property name="pin7" type="string" value="zdir"/>
<property name="pin7inv" type="bool" value="True"/>
<property name="pin8" type="string" value="unused-output"/>
<property name="pin8inv" type="bool" value="False"/>
<property name="pin9" type="string" value="unused-output"/>
<property name="pin9inv" type="bool" value="False"/>
<property name="pp2_direction" type="int" value="0"/>
<property name="pp2_pin1" type="string" value="unused-output"/>
<property name="pp2_pin10_in" type="string" value="unused-input"/>
<property name="pp2_pin10_in_inv" type="int" value="0"/>
<property name="pp2_pin11_in" type="string" value="unused-input"/>
<property name="pp2_pin11_in_inv" type="int" value="0"/>
<property name="pp2_pin12_in" type="string" value="unused-input"/>
<property name="pp2_pin12_in_inv" type="int" value="0"/>
<property name="pp2_pin13_in" type="string" value="unused-input"/>
<property name="pp2_pin13_in_inv" type="int" value="0"/>
<property name="pp2_pin14" type="string" value="unused-output"/>
<property name="pp2_pin14inv" type="int" value="0"/>
<property name="pp2_pin15_in" type="string" value="unused-input"/>
<property name="pp2_pin15_in_inv" type="int" value="0"/>
<property name="pp2_pin16" type="string" value="unused-output"/>
<property name="pp2_pin16inv" type="int" value="0"/>
<property name="pp2_pin17" type="string" value="unused-output"/>
<property name="pp2_pin17inv" type="int" value="0"/>
<property name="pp2_pin1inv" type="int" value="0"/>
<property name="pp2_pin2" type="string" value="unused-output"/>
<property name="pp2_pin2_in" type="string" value="unused-input"/>
<property name="pp2_pin2_in_inv" type="int" value="0"/>
<property name="pp2_pin2inv" type="int" value="0"/>
<property name="pp2_pin3" type="string" value="unused-output"/>
<property name="pp2_pin3_in" type="string" value="unused-input"/>
<property name="pp2_pin3_in_inv" type="int" value="0"/>
<property name="pp2_pin3inv" type="int" value="0"/>
<property name="pp2_pin4" type="string" value="unused-output"/>
<property name="pp2_pin4_in" type="string" value="unused-input"/>
<property name="pp2_pin4_in_inv" type="int" value="0"/>
<property name="pp2_pin4inv" type="int" value="0"/>
<property name="pp2_pin5" type="string" value="unused-output"/>
<property name="pp2_pin5_in" type="string" value="unused-input"/>
<property name="pp2_pin5_in_inv" type="int" value="0"/>
<property name="pp2_pin5inv" type="int" value="0"/>
<property name="pp2_pin6" type="string" value="unused-output"/>
<property name="pp2_pin6_in" type="string" value="unused-input"/>
<property name="pp2_pin6_in_inv" type="int" value="0"/>
<property name="pp2_pin6inv" type="int" value="0"/>
<property name="pp2_pin7" type="string" value="unused-output"/>
<property name="pp2_pin7_in" type="string" value="unused-input"/>
<property name="pp2_pin7_in_inv" type="int" value="0"/>
<property name="pp2_pin7inv" type="int" value="0"/>
<property name="pp2_pin8" type="string" value="unused-output"/>
<property name="pp2_pin8_in" type="string" value="unused-input"/>
<property name="pp2_pin8_in_inv" type="int" value="0"/>
<property name="pp2_pin8inv" type="int" value="0"/>
<property name="pp2_pin9" type="string" value="unused-output"/>
<property name="pp2_pin9_in" type="string" value="unused-input"/>
<property name="pp2_pin9_in_inv" type="int" value="0"/>
<property name="pp2_pin9inv" type="int" value="0"/>
<property name="pp3_direction" type="int" value="0"/>
<property name="pyvcp" type="bool" value="False"/>
<property name="pyvcpconnect" type="bool" value="True"/>
<property name="pyvcphaltype" type="int" value="0"/>
<property name="pyvcpname" type="string" value="custom.xml"/>
<property name="s32in" type="float" value="10.0"/>
<property name="s32out" type="float" value="10.0"/>
<property name="spindlecarrier" type="int" value="100"/>
<property name="spindlecpr" type="int" value="100"/>
<property name="spindlefiltergain" type="float" value="0.01"/>
<property name="spindlenearscale" type="float" value="1.5"/>
<property name="spindlepwm1" type="float" value="0.2"/>
<property name="spindlepwm2" type="float" value="0.8"/>
<property name="spindlespeed1" type="int" value="100"/>
<property name="spindlespeed2" type="int" value="800"/>
<property name="stepspace" type="float" value="10000.0"/>
<property name="steptime" type="float" value="10000.0"/>
<property name="tempexists" type="int" value="0"/>
<property name="units" type="int" value="1"/>
<property name="usespindleatspeed" type="bool" value="False"/>
<property name="xhomepos" type="float" value="0.0"/>
<property name="xhomesw" type="float" value="-5.5"/>
<property name="xhomevel" type="float" value="-5.0"/>
<property name="xlatchdir" type="int" value="0"/>
<property name="xleadscrew" type="float" value="3.962"/>
<property name="xmaxacc" type="float" value="200.0"/>
<property name="xmaxlim" type="float" value="279.0"/>
<property name="xmaxvel" type="float" value="33.3333333333"/>
<property name="xmicrostep" type="float" value="8.0"/>
<property name="xminlim" type="float" value="-5.0"/>
<property name="xpulleyden" type="float" value="1.0"/>
<property name="xpulleynum" type="float" value="1.0"/>
<property name="xscale" type="float" value="403.836446239"/>
<property name="xsteprev" type="float" value="200.0"/>
<property name="yhomepos" type="float" value="0.0"/>
<property name="yhomesw" type="float" value="-5.5"/>
<property name="yhomevel" type="float" value="-5.0"/>
<property name="ylatchdir" type="int" value="0"/>
<property name="yleadscrew" type="float" value="3.968"/>
<property name="ymaxacc" type="float" value="200.0"/>
<property name="ymaxlim" type="float" value="385.0"/>
<property name="ymaxvel" type="float" value="33.3333333333"/>
<property name="ymicrostep" type="float" value="8.0"/>
<property name="yminlim" type="float" value="-5.0"/>
<property name="ypulleyden" type="float" value="1.0"/>
<property name="ypulleynum" type="float" value="1.0"/>
<property name="yscale" type="float" value="403.225806452"/>
<property name="ysteprev" type="float" value="200.0"/>
<property name="zhomepos" type="float" value="0.0"/>
<property name="zhomesw" type="float" value="0.0"/>
<property name="zhomevel" type="float" value="0.05"/>
<property name="zlatchdir" type="int" value="0"/>
<property name="zleadscrew" type="float" value="4.0"/>
<property name="zmaxacc" type="float" value="150.0"/>
<property name="zmaxlim" type="float" value="40.0"/>
<property name="zmaxvel" type="float" value="11.0"/>
<property name="zmicrostep" type="float" value="8.0"/>
<property name="zminlim" type="float" value="-15.0"/>
<property name="zpulleyden" type="float" value="1.0"/>
<property name="zpulleynum" type="float" value="1.0"/>
<property name="zscale" type="float" value="400.0"/>
<property name="zsteprev" type="float" value="200.0"/>
</stepconf>

View file

@ -0,0 +1,24 @@
( test program to see if X axis loses position )
( msg, test 1 of X axis configuration )
G20 #1000=100 ( loop 100 times )
( this loop has delays after moves )
( tests acc and velocity settings )
o100 while [#1000]
G0 X1.000
G4 P0.250
G0 X0.500
G4 P0.250
#1000 = [#1000 - 1]
o100 endwhile
( msg, test 2 of X axis configuration S to continue)
M1 (stop here)
#1000=100 ( loop 100 times )
( the next loop has no delays after moves )
( tests direction hold times on driver config and also max accel setting )
o101 while [#1000]
G0 X1.000
G0 X0.500
#1000 = [#1000 - 1]
o101 endwhile
( msg, Done...X should be exactly .5" above table )
M2

View file

@ -0,0 +1,24 @@
( test program to see if Y axis loses position )
( msg, test 1 of Y axis configuration )
G20 #1000=100 ( loop 100 times )
( this loop has delays after moves )
( tests acc and velocity settings )
o100 while [#1000]
G0 Y1.000
G4 P0.250
G0 Y0.500
G4 P0.250
#1000 = [#1000 - 1]
o100 endwhile
( msg, test 2 of Y axis configuration S to continue)
M1 (stop here)
#1000=100 ( loop 100 times )
( the next loop has no delays after moves )
( tests direction hold times on driver config and also max accel setting )
o101 while [#1000]
G0 Y1.000
G0 Y0.500
#1000 = [#1000 - 1]
o101 endwhile
( msg, Done...Y should be exactly .5" above table )
M2

View file

@ -0,0 +1,27 @@
( test program to see if Z axis loses position )
( msg, test 1 of Z axis configuration )
G20 #1000=100 ( loop 100 times )
( this loop has delays after moves )
( tests acc and velocity settings )
o100 while [#1000]
G0 Z1.000
G4 P0.250
G0 Z0.500
G4 P0.250
#1000 = [#1000 - 1]
o100 endwhile
( msg, test 2 of Z axis configuration S to continue)
M1 (stop here)
#1000=100 ( loop 100 times )
( the next loop has no delays after moves )
( tests direction hold times on driver config and also max accel setting )
o101 while [#1000]
G0 Z1.000
G0 Z0.500
#1000 = [#1000 - 1]
o101 endwhile
( msg, Done...Z should be exactly .5" above table )
M2

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,131 @@
/*
* HotHotHeat
*
* Compile with the Arduino IDE (http://arduino.cc); is deployed against a
* Atmel Butterfly - so you also need the Butteruino project
* (http://code.google.com/p/butteruino/)
*
* ...will
* 1) Read the Butterfly temperature sensor and output
* the result permanently to UART.
*
* 2) Read a reed sensor and output
* the result permanently to UART
*
* Contact: Norbert Wigbels
* (http://foobla.wigbels.de/uber-foobla/)
*
* Format: <# of Sensor> <data>
* Example: 1 23.4 -- Temperature
* 2 HIGH -- Reed count
* 3 14 -- Total of Reed counts since start of programm
*/
#include <butterfly_temp.h>
#include <pins_butterfly.h>
#include <LCD_Driver.h>
#include <timer2_RTC.h>
int inputReed = PBPIN4;
int outputLED = PBPIN7;
int value = 0;
int debounce = 0;
int slewRate = LOW;
int everySecond = 0;
unsigned long gasReeds = 0;
int temp = 0;
void setup() {
// Identify butterfly running program...
LCD.prints_f( PSTR( "HOTHOTHEAT" ) );
delay( 1400 );
TempSense.overSample = true;
pinMode( inputReed, INPUT );
pinMode( outputLED, OUTPUT );
digitalWrite( outputLED, HIGH );
temp = TempSense.getTemp( CELSIUS );
Serial.begin( 9600 );
}
void logOutput()
{
LCD.print( gasReeds );
LCD.print( " G " );
LCD.print( temp );
LCD.println( " C" );
// Temperature
Serial.print( "1" );
Serial.print( "\t" );
Serial.println( temp );
// Reed HIGH or Low
Serial.print( "2" );
Serial.print( "\t" );
if( slewRate==1 ) {
Serial.println( "HIGH" );
} else {
Serial.println( "LOW" );
}
// Total of Gas Reeds
Serial.print( "3" );
Serial.print( "\t" );
Serial.println( gasReeds );
}
int getSamples() {
// Sensor 1 - Temperature
temp = TempSense.getTemp( CELSIUS );
// switchtime of reed is 18 ms including debouncing...
value = digitalRead( inputReed );
delay( 20 );
debounce = digitalRead( inputReed );
// Sensor 2 - Reedcontact
// ...we are just interested in falling levels
// __|----|count_here__|----|_count_here__
if ( value==debounce ) {
if ( value==HIGH ) {
slewRate=HIGH;
return HIGH;
}
else {
if( slewRate==HIGH ) {
slewRate=LOW;
gasReeds++;
}
return LOW;
}
}
}
void loop() {
// LED marks Butterfly working; dark to mark a reed contact
if( getSamples()==HIGH ) {
digitalWrite( outputLED, LOW );
} else {
digitalWrite( outputLED, HIGH );
}
if ( everySecond > 20 ) {
everySecond = 0;
logOutput();
} else {
everySecond++;
}
delay( 30 );
}

View file

@ -0,0 +1,21 @@
Java Coding Dojo Template
=========================
Minimalistic Java coding dojo template using Maven. This template has only one dependency on JUnit library thus
ideal for coding dojo where minimal setup is required.
# Pre-requisites
* [JDK 1.6+](http://www.oracle.com/technetwork/java/javase/downloads/index.html)
* [Apache Maven](http://maven.apache.org/)
# How to build
```
mvn clean test
```
# How to generate project site
```
mvn site:site
```

View file

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_6" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.10" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
</component>
</module>

View file

@ -0,0 +1,111 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>dojo</groupId>
<artifactId>java</artifactId>
<packaging>jar</packaging>
<version>0.1-SNAPSHOT</version>
<name>Dojo in Java</name>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<configuration>
<encoding>UTF-8</encoding>
<outputDirectory/>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<compilerVersion>1.6</compilerVersion>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
<configuration>
<forkMode>once</forkMode>
<includes>
<include>**/*Test.class</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- Testing -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
</dependencies>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.4</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.12</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.5.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>2.7.1</version>
<configuration>
<targetJdk>1.6</targetJdk>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.3</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.8.1</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jdepend-maven-plugin</artifactId>
<version>2.0-beta-2</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>2.4.0</version>
<configuration>
<threshold>High</threshold>
</configuration>
</plugin>
</plugins>
</reporting>
</project>

View file

@ -0,0 +1,37 @@
package dojo.java;
/**
* @author Norbert Wigbels (norbert@wigbels.de)
*/
public class BowlingGame {
private int[] rolls = new int[20 + 1];
private int currentRoll = 0;
public int calcScore() {
int score = 0;
int subFrame = 0;
for (int frame = 1; frame <= 10; frame++) {
if (rolls[subFrame] == 10) { // Frame with Strike
score += 10 + rolls[subFrame + 1] + rolls[subFrame + 2];
subFrame++;
} else if (rolls[subFrame] + rolls[subFrame + 1] == 10) { // Frame with Spare
score += 10 + rolls[subFrame + 2];
subFrame += 2;
} else { // normal Frame
score += rolls[subFrame] + rolls[subFrame + 1];
subFrame += 2;
}
}
return score;
}
public void roll(int pinsDown) {
rolls[currentRoll] = pinsDown;
currentRoll++;
}
}

View file

@ -0,0 +1,87 @@
package dojo.java;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* @author Norbert Wigbels (norbert@wigbels.de)
*/
public class BowlingGameTest {
BowlingGame bg;
@Before
public void setup() {
bg = new BowlingGame();
}
@Test
public void testAllZeros() {
rollForward(20, 0);
assertEquals(0, bg.calcScore());
}
@Test
public void testAllOnes() {
rollForward(20, 1);
assertEquals(20, bg.calcScore());
}
@Test
public void testAllStrikes() {
rollForward(12, 10);
assertEquals(300, bg.calcScore());
}
@Test
public void testOneSpare() {
rollForward(4, 0);
bg.roll(5); // roll, that is
bg.roll(5); //
bg.roll(3); /* bonus */
rollForward(13, 0);
assertEquals(16, bg.calcScore());
}
@Test
public void testOneStrike() {
rollForward(4, 0);
bg.roll(10); /* strike, that is */
bg.roll(3); // bonus
bg.roll(4); //
rollForward(12, 0);
assertEquals(24, bg.calcScore());
}
@Test
public void testSampleGame() {
bg.roll(1);
bg.roll(4);
bg.roll(4);
bg.roll(5);
bg.roll(6);
bg.roll(4);
bg.roll(5);
bg.roll(5);
bg.roll(10);
bg.roll(0);
bg.roll(1);
bg.roll(7);
bg.roll(3);
bg.roll(6);
bg.roll(4);
bg.roll(10);
bg.roll(2);
bg.roll(8);
bg.roll(6);
assertEquals(133, bg.calcScore());
}
private void rollForward(int rounds, int pins) {
for (int i = 0; i < rounds; i++) {
bg.roll(pins);
}
}
}

View file

@ -0,0 +1,21 @@
Java Coding Dojo Template
=========================
Minimalistic Java coding dojo template using Maven. This template has only one dependency on JUnit library thus
ideal for coding dojo where minimal setup is required.
# Pre-requisites
* [JDK 1.6+](http://www.oracle.com/technetwork/java/javase/downloads/index.html)
* [Apache Maven](http://maven.apache.org/)
# How to build
```
mvn clean test
```
# How to generate project site
```
mvn site:site
```

View file

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_6" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.10" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
</component>
</module>

View file

@ -0,0 +1,111 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>dojo</groupId>
<artifactId>java</artifactId>
<packaging>jar</packaging>
<version>0.1-SNAPSHOT</version>
<name>Dojo in Java</name>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<configuration>
<encoding>UTF-8</encoding>
<outputDirectory/>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<compilerVersion>1.6</compilerVersion>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
<configuration>
<forkMode>once</forkMode>
<includes>
<include>**/*Test.class</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- Testing -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
</dependencies>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.4</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.12</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.5.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>2.7.1</version>
<configuration>
<targetJdk>1.6</targetJdk>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.3</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.8.1</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jdepend-maven-plugin</artifactId>
<version>2.0-beta-2</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>2.4.0</version>
<configuration>
<threshold>High</threshold>
</configuration>
</plugin>
</plugins>
</reporting>
</project>

View file

@ -0,0 +1,19 @@
package dojo.java;
/**
* @author Norbert Wigbels (norbert@wigbels.de)
*/
public class FizzBuzz {
public String evaluate(int number) {
if ((number % 3) == 0 && (number % 5) == 0)
return "fizzbuzz";
if ((number % 3) == 0)
return "fizz";
if ((number % 5) == 0)
return "buzz";
else
return String.valueOf(number);
}
}

View file

@ -0,0 +1,17 @@
package dojo.java;
/**
* @author Norbert Wigbels (norbert@wigbels.de)
*/
public class Main {
public static final void main(String[] args) {
FizzBuzz fb = new FizzBuzz();
int i = 1;
while (i <= 15) {
System.out.println("For number " + i + " Fizzbuzz evaluates to " + fb.evaluate(i));
i++;
}
}
}

View file

@ -0,0 +1,61 @@
package dojo.java;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
/**
* @author Norbert Wigbels (norbert@wigbels.de)
*/
public class FizzBuzzTest {
FizzBuzz fb;
@Before
public void setup() {
fb = new FizzBuzz();
}
@Test
public void testWith1() {
assertEquals("1", fb.evaluate(1));
}
@Test
public void testWith2() {
assertEquals("2", fb.evaluate(2));
}
@Test
public void testWith3() {
assertEquals("fizz", fb.evaluate(3));
}
@Test
public void testWith4() {
assertEquals("4", fb.evaluate(4));
}
@Test
public void testWith5() {
assertEquals("buzz", fb.evaluate(5));
}
@Test
public void testWith6() {
assertEquals("fizz", fb.evaluate(6));
}
@Test
public void testWith10() {
assertEquals("buzz", fb.evaluate(10));
}
@Test
public void testWith15() {
assertEquals("fizzbuzz", fb.evaluate(15));
}
}

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,312 @@
# version
# Cleanflight/NAZE 1.9.0 May 31 2015 / 13:17:47 (98f7549)
# dump master
# mixer
mixer QUADX
# feature
feature -RX_PPM
feature -VBAT
feature -INFLIGHT_ACC_CAL
feature -RX_SERIAL
feature -MOTOR_STOP
feature -SERVO_TILT
feature -SOFTSERIAL
feature -GPS
feature -FAILSAFE
feature -SONAR
feature -TELEMETRY
feature -CURRENT_METER
feature -3D
feature -RX_PARALLEL_PWM
feature -RX_MSP
feature -RSSI_ADC
feature -LED_STRIP
feature -DISPLAY
feature -ONESHOT125
feature -BLACKBOX
feature VBAT
feature RX_SERIAL
feature FAILSAFE
# map
map AETR1234
# serial
serial 0 1 115200 57600 0 115200
serial 1 64 115200 57600 0 115200
# led
led 0 15,15:ES:IA:0
led 1 15,8:E:WF:0
led 2 15,7:E:WF:0
led 3 15,0:NE:IA:0
led 4 8,0:N:F:0
led 5 7,0:N:F:0
led 6 0,0:NW:IA:0
led 7 0,7:W:WF:0
led 8 0,8:W:WF:0
led 9 0,15:SW:IA:0
led 10 7,15:S:WF:0
led 11 8,15:S:WF:0
led 12 7,7:U:WF:0
led 13 8,7:U:WF:0
led 14 7,8:D:WF:0
led 15 8,8:D:WF:0
led 16 8,9::R:3
led 17 9,10::R:3
led 18 10,11::R:3
led 19 10,12::R:3
led 20 9,13::R:3
led 21 8,14::R:3
led 22 7,14::R:3
led 23 6,13::R:3
led 24 5,12::R:3
led 25 5,11::R:3
led 26 6,10::R:3
led 27 7,9::R:3
led 28 0,0:::0
led 29 0,0:::0
led 30 0,0:::0
led 31 0,0:::0
# color
color 0 0,0,0
color 1 0,255,255
color 2 0,0,255
color 3 30,0,255
color 4 60,0,255
color 5 90,0,255
color 6 120,0,255
color 7 150,0,255
color 8 180,0,255
color 9 210,0,255
color 10 240,0,255
color 11 270,0,255
color 12 300,0,255
color 13 330,0,255
color 14 0,0,0
color 15 0,0,0
set looptime = 3500
set emf_avoidance = 0
set mid_rc = 1500
set min_check = 1100
set max_check = 1900
set rssi_channel = 0
set rssi_scale = 30
set rssi_ppm_invert = 0
set input_filtering_mode = 0
set min_throttle = 1150
set max_throttle = 1950
set min_command = 1000
set servo_center_pulse = 1500
set 3d_deadband_low = 1406
set 3d_deadband_high = 1514
set 3d_neutral = 1460
set 3d_deadband_throttle = 50
set motor_pwm_rate = 400
set servo_pwm_rate = 50
set retarded_arm = 0
set disarm_kill_switch = 1
set auto_disarm_delay = 5
set small_angle = 25
set flaps_speed = 0
set fixedwing_althold_dir = 1
set reboot_character = 82
set gps_provider = 0
set gps_sbas_mode = 0
set gps_auto_config = 1
set gps_auto_baud = 0
set serialrx_provider = 5
set spektrum_sat_bind = 0
set telemetry_switch = 0
set telemetry_inversion = 0
set frsky_default_lattitude = 0.000
set frsky_default_longitude = 0.000
set frsky_coordinates_format = 0
set frsky_unit = 0
set frsky_vfas_precision = 0
set hott_alarm_sound_interval = 5
set battery_capacity = 0
set vbat_scale = 110
set vbat_max_cell_voltage = 42
set vbat_min_cell_voltage = 34
set vbat_warning_cell_voltage = 35
set current_meter_scale = 400
set current_meter_offset = 0
set multiwii_current_meter_output = 0
set current_meter_type = 1
set align_gyro = 0
set align_acc = 0
set align_mag = 0
set align_board_roll = 0
set align_board_pitch = 0
set align_board_yaw = 90
set max_angle_inclination = 500
set gyro_lpf = 42
set moron_threshold = 32
set gyro_cmpf_factor = 600
set gyro_cmpfm_factor = 250
set yaw_control_direction = 1
set pid_at_min_throttle = 1
set yaw_direction = 1
set yaw_jump_prevention_limit = 200
set tri_unarmed_servo = 1
set servo_lowpass_freq = 400
set servo_lowpass_enable = 0
set failsafe_delay = 10
set failsafe_off_delay = 200
set failsafe_throttle = 980
set rx_min_usec = 985
set rx_max_usec = 2115
set acc_hardware = 0
set mag_hardware = 0
set blackbox_rate_num = 1
set blackbox_rate_denom = 1
set blackbox_device = 0
# dump profile
# profile
profile 0
# aux
aux 0 0 1 1900 2100
aux 1 1 0 1875 2100
aux 2 2 0 900 1100
aux 3 0 0 900 900
aux 4 0 0 900 900
aux 5 0 0 900 900
aux 6 0 0 900 900
aux 7 0 0 900 900
aux 8 0 0 900 900
aux 9 0 0 900 900
aux 10 0 0 900 900
aux 11 0 0 900 900
aux 12 0 0 900 900
aux 13 0 0 900 900
aux 14 0 0 900 900
aux 15 0 0 900 900
aux 16 0 0 900 900
aux 17 0 0 900 900
aux 18 0 0 900 900
aux 19 0 0 900 900
# adjrange
adjrange 0 0 0 900 900 0 0
adjrange 1 0 0 900 900 0 0
adjrange 2 0 0 900 900 0 0
adjrange 3 0 0 900 900 0 0
adjrange 4 0 0 900 900 0 0
adjrange 5 0 0 900 900 0 0
adjrange 6 0 0 900 900 0 0
adjrange 7 0 0 900 900 0 0
adjrange 8 0 0 900 900 0 0
adjrange 9 0 0 900 900 0 0
adjrange 10 0 0 900 900 0 0
adjrange 11 0 0 900 900 0 0
# servo
servo 0 1020 2000 1500 30 -1
servo 1 1020 2000 1500 30 -1
servo 2 1020 2000 1500 100 -1
servo 3 1020 2000 1500 100 -1
servo 4 1020 2000 1500 100 -1
servo 5 1020 2000 1500 100 -1
servo 6 1020 2000 1500 100 -1
servo 7 1020 2000 1500 100 -1
servo 8 1020 2000 1500 100 -1
servo 9 1020 2000 1500 100 -1
set gps_pos_p = 15
set gps_pos_i = 0
set gps_pos_d = 0
set gps_posr_p = 34
set gps_posr_i = 14
set gps_posr_d = 53
set gps_nav_p = 25
set gps_nav_i = 33
set gps_nav_d = 83
set gps_wp_radius = 200
set nav_controls_heading = 1
set nav_speed_min = 100
set nav_speed_max = 300
set nav_slew_rate = 30
set alt_hold_deadband = 40
set alt_hold_fast_change = 1
set deadband = 4
set yaw_deadband = 4
set throttle_correction_value = 0
set throttle_correction_angle = 800
set default_rate_profile = 0
set gimbal_flags = 1
set acc_lpf_factor = 4
set accxy_deadband = 40
set accz_deadband = 40
set accz_lpf_cutoff = 5.000
set acc_unarmedcal = 1
set acc_trim_pitch = 0
set acc_trim_roll = 0
set baro_tab_size = 21
set baro_noise_lpf = 0.600
set baro_cf_vel = 0.985
set baro_cf_alt = 0.965
set mag_declination = 0
set pid_controller = 0
set p_pitch = 40
set i_pitch = 30
set d_pitch = 23
set p_roll = 40
set i_roll = 30
set d_roll = 23
set p_yaw = 85
set i_yaw = 45
set d_yaw = 0
set p_pitchf = 2.500
set i_pitchf = 0.600
set d_pitchf = 0.060
set p_rollf = 2.500
set i_rollf = 0.600
set d_rollf = 0.060
set p_yawf = 8.000
set i_yawf = 0.500
set d_yawf = 0.050
set level_horizon = 3.000
set level_angle = 5.000
set sensitivity_horizon = 75
set p_alt = 50
set i_alt = 0
set d_alt = 0
set p_level = 90
set i_level = 10
set d_level = 100
set p_vel = 120
set i_vel = 45
set d_vel = 1
set yaw_p_limit = 500
# dump rates
# rateprofile
rateprofile 0
set rc_rate = 120
set rc_expo = 30
set rc_yaw_expo = 0
set thr_mid = 50
set thr_expo = 0
set roll_rate = 18
set pitch_rate = 18
set yaw_rate = 110
set tpa_rate = 0
set tpa_breakpoint = 1500
#

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,7 @@
#!/usr/bin/env ruby
require 'rubygems'
require 'daemons'
mypath = File.expand_path(File.dirname(__FILE__))
Daemons.run("#{mypath}/hotcoldrain.rb")

View file

@ -0,0 +1,179 @@
#!/bin/bash
rrdtool graph web/temperatur_3stunden.png --title "Temperaturen 3h" --font TITLE:12 --vertical-label="° Celsius" -s 'now - 3 hour' -e 'now' \
DEF:temps1=weather.rrd:temps1:AVERAGE LINE2:temps1#204a87:"Temperatur unten" \
DEF:temps2=weather.rrd:temps2:AVERAGE LINE2:temps2#f57900:"Temperatur oben" \
DEF:temps9=weather.rrd:temps9:AVERAGE LINE2:temps9#4e9a06:"Temperatur aussen\n" \
DEF:temp1=../mqtttemp/mqtttemp.rrd:temp1:AVERAGE LINE2:temp1#6666ff:"Temperatur enklavE\n" \
GPRINT:temps1:LAST:"Letzte Messung unten\: %2.2lf" GPRINT:temps2:LAST:"oben\: %2.2lf" GPRINT:temps9:LAST:"aussen\: %2.2lf" GPRINT:temp1:LAST:"Letzte Messung enklavE\: %2.2lf"
rrdtool graph web/temperatur_6stunden.png --title "Temperaturen 6h" --font TITLE:12 --vertical-label="° Celsius" -s 'now - 6 hour' -e 'now' \
DEF:temps1=weather.rrd:temps1:AVERAGE LINE2:temps1#204a87:"Temperatur unten" \
DEF:temps2=weather.rrd:temps2:AVERAGE LINE2:temps2#f57900:"Temperatur oben" \
DEF:temps9=weather.rrd:temps9:AVERAGE LINE2:temps9#4e9a06:"Temperatur aussen\n" \
DEF:temp1=../mqtttemp/mqtttemp.rrd:temp1:AVERAGE LINE2:temp1#6666ff:"Temperatur enklavE\n" \
GPRINT:temps1:LAST:"Letzte Messung unten\: %2.2lf" GPRINT:temps2:LAST:"oben\: %2.2lf" GPRINT:temps9:LAST:"aussen\: %2.2lf" GPRINT:temp1:LAST:"Letzte Messung enklavE\: %2.2lf"
rrdtool graph web/temperatur_12stunden.png --title "Temperaturen 12h" --font TITLE:12 --vertical-label="° Celsius" -s 'now - 12 hour' -e 'now' \
DEF:temps1=weather.rrd:temps1:AVERAGE LINE2:temps1#204a87:"Temperatur unten" \
DEF:temps2=weather.rrd:temps2:AVERAGE LINE2:temps2#f57900:"Temperatur oben" \
DEF:temps9=weather.rrd:temps9:AVERAGE LINE2:temps9#4e9a06:"Temperatur aussen\n" \
DEF:temp1=../mqtttemp/mqtttemp.rrd:temp1:AVERAGE LINE2:temp1#6666ff:"Temperatur enklavE\n" \
GPRINT:temps1:LAST:"Letzte Messung unten\: %2.2lf" GPRINT:temps2:LAST:"oben\: %2.2lf" GPRINT:temps9:LAST:"aussen\: %2.2lf" GPRINT:temp1:LAST:"Letzte Messung enklavE\: %2.2lf"
rrdtool graph web/temperatur_1tag.png --title "Temperaturen 1 Tag" --font TITLE:12 --vertical-label="° Celsius" -s 'now - 1 day' -e 'now' \
DEF:temps1=weather.rrd:temps1:AVERAGE LINE2:temps1#204a87:"Temperatur unten" \
DEF:temps2=weather.rrd:temps2:AVERAGE LINE2:temps2#f57900:"Temperatur oben" \
DEF:temps9=weather.rrd:temps9:AVERAGE LINE2:temps9#4e9a06:"Temperatur aussen\n" \
DEF:temp1=../mqtttemp/mqtttemp.rrd:temp1:AVERAGE LINE2:temp1#6666ff:"Temperatur enklavE\n" \
GPRINT:temps1:LAST:"Letzte Messung unten\: %2.2lf" GPRINT:temps2:LAST:"oben\: %2.2lf" GPRINT:temps9:LAST:"aussen\: %2.2lf" GPRINT:temp1:LAST:"Letzte Messung enklavE\: %2.2lf"
rrdtool graph web/temperatur_1woche.png --title "Temperaturen im Wochenverlauf" --font TITLE:12 --vertical-label="° Celsius" -s 'now - 1 week' -e 'now' \
DEF:temps1=weather.rrd:temps1:AVERAGE LINE2:temps1#204a87:"Temperatur unten" \
DEF:temps2=weather.rrd:temps2:AVERAGE LINE2:temps2#f57900:"Temperatur oben" \
DEF:temp1=../mqtttemp/mqtttemp.rrd:temp1:AVERAGE LINE2:temp1#6666ff:"Temperatur enklavE" \
DEF:tempmins9=weather.rrd:temps9:MIN DEF:tempmaxs9=weather.rrd:temps9:MAX \
DEF:temps9=weather.rrd:temps9:AVERAGE CDEF:tempranges9=tempmaxs9,tempmins9,- LINE1:tempmins9#4e9a06 AREA:tempranges9#8ae234::STACK LINE1:tempmaxs9#4e9a06 LINE2:temps9#4e9a06:"Temperatur aussen\n"
rrdtool graph web/temperatur_1monat.png --title "Temperaturen im Monatsverlauf" --font TITLE:12 --vertical-label="° Celsius" -s 'now - 1 month' -e 'now' \
DEF:temps1=weather.rrd:temps1:AVERAGE LINE2:temps1#204a87:"Temperatur unten" \
DEF:temps2=weather.rrd:temps2:AVERAGE LINE2:temps2#f57900:"Temperatur oben" \
DEF:temp1=../mqtttemp/mqtttemp.rrd:temp1:AVERAGE LINE2:temp1#6666ff:"Temperatur enklavE" \
DEF:tempmins9=weather.rrd:temps9:MIN DEF:tempmaxs9=weather.rrd:temps9:MAX DEF:temps9=weather.rrd:temps9:AVERAGE CDEF:tempranges9=tempmaxs9,tempmins9,- LINE1:tempmins9#4e9a06 AREA:tempranges9#8ae234::STACK LINE1:tempmaxs9#4e9a06 LINE2:temps9#4e9a06:"Temperatur aussen\n"
rrdtool graph web/temperatur_1jahr.png --title "Temperaturen im Jahresverlauf" --font TITLE:12 --vertical-label="° Celsius" -s 'now - 1 year' -e 'now' \
DEF:temps1=weather.rrd:temps1:AVERAGE LINE2:temps1#204a87:"Temperatur unten" \
DEF:temps2=weather.rrd:temps2:AVERAGE LINE2:temps2#f57900:"Temperatur oben" \
DEF:temp1=../mqtttemp/mqtttemp.rrd:temp1:AVERAGE LINE2:temp1#6666ff:"Temperatur enklavE" \
DEF:tempmins9=weather.rrd:temps9:MIN DEF:tempmaxs9=weather.rrd:temps9:MAX DEF:temps9=weather.rrd:temps9:AVERAGE CDEF:tempranges9=tempmaxs9,tempmins9,- LINE1:tempmins9#4e9a06 AREA:tempranges9#8ae234::STACK LINE1:tempmaxs9#4e9a06 LINE2:temps9#4e9a06:"Temperatur aussen\n"
rrdtool graph web/temperatur_5jahr.png --title "Temperaturen im Jahresverlauf" --font TITLE:12 --vertical-label="° Celsius" -s 'now - 5 year' -e 'now' \
DEF:temps1=weather.rrd:temps1:AVERAGE LINE2:temps1#204a87:"Temperatur unten" \
DEF:temps2=weather.rrd:temps2:AVERAGE LINE2:temps2#f57900:"Temperatur oben" \
DEF:temp1=../mqtttemp/mqtttemp.rrd:temp1:AVERAGE LINE2:temp1#6666ff:"Temperatur enklavE" \
DEF:tempmins9=weather.rrd:temps9:MIN DEF:tempmaxs9=weather.rrd:temps9:MAX DEF:temps9=weather.rrd:temps9:AVERAGE CDEF:tempranges9=tempmaxs9,tempmins9,- LINE1:tempmins9#4e9a06 AREA:tempranges9#8ae234::STACK LINE1:tempmaxs9#4e9a06 LINE2:temps9#4e9a06:"Temperatur aussen\n"
rrdtool graph web/luftfeuchtigkeit_3stunden.png --title "Luftfeuchtigkeit 3h" --font TITLE:12 --vertical-label="%" -s 'now - 3 hour' -e 'now' \
DEF:hums1=weather.rrd:hums1:AVERAGE LINE2:hums1#204a87:"Luftfeuchtigkeit unten" \
DEF:hums2=weather.rrd:hums2:AVERAGE LINE2:hums2#f57900:"Luftfeuchtigkeit oben" \
DEF:hums9=weather.rrd:hums9:AVERAGE LINE2:hums9#4e9a06:"Luftfeuchtigkeit aussen\n" \
DEF:hum1=../mqtttemp/mqtttemp.rrd:hum1:AVERAGE LINE2:hum1#6666ff:"Luftfeuchtigkeit enklavE\n" \
GPRINT:hums1:LAST:"Letzte Messung unten\: %3.2lf" GPRINT:hums2:LAST:"oben\: %3.2lf" GPRINT:hums9:LAST:"aussen\: %3.2lf" GPRINT:hum1:LAST:"enklavE\: %3.2lf"
rrdtool graph web/luftfeuchtigkeit_6stunden.png --title "Luftfeuchtigkeit 6h" --font TITLE:12 --vertical-label="%" -s 'now - 6 hour' -e 'now' \
DEF:hums1=weather.rrd:hums1:AVERAGE LINE2:hums1#204a87:"Luftfeuchtigkeit unten" \
DEF:hums2=weather.rrd:hums2:AVERAGE LINE2:hums2#f57900:"Luftfeuchtigkeit oben" \
DEF:hums9=weather.rrd:hums9:AVERAGE LINE2:hums9#4e9a06:"Luftfeuchtigkeit aussen\n" \
DEF:hum1=../mqtttemp/mqtttemp.rrd:hum1:AVERAGE LINE2:hum1#6666ff:"Luftfeuchtigkeit enklavE\n" \
GPRINT:hums1:LAST:"Letzte Messung unten\: %3.2lf" GPRINT:hums2:LAST:"oben\: %3.2lf" GPRINT:hums9:LAST:"aussen\: %3.2lf" GPRINT:hum1:LAST:"enklavE\: %3.2lf"
rrdtool graph web/luftfeuchtigkeit_12stunden.png --title "Luftfeuchtigkeit 12h" --font TITLE:12 --vertical-label="%" -s 'now - 12 hour' -e 'now' \
DEF:hums1=weather.rrd:hums1:AVERAGE LINE2:hums1#204a87:"Luftfeuchtigkeit unten" \
DEF:hums2=weather.rrd:hums2:AVERAGE LINE2:hums2#f57900:"Luftfeuchtigkeit oben" \
DEF:hums9=weather.rrd:hums9:AVERAGE LINE2:hums9#4e9a06:"Luftfeuchtigkeit aussen\n" \
DEF:hum1=../mqtttemp/mqtttemp.rrd:hum1:AVERAGE LINE2:hum1#6666ff:"Luftfeuchtigkeit enklavE\n" \
GPRINT:hums1:LAST:"Letzte Messung unten\: %3.2lf" GPRINT:hums2:LAST:"oben\: %3.2lf" GPRINT:hums9:LAST:"aussen\: %3.2lf" GPRINT:hum1:LAST:"enklavE\: %3.2lf"
rrdtool graph web/luftfeuchtigkeit_1tag.png --title "Luftfeuchtigkeit im Tagesverlauf" --font TITLE:12 --vertical-label="%" -s 'now - 1 day' -e 'now' \
DEF:hums1=weather.rrd:hums1:AVERAGE LINE2:hums1#204a87:"Luftfeuchtigkeit unten" \
DEF:hums2=weather.rrd:hums2:AVERAGE LINE2:hums2#f57900:"Luftfeuchtigkeit oben" \
DEF:hums9=weather.rrd:hums9:AVERAGE LINE2:hums9#4e9a06:"Luftfeuchtigkeit aussen\n" \
DEF:hum1=../mqtttemp/mqtttemp.rrd:hum1:AVERAGE LINE2:hum1#6666ff:"Luftfeuchtigkeit enklavE\n" \
GPRINT:hums1:LAST:"Letzte Messung unten\: %3.2lf" GPRINT:hums2:LAST:"oben\: %3.2lf" GPRINT:hums9:LAST:"aussen\: %3.2lf" GPRINT:hum1:LAST:"enklavE\: %3.2lf"
rrdtool graph web/luftfeuchtigkeit_1woche.png --title "Luftfeuchtigkeit im Wochenverlauf" --font TITLE:12 --vertical-label="%" -s 'now - 1 week' -e 'now' \
DEF:hums1=weather.rrd:hums1:AVERAGE LINE2:hums1#204a87:"Luftfeuchtigkeit unten" \
DEF:hums2=weather.rrd:hums2:AVERAGE LINE2:hums2#f57900:"Luftfeuchtigkeit oben" \
DEF:hums9=weather.rrd:hums9:AVERAGE LINE2:hums9#4e9a06:"Luftfeuchtigkeit aussen\n" \
DEF:hum1=../mqtttemp/mqtttemp.rrd:hum1:AVERAGE LINE2:hum1#6666ff:"Luftfeuchtigkeit enklavE"
rrdtool graph web/luftfeuchtigkeit_1monat.png --title "Luftfeuchtigkeit im Monatsverlauf" --font TITLE:12 --vertical-label="%" -s 'now - 1 month' -e 'now' \
DEF:hums1=weather.rrd:hums1:AVERAGE LINE2:hums1#204a87:"Luftfeuchtigkeit unten" \
DEF:hums2=weather.rrd:hums2:AVERAGE LINE2:hums2#f57900:"Luftfeuchtigkeit oben" \
DEF:hums9=weather.rrd:hums9:AVERAGE LINE2:hums9#4e9a06:"Luftfeuchtigkeit aussen\n" \
DEF:hum1=../mqtttemp/mqtttemp.rrd:hum1:AVERAGE LINE2:hum1#6666ff:"Luftfeuchtigkeit enklavE"
rrdtool graph web/luftfeuchtigkeit_1jahr.png --title "Luftfeuchtigkeit im Jahresverlauf" --font TITLE:12 --vertical-label="%" -s 'now - 1 year' -e 'now' \
DEF:hums1=weather.rrd:hums1:AVERAGE LINE2:hums1#204a87:"Luftfeuchtigkeit unten" \
DEF:hums2=weather.rrd:hums2:AVERAGE LINE2:hums2#f57900:"Luftfeuchtigkeit oben" \
DEF:hums9=weather.rrd:hums9:AVERAGE LINE2:hums9#4e9a06:"Luftfeuchtigkeit aussen\n" \
DEF:hum1=../mqtttemp/mqtttemp.rrd:hum1:AVERAGE LINE2:hum1#6666ff:"Luftfeuchtigkeit enklavE"
rrdtool graph web/luftfeuchtigkeit_5jahr.png --title "Luftfeuchtigkeit im Jahresverlauf" --font TITLE:12 --vertical-label="%" -s 'now - 5 year' -e 'now' \
DEF:hums1=weather.rrd:hums1:AVERAGE LINE2:hums1#204a87:"Luftfeuchtigkeit unten" \
DEF:hums2=weather.rrd:hums2:AVERAGE LINE2:hums2#f57900:"Luftfeuchtigkeit oben" \
DEF:hums9=weather.rrd:hums9:AVERAGE LINE2:hums9#4e9a06:"Luftfeuchtigkeit aussen\n" \
DEF:hum1=../mqtttemp/mqtttemp.rrd:hum1:AVERAGE LINE2:hum1#6666ff:"Luftfeuchtigkeit enklavE"
rrdtool graph web/regen_1tag.png \
--title "Regen im Tagesverlauf" \
--font TITLE:12 \
-s 'now - 1 day' -e 'now' \
-v mm/Stunde \
DEF:rains9=weather.rrd:rains9:AVERAGE \
CDEF:rainph=rains9,3600,*,1,*,0.295,* \
CDEF:rainpd=rainph,24,* \
VDEF:totalrain=rainpd,AVERAGE \
GPRINT:totalrain:"Total %6.0lf mm/Tag" \
LINE2:rainph#729fcf
rrdtool graph web/regen_1woche.png \
--title "Regen im Wochenverlauf" \
--font TITLE:12 \
-s 'now - 1 week' -e 'now' \
-v mm/Stunde \
DEF:rains9=weather.rrd:rains9:AVERAGE \
CDEF:rainph=rains9,3600,*,1,*,0.295,* \
CDEF:rainpw=rainph,168,* \
VDEF:totalrain=rainpw,AVERAGE \
GPRINT:totalrain:"Total %6.0lf mm/Woche" \
LINE2:rainph#729fcf
rrdtool graph web/regen_1monat.png \
--title "Regen im Monatsverlauf" \
--font TITLE:12 \
-s 'now - 1 month' -e 'now' \
-v mm/Tag \
DEF:rains9=weather.rrd:rains9:AVERAGE \
CDEF:rainpd=rains9,3600,*,24,*,0.295,* \
CDEF:rainpm=rainpd,30,* \
VDEF:totalrain=rainpm,AVERAGE \
GPRINT:totalrain:"Total %6.0lf mm/Monat" \
LINE2:rainpd#729fcf
rrdtool graph web/regen_1jahr.png \
--title "Regen im Jahresverlauf" \
--font TITLE:12 \
-s 'now - 1 year' -e 'now' \
-v mm/Tag \
DEF:rains9=weather.rrd:rains9:AVERAGE \
CDEF:rainpd=rains9,3600,*,24,*,0.295,* \
CDEF:rainpm=rainpd,30,* \
VDEF:totalrain=rainpm,AVERAGE \
GPRINT:totalrain:"Total %6.0lf mm/Jahr" \
LINE2:rainpd#729fcf
rrdtool graph web/regen_5jahr.png \
--title "Regen im Jahresverlauf" \
--font TITLE:12 \
-s 'now - 5 year' -e 'now' \
-v mm/Tag \
DEF:rains9=weather.rrd:rains9:AVERAGE \
CDEF:rainpd=rains9,3600,*,24,*,0.295,* \
CDEF:rainpm=rainpd,30,* \
VDEF:totalrain=rainpm,AVERAGE \
GPRINT:totalrain:"Total %6.0lf mm/Jahr" \
LINE2:rainpd#729fcf
rrdtool graph web/wind_1tag.png --title "Wind im Tagesverlauf" --font TITLE:12 -s 'now - 1 day' -e 'now' -v km/h DEF:winds9=weather.rrd:winds9:AVERAGE LINE2:winds9#2e3436:"Wind km/h"
rrdtool graph web/wind_1woche.png --title "Wind im Wochenverlauf" --font TITLE:12 -s 'now - 1 week' -e 'now' -v km/h DEF:winds9=weather.rrd:winds9:AVERAGE LINE2:winds9#2e3436:"Wind km/h"
rrdtool graph web/wind_1monat.png --title "Wind im Monatsverlauf" --font TITLE:12 -s 'now - 1 month' -e 'now' -v km/h DEF:winds9=weather.rrd:winds9:AVERAGE LINE2:winds9#2e3436:"Wind km/h"
rrdtool graph web/wind_1jahr.png --title "Wind im Jahresverlauf" --font TITLE:12 -s 'now - 1 year' -e 'now' -v km/h DEF:winds9=weather.rrd:winds9:AVERAGE LINE2:winds9#2e3436:"Wind km/h"
rrdtool graph web/wind_5jahr.png --title "Wind im Jahresverlauf" --font TITLE:12 -s 'now - 5 year' -e 'now' -v km/h DEF:winds9=weather.rrd:winds9:AVERAGE LINE2:winds9#2e3436:"Wind km/h"

View file

@ -0,0 +1,88 @@
#!/usr/bin/env ruby
#
# Author: Norbert Wigbels - foobla.wigbels.de/uber-foobla
#
# HotColdRain continously reads output of USB-WDE1
# and pushes data to mosquitto-db
#
# todos:
#
#------------------------------------------
# Tainted mode 0-4
$SAFE=0
#------------------------------------------
require 'logger'
require 'serialport'
require 'mqtt'
#------------------------------------------
class HotColdRain < Logger::Application
attr_accessor :temp1, :humidity1, :serialport, :mypath
def initialize(application_name)
super(application_name)
@serialport = SerialPort.new("/dev/ttyUSB0", 9600, 8, 1, SerialPort::NONE)
@mypath = File.expand_path(File.dirname(__FILE__))
end
def logOutReadableData(datagrams)
puts "TemperaturUnten: " + datagrams[3]
puts "LuftfeuchtigkeitUnten: " + datagrams[11]
puts
puts "TemperaturOben: " + datagrams[4]
puts "LuftfeuchtigkeitOben: " + datagrams[12]
puts
puts "TemperaturAussen: " + datagrams[19]
puts "LuftfeuchtigkeitAussen: " + datagrams[20]
puts "Windgeschwindigkeit km/h: " + datagrams[21]
puts "Niederschlag: " + datagrams[22]
puts "Regen ja/nein: " + datagrams[23]
puts "---------------------"
end
def run
begin
while true do
openformat = @serialport.readline
#openformat = "$1;1;;21,3;20,0;;;;;;;50;55;;;;;;;4,9;74;3,0;6;0;0"
datagrams = openformat.split(';')
logOutReadableData(datagrams)
# $1;1;;21,3;20,0;;;;;;;50;55;;;;;;;4,9;74;3,0;6;0;0
# extract only data
# then replace empty data with U
# then localize float value
# finally prepare updatestring for rrdtool
datagrams = datagrams.values_at(3..23)
datagrams.collect! { |element| (element.empty?) ? "U" : element }
datagrams.collect! { |element| (element.include? ',') ? element.sub!(',','.') : element }
rrddata = 'N:'+datagrams.join(':')
system("rrdtool update #{mypath}/weather.rrd #{rrddata}")
# MQTT::Client.connect('mqtt://notwist:pixies@wigbels.net') do |c|
# c.publish('oben/temperatur', datagrams[0])
# end
end
@serialport.close
rescue => msg
log(ERROR, "error: #{msg}")
retry
ensure
@serialport.close
end
end
end
#------------------------------------------
status = HotColdRain.new("HotColdRain").start

View file

@ -0,0 +1,26 @@
rrdtool create weather.rrd --step 900 \
DS:temps1:GAUGE:1200:-40:50 \
DS:temps2:GAUGE:1200:-40:50 \
DS:temps3:GAUGE:1200:-40:50 \
DS:temps4:GAUGE:1200:-40:50 \
DS:temps5:GAUGE:1200:-40:50 \
DS:temps6:GAUGE:1200:-40:50 \
DS:temps7:GAUGE:1200:-40:50 \
DS:temps8:GAUGE:1200:-40:50 \
DS:hums1:GAUGE:1200:0:100 \
DS:hums2:GAUGE:1200:0:100 \
DS:hums3:GAUGE:1200:0:100 \
DS:hums4:GAUGE:1200:0:100 \
DS:hums5:GAUGE:1200:0:100 \
DS:hums6:GAUGE:1200:0:100 \
DS:hums7:GAUGE:1200:0:100 \
DS:hums8:GAUGE:1200:0:100 \
DS:temps9:GAUGE:1200:-40:50 \
DS:hums9:GAUGE:1200:0:100 \
DS:winds9:GAUGE:1200:0:200 \
DS:rains9:DERIVE:1200:0:U \
DS:israins9:GAUGE:1200:0:1 \
RRA:AVERAGE:0.5:1:960 \
RRA:MIN:0.5:96:3600 \
RRA:MAX:0.5:96:3600 \
RRA:AVERAGE:0.5:96:3600

View file

@ -0,0 +1,13 @@
@mypath = File.expand_path(File.dirname(__FILE__))
def foo
puts @mypath
end
bar = "16.9"
bar1 = "16"
bar = bar.gsub(".",",")
bar1 = bar1.gsub(".",",")
puts bar
puts bar1
foo

View file

@ -0,0 +1 @@
Woche/Monats/Jahresverlauefe Summen/Durchschnitte zeigen

View file

@ -0,0 +1,25 @@
<!DOCTYPE html>
<html>
<body>
<h2>Temperatur / Luftfeuchtigkeit</h2>
<img src="temperatur_3stunden.png"> <img src="luftfeuchtigkeit_3stunden.png"> <br />
<img src="temperatur_6stunden.png"> <img src="luftfeuchtigkeit_6stunden.png"> <br />
<img src="temperatur_12stunden.png"> <img src="luftfeuchtigkeit_12stunden.png"> <br />
<img src="temperatur_1tag.png"> <img src="luftfeuchtigkeit_1tag.png"> <br />
<img src="temperatur_1woche.png"> <img src="luftfeuchtigkeit_1woche.png"> <br />
<img src="temperatur_1monat.png"> <img src="luftfeuchtigkeit_1monat.png"> <br />
<img src="temperatur_1jahr.png"> <img src="luftfeuchtigkeit_1jahr.png"> <br />
<img src="temperatur_5jahr.png"> <img src="luftfeuchtigkeit_5jahr.png"> <br />
<h2>Regen / Wind</h2>
<img src="regen_1tag.png"> <img src="wind_1tag.png"> <br />
<img src="regen_1woche.png"> <img src="wind_1woche.png"> <br />
<img src="regen_1monat.png"> <img src="wind_1monat.png"> <br />
<img src="regen_1jahr.png"> <img src="wind_1jahr.png"> <br />
<img src="regen_5jahr.png"> <img src="wind_5jahr.png"> <br />
<p>Stationskoordinaten: 53&deg;34'17.1"N 9&deg;29'21.8"E, Stade-Ottenbeck</p>
</body>
</html>

Binary file not shown.

View file

@ -0,0 +1,7 @@
#!/usr/bin/env ruby
require 'rubygems'
require 'daemons'
mypath = File.expand_path(File.dirname(__FILE__))
Daemons.run("#{mypath}/hothotpiper.rb")

View file

@ -0,0 +1 @@
scp -P 2342 hothotread.rb root@192.168.14.7:/root/hothotread/hothotread.rb

View file

@ -0,0 +1,57 @@
#!/bin/bash
#DEF:temps9=../hotcoldrain/weather.rrd:temps9:AVERAGE \
#LINE1:temps9#4e9a06:"Temperatur aussen\n" \
rrdtool graph web/gas_1tag.png \
-w 800 -h 500 \
-s 'now - 1 day' -e 'now' \
--title "Gasverbrauch im Tagesverlauf" \
--font TITLE:12 --vertical-label="Liter/Stunde" \
DEF:gas=gas.rrd:gas:AVERAGE \
CDEF:gash=gas,120,* \
VDEF:gastotal=gas,TOTAL \
GPRINT:gastotal:"Total %6.0lf Liter Gas" \
LINE2:gash#c17d11:"Gasverbrauch"
rrdtool graph web/gas_1woche.png \
-w 800 -h 500 \
-s 'now - 1 week' -e 'now' \
--title "Gasverbrauch im Wochenverlauf" \
--font TITLE:12 --vertical-label="Liter/Tag" \
DEF:gas=gas.rrd:gas:AVERAGE \
CDEF:gasd=gas,2880,* \
VDEF:gastotal=gas,TOTAL \
GPRINT:gastotal:"Total %6.0lf Liter Gas" \
LINE2:gasd#c17d11:"Gasverbrauch/Tag"
rrdtool graph web/gas_1monat.png \
-w 800 -h 500 \
-s 'now - 1 month' -e 'now' \
--title "Gasverbrauch im Monatsverlauf" \
--font TITLE:12 --vertical-label="Liter/Tag" \
DEF:gas=gas.rrd:gas:AVERAGE \
CDEF:gasd=gas,2880,* \
VDEF:gastotal=gas,TOTAL \
GPRINT:gastotal:"Total %6.0lf Liter Gas" \
LINE2:gasd#c17d11:"Gasverbrauch/Tag"
rrdtool graph web/gas_1jahr.png \
-w 800 -h 500 \
-s 'now - 1 year' -e 'now' \
--title "Gasverbrauch im Jahresverlauf" \
--font TITLE:12 --vertical-label="Liter/Tag" \
DEF:gas=gas.rrd:gas:AVERAGE \
CDEF:gasd=gas,2880,* \
VDEF:gastotal=gas,TOTAL \
GPRINT:gastotal:"Total %6.0lf Liter Gas" \
LINE2:gasd#c17d11:"Gasverbrauch/Tag"
rrdtool graph web/consum_1day.png -s 'now -1 day' -e 'now' -Y -A DEF:consum=power.rrd:consum:AVERAGE LINE2:consum#00FF00:"Verbrauch [W]"
rrdtool graph web/consum_1week.png -s 'now -1 week' -e 'now' -Y -A DEF:consum=power.rrd:consum:AVERAGE LINE2:consum#00FF00:"Verbrauch [W]"
rrdtool graph web/consum_1month.png -s 'now -1 month' -e 'now' -Y -A DEF:consum=power.rrd:consum:AVERAGE LINE2:consum#00FF00:"Verbrauch [W]"
rrdtool graph web/consum_1year.png -s 'now -1 year' -e 'now' -Y -A DEF:consum=power.rrd:consum:AVERAGE LINE2:consum#00FF00:"Verbrauch [W]"
rrdtool graph web/counter_1week.png -s 'now -1 week' -e 'now' -X 0 -Y -A DEF:counter=power.rrd:counter:LAST LINE2:counter#000000:"Zählerstand [kWh]"
rrdtool graph web/counter_1month.png -s 'now -1 month' -e 'now' -X 0 -Y -A DEF:counter=power.rrd:counter:LAST LINE2:counter#000000:"Zählerstand [kWh]"

Binary file not shown.

View file

@ -0,0 +1,56 @@
#!/usr/bin/env ruby
#
# Author: Norbert Wigbels - foobla.wigbels.de/uber-foobla
#
# HotHotPiper continously reads the status of a
# reed contact attached to the Raspberry Pi GPIO
#
# The reed measures gas usage.
#
# A magig URL is formed and called; the url
# stores the sensor-data to wigbels.net
#
# todo: status-led
#
#------------------------------------------
# Tainted mode 0-4
$SAFE=0
#------------------------------------------
require 'pi_piper'
include PiPiper
$mypath = File.expand_path(File.dirname(__FILE__))
def last_rrd_count
val = 0.0
handle = IO.popen("rrdtool lastupdate #{$mypath}/power.rrd")
handle.each_line do |line|
m = line.match("^[0-9]*: ([0-9.]*) [0-9.]*")
if m
val = m[1].to_f
break
end
end
return val
end
watch :pin => 4, :trigger => :falling do
puts('added 10 liter of gas to sensor-database')
system("rrdtool update #{$mypath}/gas.rrd N:10")
end
watch :pin => 11, :trigger => :falling do
puts('updated power consumption')
$counter = $counter + $trigger_step
trigger_update = $trigger_step * 3600000.0
system("rrdtool update #{$mypath}/power.rrd N:#{$counter}:#{trigger_update}")
end
$trigger_step = 1.0 / 96
$counter = last_rrd_count
PiPiper.wait

View file

@ -0,0 +1,42 @@
#!/usr/bin/env ruby
require 'pi_piper'
include PiPiper
mypath = File.expand_path(File.dirname(__FILE__))
trigger_step = 0.01
trigger_watch = 0
counter = 0
timestamp = Time.now.to_i
def last_rrd_count(concretepath)
val = 0.0
handle = IO.popen("rrdtool lastupdate #{concretepath}")
handle.each_line do |line|
m = line.match("^[0-9]*: ([0-9.]*) [0-9.]*")
if m
val = m[1].to_f
break
end
end
return val
end
watch :pin => 4, :trigger => :falling do
puts('added 10 liter of gas to sensor-database')
system("rrdtool update #{mypath}/gas.rrd N:10")
end
rrdpath = mypath + "/gasneu.rrd"
counter = last_rrd_count(rrdpath)
#loop do
# if trigger_watch == 1 then
# puts('trigger 1 detected')
# trigger_watch = 0
# else
# puts('trigger 0 detected')
# end
# sleep(1)
#end
PiPiper.wait

View file

@ -0,0 +1,79 @@
#!/usr/bin/env ruby
#
# Author: Norbert Wigbels - foobla.wigbels.de/uber-foobla
#
# HotHotRead continously reads the status of a
# reed contact attached to the avr-net-io
#
# The reed measures gas usage.
#
# A magig URL is formed and called; the url
# stores the sensor-data to wigbels.net
#
# todo: status-led
#
#------------------------------------------
# Tainted mode 0-4
$SAFE=0
#------------------------------------------
require 'logger'
require 'socket'
require 'net/http'
#------------------------------------------
class HotHotRead < Logger::Application
attr_accessor :socket, :socketaddr
def initialize(application_name)
super(application_name)
@socket = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
@sockaddr = Socket.sockaddr_in(2701, '192.168.14.42')
end
def run
begin
@socket.connect(@sockaddr)
high2low = false;
while true do
@socket.print "io get pin 0\r\n"
rawdata = @socket.recvfrom(128)
# data contains "port 0: 0xfe"; extract last part
data = rawdata.to_s.split(" ")[2]
# we are only interested in the changes from high to low of the reed sensor
if (data=="0xff")
high2low = true
else
if (high2low==true)
high2low = false
Net::HTTP.get(URI.parse('http://www.wigbels.net/cgi-bin/hhw.rb?sensorid=1&data=10'))
# fixme: response.body auswerten
# bei fehler, lokales backlog schreibe
log(INFO, 'added 100 liter of gas to sensor-database')
end
end
sleep(0.2)
end
# and terminate the connection when we're done
rescue => msg
log(ERROR, "error: #{msg}")
retry
ensure
@socket.close
end
#puts "Filename: "+__FILE__.to_s
#puts "Linenumber: "+__LINE__.to_s
#log(WARN, 'warning', 'mymethod' )
#@log.error('my_method2') { 'Error!' }
end
end
#------------------------------------------
status = HotHotRead.new("HotHotRead").start
#if status != 0
# puts "Some error occured."
#end

View file

@ -0,0 +1,14 @@
def last_rrd_count
val = 0.0
handle = IO.popen("rrdtool lastupdate power.rrd")
handle.each_line do |line|
m = line.match("^[0-9]*: ([0-9.]*) [0-9.]*")
if m
val = m[1].to_f
break
end
end
return val
end
puts last_rrd_count

View file

@ -0,0 +1,16 @@
require 'socket'
s = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
sockaddr = Socket.sockaddr_in(2701, '192.168.14.42')
begin
s.connect(sockaddr)
rescue
puts "error: #{$!}"
else
s.print "version\r\n"
data = s.recvfrom(1024)
puts data
# and terminate the connection when we're done
s.close
end

View file

@ -0,0 +1,19 @@
require 'pi_piper'
include PiPiper
trigger_watch = 0
watch :pin => 11, :trigger => :falling do
puts('trigger registered')
trigger_watch = 1
end
loop do
if trigger_watch == 1 then
puts('trigger 1 detected')
trigger_watch = 0
else
puts('trigger 0 detected')
end
sleep(5)
end

View file

@ -0,0 +1,4 @@
http://www.blackberryforums.com/developer-forum/2730-persistant-tcp-connection.html
nested retry
restart

View file

@ -0,0 +1,7 @@
#!/usr/bin/env ruby
require 'rubygems'
require 'daemons'
mypath = File.expand_path(File.dirname(__FILE__))
Daemons.run("#{mypath}/hothotpiper_gas.rb")

View file

@ -0,0 +1,7 @@
#!/usr/bin/env ruby
require 'rubygems'
require 'daemons'
mypath = File.expand_path(File.dirname(__FILE__))
Daemons.run("#{mypath}/hothotpiper_power.rb")

View file

@ -0,0 +1,7 @@
#!/usr/bin/env ruby
require 'rubygems'
require 'daemons'
mypath = File.expand_path(File.dirname(__FILE__))
Daemons.run("#{mypath}/hothotpiper_water.rb")

View file

@ -0,0 +1,45 @@
#!/bin/bash
rrdtool graph web/gas_3hour.png -s 'now - 3 hour' -e 'now' DEF:consum=gasneu.rrd:consum:AVERAGE CDEF:conph=consum,3600,* CDEF:conpd=conph,24,* VDEF:gastotal=conpd,AVERAGE GPRINT:gastotal:"Total %4.2lf m³/d" LINE2:conph#c17d11:m³/h
rrdtool graph web/gas_6hour.png -s 'now - 6 hour' -e 'now' DEF:consum=gasneu.rrd:consum:AVERAGE CDEF:conph=consum,3600,* CDEF:conpd=conph,24,* VDEF:gastotal=conpd,AVERAGE GPRINT:gastotal:"Total %4.2lf m³/d" LINE2:conph#c17d11:m³/h
rrdtool graph web/gas_12hour.png -s 'now - 12 hour' -e 'now' DEF:consum=gasneu.rrd:consum:AVERAGE CDEF:conph=consum,3600,* CDEF:conpd=conph,24,* VDEF:gastotal=conpd,AVERAGE GPRINT:gastotal:"Total %4.2lf m³/d" LINE2:conph#c17d11:m³/h
rrdtool graph web/gas_1tag.png -s 'now - 1 day' -e 'now' DEF:consum=gasneu.rrd:consum:AVERAGE CDEF:conph=consum,3600,* CDEF:conpd=conph,24,* VDEF:gastotal=conpd,AVERAGE GPRINT:gastotal:"Total %4.2lf m³/d" LINE2:conph#c17d11:m³/h
rrdtool graph web/gas_1week.png -s 'now - 1 week' -e 'now' DEF:consum=gasneu.rrd:consum:AVERAGE CDEF:conpd=consum,3600,*,24,* LINE2:conpd#c17d11:m³/h
rrdtool graph web/gas_1month.png -s 'now - 1 month' -e 'now' DEF:consum=gasneu.rrd:consum:AVERAGE CDEF:conpd=consum,3600,*,24,* LINE2:conpd#c17d11:m³/h
rrdtool graph web/gas_1year.png -s 'now - 1 year' -e 'now' DEF:consum=gasneu.rrd:consum:AVERAGE CDEF:conpm=consum,3600,*,24,*,30,* LINE2:conpm#c17d11:m³/h
rrdtool graph web/gas_2year.png -s 'now - 2 year' -e 'now' DEF:consum=gasneu.rrd:consum:AVERAGE CDEF:conpm=consum,3600,*,24,*,30,* LINE2:conpm#c17d11:m³/h
rrdtool graph web/gascounter_1week.png -s 'now -1 week' -e 'now' -X 0 -Y -A DEF:counter=gasneu.rrd:counter:LAST LINE2:counter#000000:"Zählerstand [m³]"
rrdtool graph web/gascounter_1month.png -s 'now -1 month' -e 'now' -X 0 -Y -A DEF:counter=gasneu.rrd:counter:LAST LINE2:counter#000000:"Zählerstand [m³]"
rrdtool graph web/consum_10minutes.png -s 'now -10 minutes' -e 'now' -Y -A DEF:consum=power.rrd:consum:AVERAGE LINE2:consum#00FF00:"Verbrauch [W]"
rrdtool graph web/consum_30minutes.png -s 'now -30 minutes' -e 'now' -Y -A DEF:consum=power.rrd:consum:AVERAGE LINE2:consum#00FF00:"Verbrauch [W]"
rrdtool graph web/consum_1hour.png -s 'now -1 hour' -e 'now' -Y -A DEF:consum=power.rrd:consum:AVERAGE LINE2:consum#00FF00:"Verbrauch[W]"
rrdtool graph web/consum_3hour.png -s 'now -3 hour' -e 'now' -Y -A DEF:consum=power.rrd:consum:AVERAGE LINE2:consum#00FF00:"Verbrauch [W]"
rrdtool graph web/consum_6hour.png -s 'now -6 hour' -e 'now' -Y -A DEF:consum=power.rrd:consum:AVERAGE LINE2:consum#00FF00:"Verbrauch [W]"
rrdtool graph web/consum_12hour.png -s 'now -12 hour' -e 'now' -Y -A DEF:consum=power.rrd:consum:AVERAGE LINE2:consum#00FF00:"Verbrauch [W]"
rrdtool graph web/consum_1day.png -s 'now -1 day' -e 'now' -Y -A DEF:consum=power.rrd:consum:AVERAGE LINE2:consum#00FF00:"Verbrauch [W]"
rrdtool graph web/consum_1week.png -s 'now -1 week' -e 'now' -Y -A DEF:consum=power.rrd:consum:AVERAGE LINE2:consum#00FF00:"Verbrauch [W]"
rrdtool graph web/consum_1month.png -s 'now -1 month' -e 'now' -Y -A DEF:consum=power.rrd:consum:AVERAGE LINE2:consum#00FF00:"Verbrauch [W]"
rrdtool graph web/consum_1year.png -s 'now -1 year' -e 'now' -Y -A DEF:consum=power.rrd:consum:AVERAGE LINE2:consum#00FF00:"Verbrauch [W]"
rrdtool graph web/consum_2year.png -s 'now -2 year' -e 'now' -Y -A DEF:consum=power.rrd:consum:AVERAGE LINE2:consum#00FF00:"Verbrauch [W]"
rrdtool graph web/counter_1week.png -s 'now -1 week' -e 'now' -X 0 -Y -A DEF:counter=power.rrd:counter:LAST LINE2:counter#000000:"Zählerstand [kWh]"
rrdtool graph web/counter_1month.png -s 'now -1 month' -e 'now' -X 0 -Y -A DEF:counter=power.rrd:counter:LAST LINE2:counter#000000:"Zählerstand [kWh]"
rrdtool graph web/wconsum_10minutes.png -s 'now -10 minutes' -e 'now' -Y -A DEF:consum=water.rrd:consum:AVERAGE CDEF:wconsum=consum,3,/ LINE2:wconsum#0066ff:"Verbrauch [L]"
rrdtool graph web/wconsum_30minutes.png -s 'now -30 minutes' -e 'now' -Y -A DEF:consum=water.rrd:consum:AVERAGE CDEF:wconsum=consum,3,/ LINE2:wconsum#0066ff:"Verbrauch [L]"
rrdtool graph web/wconsum_1hour.png -s 'now -1 hour' -e 'now' -Y -A DEF:consum=water.rrd:consum:AVERAGE CDEF:wconsum=consum,3,/ LINE2:wconsum#0066ff:"Verbrauch[L]"
rrdtool graph web/wconsum_3hour.png -s 'now -3 hour' -e 'now' -Y -A DEF:consum=water.rrd:consum:AVERAGE CDEF:wconsum=consum,3,/ LINE2:wconsum#0066ff:"Verbrauch [L]"
rrdtool graph web/wconsum_6hour.png -s 'now -6 hour' -e 'now' -Y -A DEF:consum=water.rrd:consum:AVERAGE CDEF:wconsum=consum,3,/ LINE2:wconsum#0066ff:"Verbrauch [L]"
rrdtool graph web/wconsum_12hour.png -s 'now -12 hour' -e 'now' -Y -A DEF:consum=water.rrd:consum:AVERAGE CDEF:wconsum=consum,3,/ LINE2:wconsum#0066ff:"Verbrauch [L]"
rrdtool graph web/wconsum_1day.png -s 'now -1 day' -e 'now' -Y -A DEF:consum=water.rrd:consum:AVERAGE CDEF:wconsum=consum,3,/ LINE2:wconsum#0066ff:"Verbrauch [L]"
rrdtool graph web/wconsum_1week.png -s 'now -1 week' -e 'now' -Y -A DEF:consum=water.rrd:consum:AVERAGE CDEF:wconsum=consum,3,/ LINE2:wconsum#0066ff:"Verbrauch [L]"
rrdtool graph web/wconsum_1month.png -s 'now -1 month' -e 'now' -Y -A DEF:consum=water.rrd:consum:AVERAGE CDEF:wconsum=consum,3,/ LINE2:wconsum#0066ff:"Verbrauch [L]"
rrdtool graph web/wconsum_1year.png -s 'now -1 year' -e 'now' -Y -A DEF:consum=water.rrd:consum:AVERAGE CDEF:wconsum=consum,3,/ LINE2:wconsum#0066ff:"Verbrauch [L]"
rrdtool graph web/wconsum_2year.png -s 'now -2 year' -e 'now' -Y -A DEF:consum=water.rrd:consum:AVERAGE CDEF:wconsum=consum,3,/ LINE2:wconsum#0066ff:"Verbrauch [L]"
rrdtool graph web/wcounter_1week.png -s 'now -1 week' -e 'now' -X 0 -Y -A DEF:counter=water.rrd:counter:LAST CDEF:wcounter=counter,3,/ LINE2:wcounter#000000:"Zählerstand [qm2]"
rrdtool graph web/wcounter_1month.png -s 'now -1 month' -e 'now' -X 0 -Y -A DEF:counter=water.rrd:counter:LAST CDEF:wcounter=counter,3,/ LINE2:wcounter#000000:"Zählerstand [qm2]"

File diff suppressed because it is too large Load diff

Binary file not shown.

View file

@ -0,0 +1,53 @@
#!/usr/bin/env ruby
require 'pi_piper'
require 'eventmachine'
include PiPiper
mypath = File.expand_path(File.dirname(__FILE__))
trigger_step = 0.01
trigger_watch = 0
counter = 0.0
timestamp = Time.now.to_i
def last_rrd_count(concretepath)
val = 0.0
handle = IO.popen("rrdtool lastupdate #{concretepath}")
handle.each_line do |line|
m = line.match("^[0-9]*: ([0-9.]*) [0-9.]*")
if m
val = m[1].to_f
break
end
end
return val
end
watch :pin => 4, :trigger => :rising, :pull => :up do
puts('triggered watch to 1')
trigger_watch = 1
end
rrdpath = mypath + "/gasneu.rrd"
counter = last_rrd_count(rrdpath)
puts('Counter restored to: ' + counter.to_s)
#PiPiper::Pin.new(:pin => 4, :direction => :in)
EventMachine.run do
EM.add_periodic_timer(1) do
if trigger_watch == 1 then
counter = counter + trigger_step
system("rrdtool update #{rrdpath} N:#{counter}:#{trigger_step}")
puts('Counter updated to: ' + counter.to_s)
timestamp = Time.now.to_i
trigger_watch = 0
elsif Time.now.to_i - timestamp > 3600
system("rrdtool update #{rrdpath} N:#{counter}:0")
timestamp = Time.now.to_i
end
end
end

View file

@ -0,0 +1,47 @@
require 'pi_piper'
require 'eventmachine'
include PiPiper
mypath = File.expand_path(File.dirname(__FILE__))
trigger_step = 1.0 / 96
trigger_watch = 0
counter = 0
def last_rrd_count(concretepath)
val = 0.0
handle = IO.popen("rrdtool lastupdate #{concretepath}")
handle.each_line do |line|
m = line.match("^[0-9]*: ([0-9.]*) [0-9.]*")
if m
val = m[1].to_f
break
end
end
return val
end
watch :pin => 11, :trigger => :falling do
puts('updated power consumption')
trigger_watch = 1
end
rrdpath = mypath + "/power.rrd"
counter = last_rrd_count(rrdpath)
puts('Counter restored to: ' + counter.to_s)
EventMachine.run do
EM.add_periodic_timer(1) do
if trigger_watch == 1 then
counter = counter + trigger_step
trigger_update = trigger_step * 3600000.0
system("rrdtool update #{rrdpath} N:#{counter}:#{trigger_update}")
puts('Counter updated to: ' + counter.to_s)
trigger_watch = 0
end
end
end

View file

@ -0,0 +1,52 @@
#!/usr/bin/env ruby
require 'pi_piper'
require 'eventmachine'
include PiPiper
mypath = File.expand_path(File.dirname(__FILE__))
trigger_step = 1
trigger_watch = 0
counter = 0.0
timestamp = Time.now.to_i
def last_rrd_count(concretepath)
val = 0.0
handle = IO.popen("rrdtool lastupdate #{concretepath}")
handle.each_line do |line|
m = line.match("^[0-9]*: ([0-9.]*) [0-9.]*")
if m
val = m[1].to_f
break
end
end
return val
end
watch :pin => 18, :trigger => :falling do
puts('triggered watch to 1')
trigger_watch = 1
end
rrdpath = mypath + "/water.rrd"
#counter = last_rrd_count(rrdpath)
puts('Counter restored to: ' + counter.to_s)
EventMachine.run do
EM.add_periodic_timer(1) do
if trigger_watch == 1 then
counter = counter + trigger_step
system("rrdtool update #{rrdpath} N:#{counter}:#{trigger_step}")
puts('Counter updated to: ' + counter.to_s)
timestamp = Time.now.to_i
trigger_watch = 0
elsif Time.now.to_i - timestamp > 3600
system("rrdtool update #{rrdpath} N:#{counter}:0")
timestamp = Time.now.to_i
end
end
end

View file

@ -0,0 +1,10 @@
rrdtool create power.rrd --step 60 --no-overwrite \
DS:counter:GAUGE:86400:0:1000000 \
DS:consum:ABSOLUTE:86400:0:1000000 \
RRA:LAST:0.5:1:4320 \
RRA:AVERAGE:0.5:1:4320 \
RRA:LAST:0.5:1440:30 \
RRA:AVERAGE:0.5:1440:30 \
RRA:LAST:0.5:10080:520 \
RRA:AVERAGE:0.5:10080:520

View file

@ -0,0 +1 @@
rrdtool create gasneu.rrd --step 60 --no-overwrite DS:counter:GAUGE:86400:0:100000 DS:consum:ABSOLUTE:86400:0:1 RRA:LAST:0.5:1:4320 RRA:AVERAGE:0.5:1:4320 RRA:LAST:0.5:1440:30 RRA:AVERAGE:0.5:1440:30 RRA:LAST:0.5:10080:520 RRA:AVERAGE:0.5:10080:520

View file

@ -0,0 +1 @@
rrdtool create gas.rrd --step 30 DS:gas:ABSOLUTE:3600:U:U RRA:AVERAGE:0.5:1:28800 RRA:MIN:0.5:2880:3600 RRA:MAX:0.5:2880:3600 RRA:AVERAGE:0.5:2880:3600

View file

@ -0,0 +1,3 @@
rrdtool create water.rrd --no-overwrite --step 60 DS:counter:GAUGE:86400:0:100000
DS:consum:ABSOLUTE:86400:0:1 RRA:LAST:0.5:1:4320 RRA:AVERAGE:0.5:1:4320 RRA:LAST:0.5:1440:30
RRA:AVERAGE:0.5:1440:30 RRA:LAST:0.5:10080:520 RRA:AVERAGE:0.5:10080:520

View file

@ -0,0 +1,51 @@
<!DOCTYPE html>
<html>
<body>
<h2>Temperatur</h2>
<img src="../temperatur_1tag.png">
<h2>Gas</h2>
<img src="gas_3hour.png">
<img src="gas_6hour.png">
<img src="gas_12hour.png">
<img src="gas_1tag.png">
<img src="gas_1week.png">
<img src="gas_1month.png">
<img src="gas_1year.png">
<img src="gas_2year.png">
<img src="gascounter_1week.png">
<img src="gascounter_1month.png ">
<h2>Strom</h2>
<img src="consum_10minutes.png">
<img src="consum_30minutes.png">
<img src="consum_1hour.png">
<img src="consum_3hour.png">
<img src="consum_6hour.png">
<img src="consum_12hour.png">
<img src="consum_1day.png">
<img src="consum_1week.png">
<img src="consum_1month.png">
<img src="consum_1year.png">
<img src="consum_2year.png">
<img src="counter_1month.png">
<img src="counter_1week.png">
<h2>Wasser</h2>
<img src="wconsum_10minutes.png">
<img src="wconsum_30minutes.png">
<img src="wconsum_1hour.png">
<img src="wconsum_3hour.png">
<img src="wconsum_6hour.png">
<img src="wconsum_12hour.png">
<img src="wconsum_1day.png">
<img src="wconsum_1week.png">
<img src="wconsum_1month.png">
<img src="wconsum_1year.png">
<img src="wconsum_2year.png">
<img src="wcounter_1month.png">
<img src="wcounter_1week.png">
</body>
</html>

View file

@ -0,0 +1 @@
http://www.wigbels.net/cgi-bin/hhw.rb?logyear=2011

View file

@ -0,0 +1,138 @@
#!/usr/bin/ruby
#
# Author: Norbert Wigbels - foobla.wigbels.de/uber-foobla
#
# HotHotWrite receives data from HotHotRead and writes it to the dbms
# Example of calling URL - http://www.wigbels.net/cgi-bin/hhw.rb?sensorid=1&data=23.4 &measuredat=2007-20-14
#------------------------------------------
# Tainted mode 0-4
$SAFE=1
#------------------------------------------
require 'mysql'
require 'cgi'
require 'logger'
require 'time'
# Standard header
print "Content-type: text/plain\n\n"
# Date 14 07 2009
day = Time.now.strftime("%d")
month = Time.now.strftime("%m")
year = Time.now.strftime("%Y")
# CGI - GET-Parameter
cgi = CGI.new
if cgi.has_key?('sensorid')
sensorid = Integer(cgi['sensorid'])
end
if cgi.has_key?('data')
data = Float(cgi['data'])
end
if cgi.has_key?('logyear')
logyear = Integer(cgi['logyear'])
yearbefore = logyear - 1
end
# Logger
log = Logger.new(STDOUT)
log.level = Logger::INFO
begin
dbh = Mysql.real_connect("localhost", "hhw", "", "kraftwerk")
# data provided?, insert - no data select->display
if sensorid and data
dbh.query( %Q"insert into sensor (sensorid, data, measuredat) values (#{sensorid.to_s}, #{data.to_s}, now())" )
log.info("Inserted sensor: #{sensorid} with data: #{data}")
else
years = dbh.query( %Q"select count(distinct year(measuredat)) FROM sensor" ).fetch_row[0]
# Auswertung Gesamtes Jahr, Monat, Vergleich Vorjahr
myquery = %Q{ select sum(data), 'Liter Verbrauch in #{month}-#{logyear}' \
from sensor \
where year(measuredat) = '#{logyear}' and month(measuredat) = '#{month}'
union
select sum(data), 'Liter Verbrauch in #{month}-#{yearbefore}\n' \
from sensor \
where year(measuredat) = '#{yearbefore}' and month(measuredat) = '#{month}'
union \
select sum(data), 'Liter Gesamtverbrauch in #{logyear}' \
from sensor \
where year(measuredat) = '#{logyear}'
union
select sum(data), 'Liter Gesamtverbrauch in #{yearbefore}\n' \
from sensor \
where year(measuredat) = '#{yearbefore}'
union
select truncate(avg(data)/#{years},2), 'Durchschnittsverbrauch Gesamtjahr Liter/Tag' \
from \
(select sum(data) as data from sensor \
group by month(measuredat), day(measuredat)) \
as foo
union
select truncate(avg(data)/#{years},2), 'Durchschnittsverbrauch Sommmer Liter/Tag' \
from \
(select sum(data) as data from sensor \
where month(measuredat) in (4,5,6,7,8,9) \
group by month(measuredat), day(measuredat)) \
as foo
union
select truncate(avg(data)/#{years},2), 'Durchschnittsverbrauch Winter Liter/Tag' \
from \
(select sum(data) as data from sensor \
where month(measuredat) in (1,2,3,10,11,12) \
group by month(measuredat), day(measuredat)) \
as foo }
res = dbh.query( myquery )
while row = res.fetch_row do
printf "%s\t%s\n", row[0], row[1]
end
puts "\n\n"
# Auswertung Monat.
res = dbh.query( %Q{ select month(measuredat), '#{logyear}', sum(data) \
from sensor \
where year(measuredat) = '#{logyear}'\
group by month(measuredat)
order by month(measuredat) desc } )
puts "Datum\t\tVerbrauch (Liter)"
puts "======================================================================================================================================================="
while row = res.fetch_row do
chart = (row[2].to_i / 1200)
printf "%s-%s\t\t%s\t", row[0], row[1], row[2]
chart.times {print "#"}
print "\n"
end
puts "\n\n"
# Auswertung Jahr: Kummuliert nach Tagen, Monat.
res = dbh.query( %Q{ select day(measuredat), month(measuredat), '#{logyear}', sum(data) \
from sensor \
where year(measuredat) = '#{logyear}'\
group by month(measuredat), day(measuredat) \
order by month(measuredat) desc, day(measuredat) desc } )
puts "Datum\t\tVerbrauch (Liter)"
puts "======================================================================================================================================================="
while row = res.fetch_row do
chart = (row[3].to_i / 70)
printf "%s-%s-%s\t%s\t", row[0], row[1], row[2], row[3]
chart.times {print "#"}
print "\n"
end
res.free
end
rescue Mysql::Error => e
log.fatal("Error code: #{e.errno}")
log.fatal("Error message: #{e.error}")
if e.respond_to?("sqlstate")
log.fatal("Error SQLSTATE: #{e.sqlstate}")
end
ensure
# disconnect from server
dbh.close if dbh
end

View file

@ -0,0 +1 @@
Thu Aug 25 20:37:34 CEST 2005

View file

@ -0,0 +1,196 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>File: m2a.rb</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="fileHeader">
<h1>m2a.rb</h1>
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Path:</strong></td>
<td>m2a.rb
</td>
</tr>
<tr class="top-aligned-row">
<td><strong>Last Update:</strong></td>
<td>Tue Aug 23 20:43:38 CEST 2005</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
<div id="description">
<p>
A little script that copies imagefiles from your Sony Ericsson K700i
mobilephone to &lt;destination&gt;
</p>
</div>
</div>
<div id="method-list">
<h3 class="section-bar">Methods</h3>
<div class="name-list">
<a href="#M000002">doCrudeObexAppComm</a>&nbsp;&nbsp;
<a href="#M000003">getObexIOObject</a>&nbsp;&nbsp;
<a href="#M000001">usage</a>&nbsp;&nbsp;
</div>
</div>
</div>
<!-- if includes -->
<div id="section">
<div id="constants-list">
<h3 class="section-bar">Constants</h3>
<div class="name-list">
<table summary="Constants">
<tr class="top-aligned-row context-row">
<td class="context-item-name">BD_ADDR</td>
<td>=</td>
<td class="context-item-value">&quot;trebroN&quot;</td>
<td width="3em">&nbsp;</td>
<td class="context-item-desc">
SE K700i organizes the camera pictures in Bilder/camera_semc
</td>
</tr>
<tr class="top-aligned-row context-row">
<td class="context-item-name">OBEX_DIR1</td>
<td>=</td>
<td class="context-item-value">&quot;Bilder&quot;</td>
</tr>
<tr class="top-aligned-row context-row">
<td class="context-item-name">OBEX_DIR2</td>
<td>=</td>
<td class="context-item-value">&quot;camera_semc&quot;</td>
</tr>
</table>
</div>
</div>
<!-- if method_list -->
<div id="methods">
<h3 class="section-bar">Public Instance methods</h3>
<div id="method-M000002" class="method-detail">
<a name="M000002"></a>
<div class="method-heading">
<a href="m2a_rb.src/M000002.html" target="Code" class="method-signature"
onclick="popupCode('m2a_rb.src/M000002.html');return false;">
<span class="method-name">doCrudeObexAppComm</span><span class="method-args">()</span>
</a>
</div>
<div class="method-description">
</div>
</div>
<div id="method-M000003" class="method-detail">
<a name="M000003"></a>
<div class="method-heading">
<a href="m2a_rb.src/M000003.html" target="Code" class="method-signature"
onclick="popupCode('m2a_rb.src/M000003.html');return false;">
<span class="method-name">getObexIOObject</span><span class="method-args">()</span>
</a>
</div>
<div class="method-description">
</div>
</div>
<div id="method-M000001" class="method-detail">
<a name="M000001"></a>
<div class="method-heading">
<a href="m2a_rb.src/M000001.html" target="Code" class="method-signature"
onclick="popupCode('m2a_rb.src/M000001.html');return false;">
<span class="method-name">usage</span><span class="method-args">()</span>
</a>
</div>
<div class="method-description">
<p>
A little script that copies imagefiles from your Sony Ericsson K700i
mobilephone to &lt;destination&gt;
</p>
</div>
</div>
</div>
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>

View file

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>usage (m2a.rb)</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
<pre><span class="ruby-comment cmt"># File m2a.rb, line 10</span>
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">usage</span>
<span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;usage: m2a.rb &lt;destination&gt;&quot;</span>
<span class="ruby-identifier">exit</span>(<span class="ruby-value">-1</span>)
<span class="ruby-keyword kw">end</span></pre>
</body>
</html>

View file

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>doCrudeObexAppComm (m2a.rb)</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
<pre><span class="ruby-comment cmt"># File m2a.rb, line 24</span>
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">doCrudeObexAppComm</span>
<span class="ruby-keyword kw">begin</span>
<span class="ruby-identifier">cam</span> = <span class="ruby-identifier">getObexIOObject</span>
<span class="ruby-identifier">cam</span>.<span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;ls&quot;</span>
<span class="ruby-identifier">cam</span>.<span class="ruby-identifier">close_write</span>
<span class="ruby-identifier">lines</span> = <span class="ruby-identifier">cam</span>.<span class="ruby-identifier">readlines</span>
<span class="ruby-identifier">cam</span> = <span class="ruby-identifier">getObexIOObject</span>
<span class="ruby-identifier">lines</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">line</span><span class="ruby-operator">|</span>
<span class="ruby-identifier">line</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/Bild\(\d+\).jpg/</span>
<span class="ruby-comment cmt">#black-magic-ruby $&amp; holds the match</span>
<span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">$&amp;</span>.<span class="ruby-identifier">nil?</span>
<span class="ruby-identifier">cam</span>.<span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;get&quot;</span>
<span class="ruby-identifier">cam</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">$&amp;</span>
<span class="ruby-identifier">cam</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">$destination</span><span class="ruby-operator">+</span><span class="ruby-value str">'/'</span><span class="ruby-operator">+</span><span class="ruby-identifier">$&amp;</span>
<span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;copy picture &quot;</span><span class="ruby-operator">+</span><span class="ruby-identifier">$&amp;</span><span class="ruby-operator">+</span><span class="ruby-value str">&quot; to to &quot;</span><span class="ruby-operator">+</span><span class="ruby-identifier">$destination</span>
<span class="ruby-comment cmt">#delete picturea after copying? uncomment...</span>
<span class="ruby-comment cmt">#doesn't work on my phone:(</span>
<span class="ruby-comment cmt">#cam.puts &quot;delete&quot;</span>
<span class="ruby-comment cmt">#cam.puts $&amp;</span>
<span class="ruby-keyword kw">end</span>
<span class="ruby-keyword kw">end</span>
<span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">ex</span>
<span class="ruby-identifier">puts</span>(<span class="ruby-identifier">ex</span>.<span class="ruby-identifier">to_s</span>)
<span class="ruby-keyword kw">ensure</span>
<span class="ruby-comment cmt"># TODO: ensure connection is closed</span>
<span class="ruby-identifier">cam</span>.<span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;disconnect&quot;</span>
<span class="ruby-identifier">cam</span>.<span class="ruby-identifier">close</span>
<span class="ruby-keyword kw">end</span>
<span class="ruby-keyword kw">end</span></pre>
</body>
</html>

View file

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>getObexIOObject (m2a.rb)</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
<pre><span class="ruby-comment cmt"># File m2a.rb, line 54</span>
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">getObexIOObject</span>
<span class="ruby-identifier">cam</span> = <span class="ruby-constant">IO</span>.<span class="ruby-identifier">popen</span>(<span class="ruby-node">&quot;obexapp -a #{BD_ADDR} -C OPUSH&quot;</span>, <span class="ruby-value str">&quot;w+&quot;</span>)
<span class="ruby-identifier">cam</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;cd #{OBEX_DIR1}&quot;</span>
<span class="ruby-identifier">cam</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;cd #{OBEX_DIR2}&quot;</span>
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">cam</span>
<span class="ruby-keyword kw">end</span></pre>
</body>
</html>

View file

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--
Classes
-->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Classes</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="rdoc-style.css" type="text/css" />
<base target="docwin" />
</head>
<body>
<div id="index">
<h1 class="section-bar">Classes</h1>
<div id="index-entries">
</div>
</div>
</body>
</html>

View file

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--
Files
-->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Files</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="rdoc-style.css" type="text/css" />
<base target="docwin" />
</head>
<body>
<div id="index">
<h1 class="section-bar">Files</h1>
<div id="index-entries">
<a href="files/m2a_rb.html">m2a.rb</a><br />
</div>
</div>
</body>
</html>

View file

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--
Methods
-->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Methods</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="rdoc-style.css" type="text/css" />
<base target="docwin" />
</head>
<body>
<div id="index">
<h1 class="section-bar">Methods</h1>
<div id="index-entries">
<a href="files/m2a_rb.html#M000002">doCrudeObexAppComm (m2a.rb)</a><br />
<a href="files/m2a_rb.html#M000003">getObexIOObject (m2a.rb)</a><br />
<a href="files/m2a_rb.html#M000001">usage (m2a.rb)</a><br />
</div>
</div>
</body>
</html>

View file

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<!--
RDoc Documentation
-->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>RDoc Documentation</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<frameset rows="20%, 80%">
<frameset cols="25%,35%,45%">
<frame src="fr_file_index.html" title="Files" name="Files" />
<frame src="fr_class_index.html" name="Classes" />
<frame src="fr_method_index.html" name="Methods" />
</frameset>
<frame src="files/m2a_rb.html" name="docwin" />
</frameset>
</html>

View file

@ -0,0 +1,208 @@
body {
font-family: Verdana,Arial,Helvetica,sans-serif;
font-size: 90%;
margin: 0;
margin-left: 40px;
padding: 0;
background: white;
}
h1,h2,h3,h4 { margin: 0; color: #efefef; background: transparent; }
h1 { font-size: 150%; }
h2,h3,h4 { margin-top: 1em; }
a { background: #eef; color: #039; text-decoration: none; }
a:hover { background: #039; color: #eef; }
/* Override the base stylesheet's Anchor inside a table cell */
td > a {
background: transparent;
color: #039;
text-decoration: none;
}
/* and inside a section title */
.section-title > a {
background: transparent;
color: #eee;
text-decoration: none;
}
/* === Structural elements =================================== */
div#index {
margin: 0;
margin-left: -40px;
padding: 0;
font-size: 90%;
}
div#index a {
margin-left: 0.7em;
}
div#index .section-bar {
margin-left: 0px;
padding-left: 0.7em;
background: #ccc;
font-size: small;
}
div#classHeader, div#fileHeader {
width: auto;
color: white;
padding: 0.5em 1.5em 0.5em 1.5em;
margin: 0;
margin-left: -40px;
border-bottom: 3px solid #006;
}
div#classHeader a, div#fileHeader a {
background: inherit;
color: white;
}
div#classHeader td, div#fileHeader td {
background: inherit;
color: white;
}
div#fileHeader {
background: #057;
}
div#classHeader {
background: #048;
}
.class-name-in-header {
font-size: 180%;
font-weight: bold;
}
div#bodyContent {
padding: 0 1.5em 0 1.5em;
}
div#description {
padding: 0.5em 1.5em;
background: #efefef;
border: 1px dotted #999;
}
div#description h1,h2,h3,h4,h5,h6 {
color: #125;;
background: transparent;
}
div#validator-badges {
text-align: center;
}
div#validator-badges img { border: 0; }
div#copyright {
color: #333;
background: #efefef;
font: 0.75em sans-serif;
margin-top: 5em;
margin-bottom: 0;
padding: 0.5em 2em;
}
/* === Classes =================================== */
table.header-table {
color: white;
font-size: small;
}
.type-note {
font-size: small;
color: #DEDEDE;
}
.xxsection-bar {
background: #eee;
color: #333;
padding: 3px;
}
.section-bar {
color: #333;
border-bottom: 1px solid #999;
margin-left: -20px;
}
.section-title {
background: #79a;
color: #eee;
padding: 3px;
margin-top: 2em;
margin-left: -30px;
border: 1px solid #999;
}
.top-aligned-row { vertical-align: top }
.bottom-aligned-row { vertical-align: bottom }
/* --- Context section classes ----------------------- */
.context-row { }
.context-item-name { font-family: monospace; font-weight: bold; color: black; }
.context-item-value { font-size: small; color: #448; }
.context-item-desc { color: #333; padding-left: 2em; }
/* --- Method classes -------------------------- */
.method-detail {
background: #efefef;
padding: 0;
margin-top: 0.5em;
margin-bottom: 1em;
border: 1px dotted #ccc;
}
.method-heading {
color: black;
background: #ccc;
border-bottom: 1px solid #666;
padding: 0.2em 0.5em 0 0.5em;
}
.method-signature { color: black; background: inherit; }
.method-name { font-weight: bold; }
.method-args { font-style: italic; }
.method-description { padding: 0 0.5em 0 0.5em; }
/* --- Source code sections -------------------- */
a.source-toggle { font-size: 90%; }
div.method-source-code {
background: #262626;
color: #ffdead;
margin: 1em;
padding: 0.5em;
border: 1px dashed #999;
overflow: hidden;
}
div.method-source-code pre { color: #ffdead; overflow: hidden; }
/* --- Ruby keyword styles --------------------- */
.standalone-code { background: #221111; color: #ffdead; overflow: hidden; }
.ruby-constant { color: #7fffd4; background: transparent; }
.ruby-keyword { color: #00ffff; background: transparent; }
.ruby-ivar { color: #eedd82; background: transparent; }
.ruby-operator { color: #00ffee; background: transparent; }
.ruby-identifier { color: #ffdead; background: transparent; }
.ruby-node { color: #ffa07a; background: transparent; }
.ruby-comment { color: #b22222; font-weight: bold; background: transparent; }
.ruby-regexp { color: #ffa07a; background: transparent; }
.ruby-value { color: #7fffd4; background: transparent; }

View file

@ -0,0 +1,64 @@
#!/usr/local/bin/ruby -w
# Norbert Wigbels
#
#######################################################################
# A little script that copies imagefiles from your
# Sony Ericsson K700i mobilephone to <destination>
#######################################################################
#
#
def usage
puts "usage: m2a.rb <destination>"
exit(-1)
end
usage if ARGV.length != 1
$destination = ARGV[0]
# SE K700i organizes the camera pictures in Bilder/camera_semc
BD_ADDR = "trebroN"
OBEX_DIR1 = "Bilder"
OBEX_DIR2 = "camera_semc"
def doCrudeObexAppComm
begin
cam = getObexIOObject
cam.puts "ls"
cam.close_write
lines = cam.readlines
cam = getObexIOObject
lines.each do |line|
line =~ /Bild\(\d+\).jpg/
#black-magic-ruby $& holds the match
if !$&.nil?
cam.puts "get"
cam.puts $&
cam.puts $destination+'/'+$&
puts "copy picture "+$&+" to to "+$destination
#delete picturea after copying? uncomment...
#doesn't work on my phone:(
#cam.puts "delete"
#cam.puts $&
end
end
rescue Exception => ex
puts(ex.to_s)
ensure
# TODO: ensure connection is closed
cam.puts "disconnect"
cam.close
end
end
def getObexIOObject
cam = IO.popen("obexapp -a #{BD_ADDR} -C OPUSH", "w+")
cam.puts "cd #{OBEX_DIR1}"
cam.puts "cd #{OBEX_DIR2}"
return cam
end
# start here
doCrudeObexAppComm

Some files were not shown because too many files have changed in this diff Show more