public void ReadEntityUpdate(AUT_WH.MajorDomoProtocol.EntityUpdate _update) { // go through the update list for (int valueIdx = 0; valueIdx < _update.ValuesLength; valueIdx++) { // search by value index var valueUpdate = _update.Values(valueIdx).Value; EntityValue value = GetValue((byte)valueUpdate.Index); if (value != null) { // is this the correct type? if (value.Type == valueUpdate.Type) { // read value and remember if this changed it m_updated |= value.ReadEntityValue(valueUpdate); // Debug.Log("updated " + Name + "/" + value.Name + ":" + updated); } } } }
public void ReadEntityValues(AUT_WH.MajorDomoProtocol.EntityInformation _information) { // go through the update list for (int valueIdx = 0; valueIdx < _information.ValuesLength; valueIdx++) { // search by value index var valueInformation = _information.Values(valueIdx).Value; EntityValue value = EntityValue.GenerateEntityValueInstance(valueInformation.Name, (byte)valueIdx, valueInformation.Type); if (value != null) // TODO: This could cause index mismatch { m_values.Add(value); value.ReadEntityValue(valueInformation); m_updated = true; } else { Debug.LogWarning("Could not create entity value '" + valueInformation.Name + "' for " + ToString()); } } }
protected EntityValue AddEntityValue(string _name, AUT_WH.MajorDomoProtocol.EntityValueType _type) { // does the value already exist? EntityValue value = GetValue(_name, _type); if (value == null) { // not yet // is this entity already registered? If so, then no more values can be added if (State == EntityState.Created) { // is there room for one more? byte index = (byte)m_values.Count; if (index < MAX_VALUE_COUNT) { value = EntityValue.GenerateEntityValueInstance(_name, index, _type); m_values.Add(value); // Debug.Log("Entity value '" + _name + "' added to entity '" + Name + "'"); } else { Debug.LogWarning("Trying to add more than " + MAX_VALUE_COUNT + " values to entity '" + Name + "'"); } } else { Debug.LogWarning("Trying to add a value to registered entity '" + Name + "'"); } } else if (value.Type != _type) { Debug.LogWarning("Entity value '" + _name + "' already added to entity '" + Name + "' with different type"); value = null; } return(value); }
public bool Equals(EntityValue _other) { return((Name == _other.Name) && (Type == _other.Type)); }