コード例 #1
0
ファイル: kitchensink.go プロジェクト: cswank/quimby
func main() {
	cfg := &gogadgets.Config{
		Host: "localhost",
		Gadgets: []gogadgets.GadgetConfig{
			gogadgets.GadgetConfig{
				Location: "tank",
				Name:     "volume",
				Pin: gogadgets.Pin{
					Type:      "switch",
					Direction: "in",
					Edge:      "both",
					Port:      "8",
					Pin:       "9",
					Value:     5.0,
					Units:     "liters",
				},
			},
			gogadgets.GadgetConfig{
				Location: "tank",
				Name:     "water",
				Pin: gogadgets.Pin{
					Type:      "gpio",
					Direction: "out",
					Port:      "8",
					Pin:       "10",
				},
			},
			gogadgets.GadgetConfig{
				Location: "lab",
				Name:     "led",
				Pin: gogadgets.Pin{
					Type:      "gpio",
					Direction: "out",
					Port:      "8",
					Pin:       "11",
				},
			},
			gogadgets.GadgetConfig{
				Location: "tank",
				Name:     "temperature",
				Pin: gogadgets.Pin{
					Type:      "thermometer",
					OneWireId: "28-0000047ade8f",
					Units:     "C",
				},
			},
		},
	}
	app := gogadgets.NewApp(cfg)
	stop := make(chan bool)
	app.Start(stop)
}
コード例 #2
0
ファイル: greenhouse.go プロジェクト: cswank/quimby
func main() {
	flag.Parse()
	if !utils.FileExists("/sys/bus/w1/devices/28-0000047ade8f") {
		ioutil.WriteFile("/sys/devices/bone_capemgr.9/slots", []byte("BB-W1:00A0"), 0666)
	}
	a := gogadgets.NewApp(configFlag)
	sleepTimes := map[string]time.Duration{
		"bed 1": 300 * time.Second,
		"bed 2": 300 * time.Second,
		"bed 3": 300 * time.Second,
	}
	g := &Greenhouse{sleepTimes: sleepTimes}
	a.AddGadget(g)
	a.Start()
}
コード例 #3
0
ファイル: brewery.go プロジェクト: cswank/brewery
func getApp(cfg interface{}, brewCfg *brewery.BrewConfig) (*gogadgets.App, error) {
	hlt, tun, boiler, carboy := brewery.NewBrewery(brewCfg)
	a := gogadgets.NewApp(cfg, hlt, tun, boiler, carboy)
	return a, nil
}
コード例 #4
0
ファイル: app_test.go プロジェクト: cswank/quimby
				Name:     name,
				Input: &gogadgets.Switch{
					GPIO:      poller,
					Value:     5.0,
					TrueValue: 5.0,
					Units:     "liters",
				},
				UID: fmt.Sprintf("%s %s", location, name),
			}
			cfg := &gogadgets.Config{
				Master: "",
				Host:   "localhost",
				Port:   port,
				Logger: lg,
			}
			a := gogadgets.NewApp(cfg, p, s)

			input := make(chan gogadgets.Message)
			go a.GoStart(input)

			msg := gogadgets.Message{
				Type: "command",
				Body: "turn on tank pump",
			}

			Expect(fo.on).To(BeFalse())

			input <- msg

			Eventually(func() bool {
				return fo.on