#include <iostream>
-// Global helper objects:
+// Global helper object:
extern PIRMakeMgr makeManager;
-//extern PIRDeviceTypeMgr deviceManager;
+
+// Static member definition:
+PIRDeviceCollection PIRKeysetMetaData::controlledDevices;
+
+// Thread synchronization stuff:
+extern bool commandInFlight;
PIRKeysetMetaData::PIRKeysetMetaData(
const char *r,
{
}
+
+PIRKeysetMetaData::~PIRKeysetMetaData()
+{
+ clearProtocol();
+}
+
+
bool PIRKeysetMetaData::hasKey(
PIRKeyName name) const
{
void PIRKeysetMetaData::populateDevices(
- unsigned int id,
- PIRSelectDeviceForm *sdf) const
+ PIRSelectDeviceForm *sdf)
{
PIRKeysetWidgetItem *kwi;
while (i != controlledDevices.end())
{
// Create a widget for the keyset:
- QString tempString = makeManager.getMakeString(i->make);
+ QString tempString = makeManager.getMakeString(i->first.make);
tempString.append(" ");
- tempString.append(i->model);
- kwi = new PIRKeysetWidgetItem(tempString, id, i->make, i->type);
+ tempString.append(i->first.model);
+
+ kwi = new PIRKeysetWidgetItem(
+ tempString, i->first.model, i->second, i->first.make, i->first.type);
+
sdf->addWidgetItem(kwi);
++i;
}
+unsigned int PIRKeysetMetaData::getCarrierFrequency() const
+{
+ if (!threadableProtocol)
+ {
+ return 0;
+ }
+
+ return threadableProtocol->getCarrierFrequency();
+}
+
+
+void PIRKeysetMetaData::setCarrierFrequency(
+ unsigned int carrierFrequency)
+{
+ if (!threadableProtocol)
+ {
+ return;
+ }
+
+ threadableProtocol->setCarrierFrequency(carrierFrequency);
+}
+
+
+unsigned int PIRKeysetMetaData::getDutyCycle() const
+{
+ if (!threadableProtocol)
+ {
+ return 0;
+ }
+
+ return threadableProtocol->getDutyCycle();
+}
+
+
+void PIRKeysetMetaData::setDutyCycle(
+ unsigned int dutyCycle)
+{
+ if (!threadableProtocol)
+ {
+ return;
+ }
+
+ threadableProtocol->setDutyCycle(dutyCycle);
+}
+
+
void PIRKeysetMetaData::addControlledDevice(
PIRMakeName make,
const char *model,
PIRDeviceTypeName type)
{
- controlledDevices.push_back(DeviceInfo(make, model, type));
-
- deviceTypes.insert(type);
+ controlledDevices.insert(
+ PIRDCPair(
+ DeviceInfo(make, model, type),
+ index));
}
}
+void PIRKeysetMetaData::addPanOldKey(
+ const char *name,
+ PIRKeyName key,
+ unsigned int addressData,
+ unsigned int commandData)
+{
+ if (key != Unmapped_Key)
+ {
+ keys[key] = name;
+ threadableProtocol->addPanOldKey(key, addressData, commandData);
+ }
+}
+
+
void PIRKeysetMetaData::addPioneerKey(
const char *name,
PIRKeyName key,
}
+void PIRKeysetMetaData::addXMPKey(
+ const char *name,
+ PIRKeyName key,
+ unsigned int firstCommand,
+ unsigned int secondCommand)
+{
+ if (key != Unmapped_Key)
+ {
+ keys[key] = name;
+ threadableProtocol->addXMPKey(key, firstCommand, secondCommand);
+ }
+}
+
+
void PIRKeysetMetaData::setPreData(
unsigned long data,
unsigned int bits)
{
keysetName = n;
}
+
+
+bool PIRKeysetMetaData::clearProtocol()
+{
+ if (!threadableProtocol)
+ {
+ return true;
+ }
+ else if (!commandInFlight)
+ {
+ delete threadableProtocol;
+ threadableProtocol = 0;
+ return true;
+ }
+
+ return false;
+}