git-svn-id: svn://db.shs.com.ru/pip@675 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
2
main.cpp
2
main.cpp
@@ -9,7 +9,7 @@ int main() {
|
|||||||
CRC_16 crc = CRC_16(0x8005, 0xFFFF, 0xFFFF, false);
|
CRC_16 crc = CRC_16(0x8005, 0xFFFF, 0xFFFF, false);
|
||||||
piCout << PICoutManipulators::Hex << s;
|
piCout << PICoutManipulators::Hex << s;
|
||||||
piCout << PICoutManipulators::Hex << crc.calculate(msg);*/
|
piCout << PICoutManipulators::Hex << crc.calculate(msg);*/
|
||||||
PIIODevice * ser = PIIODevice::createFromFullPath("ser://COM3:9600:9:o:2 (wo,bwr)");
|
PIIODevice * ser = PIIODevice::createFromFullPath("ser://COM3:9600:7:e:1 (wo,bwr)");
|
||||||
piCout << ser << ser->constructVariant() << ser->constructFullPath();
|
piCout << ser << ser->constructVariant() << ser->constructFullPath();
|
||||||
ser = PIIODevice::createFromVariant(ser->constructVariant());
|
ser = PIIODevice::createFromVariant(ser->constructVariant());
|
||||||
piCout << ser << ser->constructVariant() << ser->constructFullPath();
|
piCout << ser << ser->constructVariant() << ser->constructFullPath();
|
||||||
|
|||||||
@@ -720,22 +720,45 @@ void PISerial::configureFromFullPathDevice(const PIString & full_path) {
|
|||||||
PIPropertyStorage PISerial::constructVariantDevice() const {
|
PIPropertyStorage PISerial::constructVariantDevice() const {
|
||||||
PIPropertyStorage ret;
|
PIPropertyStorage ret;
|
||||||
ret.addProperty("path", path());
|
ret.addProperty("path", path());
|
||||||
ret.addProperty("speed", (int)inSpeed());
|
PIVariantTypes::Enum e;
|
||||||
ret.addProperty("bits", dataBitsCount());
|
|
||||||
ret.addProperty("parity", parameters()[ParityControl]);
|
PIVector<int> as = availableSpeeds();
|
||||||
ret.addProperty("parityEven", !parameters()[ParityOdd]);
|
piForeachC (int s, as) {e << PIVariantTypes::Enumerator(s, PIString::fromNumber(s));}
|
||||||
ret.addProperty("twoStopBits", parameters()[TwoStopBits]);
|
e.selectValue((int)inSpeed());
|
||||||
|
ret.addProperty("speed", e);
|
||||||
|
|
||||||
|
e = PIVariantTypes::Enum();
|
||||||
|
for (int i = 5; i <= 8; ++i) {e << PIVariantTypes::Enumerator(i, PIString::fromNumber(i));}
|
||||||
|
e.selectValue(dataBitsCount());
|
||||||
|
ret.addProperty("dataBits", e);
|
||||||
|
|
||||||
|
e = PIVariantTypes::Enum();
|
||||||
|
e << "None" << "Odd" << "Even";
|
||||||
|
if (parameters()[ParityControl]) {
|
||||||
|
if (parameters()[ParityOdd])
|
||||||
|
e.selectValue(1);
|
||||||
|
else
|
||||||
|
e.selectValue(2);
|
||||||
|
} else
|
||||||
|
e.selectValue(0);
|
||||||
|
ret.addProperty("parity", e);
|
||||||
|
|
||||||
|
e = PIVariantTypes::Enum();
|
||||||
|
for (int i = 1; i <= 2; ++i) {e << PIVariantTypes::Enumerator(i, PIString::fromNumber(i));}
|
||||||
|
e.selectValue(parameters()[TwoStopBits] ? 2 : 1);
|
||||||
|
ret.addProperty("stopBits", e);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PISerial::configureFromVariantDevice(const PIPropertyStorage & d) {
|
void PISerial::configureFromVariantDevice(const PIPropertyStorage & d) {
|
||||||
setPath(d.propertyValueByName("path").toString());
|
setPath(d.propertyValueByName("path").toString());
|
||||||
setSpeed((Speed)d.propertyValueByName("speed").toInt());
|
setSpeed((Speed)d.propertyValueByName("speed").toEnum().selectedValue());
|
||||||
setDataBitsCount(d.propertyValueByName("bits").toInt());
|
setDataBitsCount(d.propertyValueByName("dataBits").toEnum().selectedValue());
|
||||||
setParameter(ParityControl, d.propertyValueByName("parity").toBool());
|
PIVariantTypes::Enum e = d.propertyValueByName("parity").toEnum();
|
||||||
setParameter(ParityOdd , !d.propertyValueByName("parityEven").toBool());
|
setParameter(ParityControl, e.selectedValue() > 0);
|
||||||
setParameter(TwoStopBits , d.propertyValueByName("twoStopBits").toBool());
|
setParameter(ParityOdd , e.selectedValue() == 1);
|
||||||
|
setParameter(TwoStopBits , d.propertyValueByName("stopBits").toEnum().selectedValue() == 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user