80 bool wire1found = dir.exists();
82 QVariantMap::const_iterator i = Details.constBegin();
83 for ( ; i != Details.constEnd(); ++i)
89 QVariantMap wire1 = i.value().toMap();
90 QVariantMap::iterator it = wire1.begin();
91 for ( ; it != wire1.end(); ++it)
101 LOG(VB_GENERAL, LOG_ERR, QStringLiteral(
"1Wire device configured but cannot find 1Wire directory (%1)").arg(
ONE_WIRE_DIRECTORY));
105 QVariantMap devices = it.value().toMap();
106 QVariantMap::iterator it2 = devices.begin();
107 for ( ; it2 != devices.end(); ++it2)
109 QString devicetype = it2.key();
110 QVariantMap details = it2.value().toMap();
113 if (!details.contains(QStringLiteral(
"wire1serial")))
115 LOG(VB_GENERAL, LOG_ERR, QStringLiteral(
"Cannot create 1Wire device without unique 1Wire ID ('%1' '%2')")
116 .arg(devicetype, details.value(QStringLiteral(
"name")).toString()));
124 device = factory->
Create(devicetype, details);
131 QString deviceid = details.
value(QStringLiteral(
"wire1serial")).toString();
132 LOG(VB_GENERAL, LOG_INFO, QStringLiteral(
"New 1Wire device: %1").arg(deviceid));
133 m_inputs.insert(deviceid, device);
137 LOG(VB_GENERAL, LOG_WARNING, QStringLiteral(
"Unable to find handler for 1Wire device type '%1'").arg(devicetype));
152 QHash<QString,TorcInput*>::const_iterator it = m_inputs.constBegin();
153 for ( ; it != m_inputs.constEnd(); ++it)
155 TorcInputs::gInputs->RemoveInput(it.value());
156 it.value()->DownRef();
164 : nextTorc1WireDeviceFactory(gTorc1WireDeviceFactory)
180 QStringLiteral(
"<xs:simpleType name='ds18b20SerialType'>\r\n" 181 " <xs:restriction base='xs:string'>\r\n" 182 " <xs:pattern value='28-[0-9a-fA-F]{12}'/>\r\n" 183 " </xs:restriction>\r\n" 184 "</xs:simpleType>\r\n" 185 "<xs:complexType name='ds18b20Type'>\r\n" 187 " <xs:element name='name' type='deviceNameType'/>\r\n" 188 " <xs:element name='username' type='userNameType' minOccurs='0' maxOccurs='1'/>\r\n" 189 " <xs:element name='userdescription' type='userDescriptionType' minOccurs='0' maxOccurs='1'/>\r\n" 190 " <xs:element name='wire1serial' type='ds18b20SerialType'/>\r\n" 192 "</xs:complexType>\r\n\r\n" 193 "<xs:complexType name='wire1Type'>\r\n" 194 " <xs:choice minOccurs='1' maxOccurs='unbounded'>\r\n" 195 " <xs:element name='ds18b20' type='ds18b20Type'/>\r\n" 197 "</xs:complexType>\r\n");
200 QStringLiteral(
" <xs:element minOccurs='0' maxOccurs='1' name='wire1' type='wire1Type'/>\r\n");
203 QStringLiteral(
"<!-- enforce unique 1Wire serial numbers -->\r\n" 204 "<xs:unique name='uniqueWire1Serial'>\r\n" 205 "<xs:selector xpath='.//wire1serial' />\r\n" 206 " <xs:field xpath='.' />\r\n" 212 void GetXSD(QMultiMap<QString,QString> &XSD) {
A class to handle the one wire files system (OWFS) for 1Wire devices.
static const QString wire1InputTypes
static Torc1WireDeviceFactory * gTorc1WireDeviceFactory
void GetXSD(QMultiMap< QString, QString > &XSD)
void Create(const QVariantMap &Details)
static Torc1WireBus * gTorc1WireBus
static Torc1WireDeviceFactory * GetTorc1WireDeviceFactory(void)
Torc1WireDeviceFactory * NextFactory(void) const
static const QString wire1Inputs
virtual TorcInput * Create(const QString &DeviceType, const QVariantMap &Details)=0
#define LOG(_MASK_, _LEVEL_, _STRING_)
QReadWriteLock m_handlerLock
Torc1WireDeviceFactory * nextTorc1WireDeviceFactory
#define ONE_WIRE_DIRECTORY
Torc1WireXSDFactory Torc1WireXSDFactory
static const QString wire1Unique