2 Inter-driver communications tutorial - Dome Driver
3 Copyright (C) 2007 Jasem Mutlaq (mutlaqja@ikarustech.com)
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
32 #include <sys/types.h>
33 #include <sys/socket.h>
34 #include <netinet/in.h>
44 #define MAIN_GROUP "Main"
45 #define SNOOP_GROUP "Snooped"
50 static ISwitch PowerS[] = {{
"CONNECT" ,
"Connect" ,
ISS_OFF, 0, 0},{
"DISCONNECT",
"Disconnect",
ISS_ON, 0, 0}};
51 static ISwitchVectorProperty PowerSP = { mydev,
"CONNECTION" ,
"Connection", MAIN_GROUP,
IP_RW,
ISR_1OFMANY, 60,
IPS_IDLE, PowerS,
NARRAY(PowerS),
"", 0};
55 static ISwitchVectorProperty DomeSP = { mydev,
"Dome Status",
"", MAIN_GROUP,
IP_RW,
ISR_1OFMANY, 0,
IPS_IDLE, DomeS ,
NARRAY(DomeS),
"", 0};
76 void ISNewBLOB (
const char *dev,
const char *name,
int sizes[],
int blobsizes[],
char *blobs[],
char *formats[],
char *names[],
int n) {}
95 IDMessage(mydev,
"Rain Alert Detected! Dome is already closed.");
98 IDMessage(mydev,
"Rain threat passed. Opening the dome is now safe.");
107 if (dev && strcmp (dev, mydev))
111 if (!strcmp (name, PowerSP.
name))
118 if (PowerS[0].s ==
ISS_ON)
130 if (!strcmp (name, DomeSP.
name))
151 IDSetSwitch(&DomeSP,
"It is raining, cannot open dome.");
174 void ISNewText (
const char *dev,
const char *name,
char *texts[],
char *names[],
int n)
177 if (dev && strcmp (mydev, dev))
181 n=n; dev=dev; name=name; names=names; texts=texts;
185 void ISNewNumber (
const char *dev,
const char *name,
double values[],
char *names[],
int n) {}
191 IDSetSwitch(&DomeSP,
"Rain Alert! Dome is closing...");