Esempio n. 1
0
        private string GetExtraDataText(IExtraData ev, MessageIdentifier messageIdentifier)
        {
            switch (messageIdentifier)
            {
            case MessageIdentifier.BlackcallIncoming:
            case MessageIdentifier.AccelerationEvent:
            case MessageIdentifier.DesaccelerationEvent:
            case MessageIdentifier.BateryInfo:
                //return String.Format(" - {0}", ((Event)ev).SensorsDataString);
                return(ev.Data.Count > 1 ? String.Format(" - {0}", ev.Data[1]) : String.Empty);

            case MessageIdentifier.Picture:
                var cantidad = ev.Data.Count > 1 ? Convert.ToInt32(ev.Data[1]) : 0;
                var id       = ev.Data.Count > 2  ? Convert.ToInt32(ev.Data[2]) : 0;
                return(GetPictureText(cantidad, id));

            case MessageIdentifier.TemperatureInfo:
            case MessageIdentifier.TemperatureDisconected:
            case MessageIdentifier.TemperaturePowerDisconected:
            case MessageIdentifier.TemperaturePowerReconected:
            case MessageIdentifier.TemperatureThawingButtonPressed:
            case MessageIdentifier.TemperatureThawingButtonUnpressed:
            case MessageIdentifier.CheckpointReached:
                return(String.Format(" - {0:000.00}", ev.GetData() / (float)100.0));
            }

            return(String.Empty);
        }
Esempio n. 2
0
 public StructureSave(Vector2Int location, StructureType type, int activeTicks, IExtraData extraData)
 {
     this.location    = location;
     this.type        = type;
     this.activeTicks = activeTicks;
     this.extraData   = extraData;
 }
 public Structure(Vector2Int position, string type, string owner, string alliance, string standings, IExtraData extraData)
 {
     this.position  = position;
     this.type      = type;
     this.owner     = owner;
     this.alliance  = alliance;
     this.standings = standings;
     this.extraData = extraData;
 }
Esempio n. 4
0
        private static void EnsureCorrectKeys(string configFilePath, IExtraData @object, string namePath)
        {
            var properties = @object.GetType().GetProperties().Where(e => e.GetCustomAttribute <JsonPropertyNameAttribute>() != null).ToList();

            foreach (var property in properties.Where(property => property.PropertyType.IsAssignableTo(typeof(IExtraData))))
            {
                var child = (IExtraData)property.GetValue(@object);
                if (child != null)
                {
                    EnsureCorrectKeys(configFilePath, child, $"{namePath}.{property.GetCustomAttribute<JsonPropertyNameAttribute>()!.Name}");
                }
            }
            var extraData = @object.ExtraData;
            IReadOnlyCollection <string> extraKeys = extraData != null ? extraData.Keys : Array.Empty <string>();

            if (extraKeys.Any())
            {
                var allowedKeys = properties.Select(e => e.GetCustomAttribute <JsonPropertyNameAttribute>() !.Name).OrderBy(e => e);
                var description = extraKeys.Count == 1 ? $"\"{extraKeys.First()}\" was found" : $"others were found (\"{string.Join("\", \"", extraKeys)}\")";
                throw new InputException($"The allowed keys for the \"{namePath}\" object are {{ \"{string.Join("\", \"", allowedKeys)}\" }} but {description} in the config file at \"{configFilePath}\"");
            }
        }
Esempio n. 5
0
        public static String GetExtraDataText(this IExtraData ev, MessageIdentifier messageIdentifier)
        {
            switch (messageIdentifier)
            {
            //case MessageIdentifier.AccelerationEvent:
            //case MessageIdentifier.DesaccelerationEvent:
            case MessageIdentifier.RpmEvent:     // vel - rpm
                return(ev.Data.Count >= 3 ? String.Format(" - {0} - {1}", ev.Data[1], ev.Data[2]) : String.Empty);

            case MessageIdentifier.Picture:
                return(ev.Data.Count >= 2 ? String.Format(" - {0}", ev.Data[1]) : String.Empty);

            case MessageIdentifier.TemperatureInfo:
            case MessageIdentifier.TemperatureDisconected:
            case MessageIdentifier.TemperaturePowerDisconected:
            case MessageIdentifier.TemperaturePowerReconected:
            case MessageIdentifier.TemperatureThawingButtonPressed:
            case MessageIdentifier.TemperatureThawingButtonUnpressed:
                return(ev.Data.Count >= 1 ? String.Format(" - {0:000.00}", ev.Data[0] / (float)100.0) : String.Empty);
            }

            return(String.Empty);
        }
 public Structure(Vector2Int position, string type, string owner, string alliance, string standings, IExtraData extraData)
 {
     this.position = position;
     this.type = type;
     this.owner = owner;
     this.alliance = alliance;
     this.standings = standings;
     this.extraData = extraData;
 }
Esempio n. 7
0
 static partial void FillBinaryOwnerCustom(MutagenFrame frame, IExtraData item)
 {
     item.Owner = GetBinaryOwner(frame.ReadSpan(8), frame.MetaData.RecordInfoCache !, frame.MetaData.MasterReferences !);
 }
Esempio n. 8
0
 public static Int64 GetData2(this IExtraData me)
 {
     return(me == null ? 0 : (me.Data.Count <= 1 ? 0 : me.Data[1]));
 }
Esempio n. 9
0
 public StructureSave(Vector2Int location, StructureType type, int activeTicks, IExtraData extraData)
 {
     this.location = location;
     this.type = type;
     this.activeTicks = activeTicks;
     this.extraData = extraData;
 }