* object group
* @param variation
* object variation
*/
private void setDB(int index, byte[] data, byte group, byte variation) {
DataElement rec = new DataElement();
rec.setIndex(index);
rec.setGroup(DataObject.getObjectType(group));
rec.setTimestamp(System.currentTimeMillis());
// set value & Q_INVALID quality
switch (DataObject.getObjectType(group)) {
case BIN_IN: {
rec.setValue(DataObject.unformatBool(group, variation, data,
(false)).toString());
if (variation == 2) {
rec.setQuality(data[0]);
} else {
// rec.quality = DataObject.setFlag(rec);
}
if ((group == 2) && (variation == 2)) // Binary Input Change with
// Time
{
byte[] time = new byte[6];
System.arraycopy(data, 1, time, 0, 6);
rec.setTimestamp(DataObject.setTime(time));
}
}
break;
case BIN_OUT: {
rec.setValue(DataObject.unformatBool(group, variation, data,
(false)).toString());
if (variation == 2) {
rec.setQuality(data[0]);
} else {
// rec.quality = DataObject.setFlag(rec);
}
}
break;
case COUNTER: {
// rec.setValue(DataObject.unformatFloat(group, variation, data,
// element.getScale(), element.getOffset()));
// rec.quality = DataObject.setFlag(rec);
}
break;
case ANA_IN: {
rec.setValue(""
+ DataObject.unformatFloat(group, variation, data, 1, 0));
if (variation < 3) {
rec.setQuality(data[0]);
} else {
// rec.quality = DataObject.setFlag(rec);
}
}
break;
case ANA_OUT: {
rec.setValue(""
+ DataObject.unformatFloat(group, variation, data, 1, 0));
if (group == 40) {
rec.setQuality(data[0]);
} else {
// rec.quality = DataObject.setFlag(rec);
}
}