예제 #1
0
 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());
         }
     }
 }
예제 #2
0
        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);
        }