36 : nextTorcI2CDeviceFactory(gTorcI2CDeviceFactory)
63 QVariantMap::const_iterator i = Details.constBegin();
64 for ( ; i != Details.constEnd(); ++i)
70 QVariantMap i2c = i.value().toMap();
71 QVariantMap::iterator it = i2c.begin();
72 for ( ; it != i2c.end(); ++it)
78 QVariantMap devices = it.value().toMap();
79 QVariantMap::iterator it2 = devices.begin();
80 for ( ; it2 != devices.end(); ++it2)
82 QVariantMap details = it2.value().toMap();
85 if (!details.contains(QStringLiteral(
"i2caddress")))
87 LOG(VB_GENERAL, LOG_ERR, QStringLiteral(
"I2C device '%1' needs <i2caddress>").arg(it2.key()));
93 int address = details.value(QStringLiteral(
"i2caddress")).toString().toInt(&ok, 16);
96 LOG(VB_GENERAL, LOG_ERR, QStringLiteral(
"Failed to parse I2C address from '%1' for device '%2'")
97 .arg(details.value(QStringLiteral(
"address")).toString(), it2.key()));
102 if (m_devices.contains(address))
104 LOG(VB_GENERAL, LOG_ERR, QStringLiteral(
"I2C bus already contains device at 0x%1 - ignoring").arg(address, 0, 16));
112 device = factory->
Create(address, it2.key(), details);
118 m_devices.insert(address, device);
120 LOG(VB_GENERAL, LOG_ERR, QStringLiteral(
"Unable to find handler for I2C device '%1'").arg(it2.key()));
130 qDeleteAll(m_devices);
134 "<xs:simpleType name='pca9685ChannelNumberType'>\r\n" 135 " <xs:restriction base='xs:integer'>\r\n" 136 " <xs:minInclusive value='0'/>\r\n" 137 " <xs:maxInclusive value='15'/>\r\n" 138 " </xs:restriction>\r\n" 139 "</xs:simpleType>\r\n" 141 "<xs:complexType name='pca9685ChannelType'>\r\n" 143 " <xs:element name='name' type='deviceNameType'/>\r\n" 144 " <xs:element name='username' type='userNameType' minOccurs='0' maxOccurs='1'/>\r\n" 145 " <xs:element name='userdescription' type='userDescriptionType' minOccurs='0' maxOccurs='1'/>\r\n" 146 " <xs:element name='number' type='pca9685ChannelNumberType'/>\r\n" 148 "</xs:complexType>\r\n" 150 "<xs:complexType name='pca9685Type'>\r\n" 152 " <!-- NB this enforces the address first -->\r\n" 153 " <xs:element name='i2caddress' type='hexType' minOccurs='1' maxOccurs='1'/>\r\n" 154 " <xs:element name='channel' type='pca9685ChannelType' minOccurs='1' maxOccurs='16'/>\r\n" 155 " </xs:sequence>\r\n" 156 "</xs:complexType>\r\n" 158 "<xs:complexType name='i2cType'>\r\n" 159 " <xs:choice minOccurs='1' maxOccurs='unbounded'>\r\n" 160 " <xs:element name='pca9685' type='pca9685Type'/>\r\n" 162 "</xs:complexType>\r\n");
165 " <xs:element minOccurs='0' maxOccurs='1' name='i2c' type='i2cType'/>\r\n");
168 " <!-- enforce unique i2c addresses -->\r\n" 169 " <xs:unique name='uniqueI2CAddress'>\r\n" 170 " <xs:selector xpath='.//i2caddress' />\r\n" 171 " <xs:field xpath='.' />\r\n" 172 " </xs:unique>\r\n");
178 void GetXSD(QMultiMap<QString,QString> &XSD) {
static TorcI2CDeviceFactory * gTorcI2CDeviceFactory
static TorcI2CBus * gTorcI2CBus
static const QString i2cOutputTypes
static const QString i2cOutputs
static const QString i2cUnique
#define OUTPUTS_DIRECTORY
virtual TorcI2CDevice * Create(int Address, const QString &Name, const QVariantMap &Details)=0
void Create(const QVariantMap &Details)
TorcI2CXSDFactory TorcI2CXSDFactory
TorcI2CDevice(int Address)
#define LOG(_MASK_, _LEVEL_, _STRING_)
QReadWriteLock m_handlerLock
void GetXSD(QMultiMap< QString, QString > &XSD)
TorcI2CDeviceFactory * NextFactory(void) const
static TorcI2CDeviceFactory * GetTorcI2CDeviceFactory(void)
TorcI2CDeviceFactory * nextTorcI2CDeviceFactory