git-svn-id: svn://db.shs.com.ru/pip@675 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5

This commit is contained in:
2018-12-18 22:25:27 +00:00
parent 37b97ed4aa
commit 74e96c1402
2 changed files with 34 additions and 11 deletions

View File

@@ -720,22 +720,45 @@ void PISerial::configureFromFullPathDevice(const PIString & full_path) {
PIPropertyStorage PISerial::constructVariantDevice() const {
PIPropertyStorage ret;
ret.addProperty("path", path());
ret.addProperty("speed", (int)inSpeed());
ret.addProperty("bits", dataBitsCount());
ret.addProperty("parity", parameters()[ParityControl]);
ret.addProperty("parityEven", !parameters()[ParityOdd]);
ret.addProperty("twoStopBits", parameters()[TwoStopBits]);
PIVariantTypes::Enum e;
PIVector<int> as = availableSpeeds();
piForeachC (int s, as) {e << PIVariantTypes::Enumerator(s, PIString::fromNumber(s));}
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;
}
void PISerial::configureFromVariantDevice(const PIPropertyStorage & d) {
setPath(d.propertyValueByName("path").toString());
setSpeed((Speed)d.propertyValueByName("speed").toInt());
setDataBitsCount(d.propertyValueByName("bits").toInt());
setParameter(ParityControl, d.propertyValueByName("parity").toBool());
setParameter(ParityOdd , !d.propertyValueByName("parityEven").toBool());
setParameter(TwoStopBits , d.propertyValueByName("twoStopBits").toBool());
setSpeed((Speed)d.propertyValueByName("speed").toEnum().selectedValue());
setDataBitsCount(d.propertyValueByName("dataBits").toEnum().selectedValue());
PIVariantTypes::Enum e = d.propertyValueByName("parity").toEnum();
setParameter(ParityControl, e.selectedValue() > 0);
setParameter(ParityOdd , e.selectedValue() == 1);
setParameter(TwoStopBits , d.propertyValueByName("stopBits").toEnum().selectedValue() == 2);
}