예제 #1
0
        /*
         * public TimeSpan RunFrequency => TimeSpan.FromMinutes(60);
         *
         * public void ProcessEntity(Entity entity, int deltaSeconds)
         * {
         *  SetEntityProfile(entity);
         * }
         *
         * public void ProcessManager(EntityManager manager, int deltaSeconds)
         * {
         *  Stopwatch timer = new Stopwatch();
         *  timer.Start();
         *  var entites = manager.GetAllEntitiesWithDataBlob<SensorProfileDB>();
         *  foreach (var entity in entites)
         *  {
         *      ProcessEntity(entity, deltaSeconds);
         *  }
         *  var ms = timer.ElapsedMilliseconds;
         *  var numEntites = entites.Count;
         * }
         */

        internal static void SetEntityProfile(Entity entity, DateTime atDate)
        {
            var position  = entity.GetDataBlob <PositionDB>();
            var sensorSig = entity.GetDataBlob <SensorProfileDB>();

            sensorSig.LastPositionOfReflectionSet = position.AbsolutePosition_AU;
            sensorSig.LastDatetimeOfReflectionSet = atDate;

            var emmiters          = entity.Manager.GetAllEntitiesWithDataBlob <SensorProfileDB>();
            int numberOfEmmitters = emmiters.Count;

            sensorSig.ReflectedEMSpectra.Clear();

            PercentValue reflectionPercent = 0.1f; //TODO: this should be calculated from crossSection(size), distance, and a reflectivity value(stealth armor?/ other design factors?).

            foreach (var emittingEntity in emmiters)
            {
                if (emittingEntity != entity) // don't reflect our own emmision.
                {
                    double distance    = PositionDB.GetDistanceBetween(position, emittingEntity.GetDataBlob <PositionDB>());
                    var    emmissionDB = emittingEntity.GetDataBlob <SensorProfileDB>();

                    foreach (var emitedItem in emmissionDB.EmittedEMSpectra)
                    {
                        var reflectedMagnatude = SensorProcessorTools.AttenuationCalc(emitedItem.Value, distance) * reflectionPercent;

                        sensorSig.ReflectedEMSpectra.Add(emitedItem.Key, emitedItem.Value);
                    }
                }
            }
        }
예제 #2
0
        /*
         * public TimeSpan RunFrequency => TimeSpan.FromMinutes(60);
         *
         * public void ProcessEntity(Entity entity, int deltaSeconds)
         * {
         *  SetEntityProfile(entity);
         * }
         *
         * public void ProcessManager(EntityManager manager, int deltaSeconds)
         * {
         *  Stopwatch timer = new Stopwatch();
         *  timer.Start();
         *  var entites = manager.GetAllEntitiesWithDataBlob<SensorProfileDB>();
         *  foreach (var entity in entites)
         *  {
         *      ProcessEntity(entity, deltaSeconds);
         *  }
         *  var ms = timer.ElapsedMilliseconds;
         *  var numEntites = entites.Count;
         * }
         */

        public static void SetEntityProfile(Entity entity, DateTime atDate)
        {
            var position  = entity.GetDataBlob <PositionDB>();
            var sensorSig = entity.GetDataBlob <SensorProfileDB>();

            sensorSig.LastPositionOfReflectionSet = position.AbsolutePosition_AU;
            sensorSig.LastDatetimeOfReflectionSet = atDate;

            var emmiters          = entity.Manager.GetAllEntitiesWithDataBlob <SensorProfileDB>();
            int numberOfEmmitters = emmiters.Count;

            sensorSig.ReflectedEMSpectra.Clear();

            //PercentValue reflectionPercent = 0.1f; //TODO: this should be calculated from crossSection(size), and a reflectivity value(stealth armor?/ other design factors?).
            var    surfaceArea          = sensorSig.TargetCrossSection_msq;
            double reflectionCoefficent = surfaceArea * sensorSig.Reflectivity;

            foreach (var emittingEntity in emmiters)
            {
                if (emittingEntity != entity) // don't reflect our own emmision.
                {
                    double distance    = PositionDB.GetDistanceBetween_m(position, emittingEntity.GetDataBlob <PositionDB>());
                    var    emmissionDB = emittingEntity.GetDataBlob <SensorProfileDB>();

                    foreach (var emitedItem in emmissionDB.EmittedEMSpectra)
                    {
                        var attenuated         = SensorProcessorTools.AttenuationCalc(emitedItem.Value, distance);
                        var reflectedMagnatude = attenuated * reflectionCoefficent;

                        if (reflectedMagnatude > 0.001) //ignore it if the signal is less than a watt
                        {
                            if (sensorSig.ReflectedEMSpectra.ContainsKey(emitedItem.Key))
                            {
                                sensorSig.ReflectedEMSpectra[emitedItem.Key] = sensorSig.ReflectedEMSpectra[emitedItem.Key] + reflectedMagnatude;
                            }
                            else
                            {
                                sensorSig.ReflectedEMSpectra.Add(emitedItem.Key, reflectedMagnatude);
                            }
                        }



                        //debug code:
                        if (emitedItem.Value < 0)
                        {
                            throw new Exception("Source should not be less than 0");
                        }
                        if (attenuated > emitedItem.Value)
                        {
                            throw new Exception("Attenuated value shoudl be less than source");
                        }
                        if (reflectedMagnatude > emitedItem.Value)
                        {
                            throw new Exception("final magnitude shoudl not be more than source");
                        }
                        if (reflectedMagnatude < 0)
                        {
                            throw new Exception("Final magnitude should not be less than 0");
                        }
                    }
                }
            }
        }
예제 #3
0
        /*
         * public TimeSpan RunFrequency => TimeSpan.FromMinutes(60);
         *
         * public void ProcessEntity(Entity entity, int deltaSeconds)
         * {
         *  SetEntityProfile(entity);
         * }
         *
         * public void ProcessManager(EntityManager manager, int deltaSeconds)
         * {
         *  Stopwatch timer = new Stopwatch();
         *  timer.Start();
         *  var entites = manager.GetAllEntitiesWithDataBlob<SensorProfileDB>();
         *  foreach (var entity in entites)
         *  {
         *      ProcessEntity(entity, deltaSeconds);
         *  }
         *  var ms = timer.ElapsedMilliseconds;
         *  var numEntites = entites.Count;
         * }
         */

        public static void SetEntityProfile(Entity entity, DateTime atDate)
        {
            var position  = entity.GetDataBlob <PositionDB>();
            var sensorSig = entity.GetDataBlob <SensorProfileDB>();

            sensorSig.LastPositionOfReflectionSet = position.AbsolutePosition_AU;
            sensorSig.LastDatetimeOfReflectionSet = atDate;

            var emmiters          = entity.Manager.GetAllEntitiesWithDataBlob <SensorProfileDB>();
            int numberOfEmmitters = emmiters.Count;

            sensorSig.ReflectedEMSpectra.Clear();

            //PercentValue reflectionPercent = 0.1f; //TODO: this should be calculated from crossSection(size), and a reflectivity value(stealth armor?/ other design factors?).
            //var surfaceArea = sensorSig.TargetCrossSection_msq;

            double tRad = 500;

            if (entity.HasDataBlob <MassVolumeDB>())
            {
                tRad = entity.GetDataBlob <MassVolumeDB>().RadiusInM;
            }



            foreach (var emittingEntity in emmiters)
            {
                if (emittingEntity != entity) // don't reflect our own emmision.
                {
                    double distance = PositionDB.GetDistanceBetween_m(position, emittingEntity.GetDataBlob <PositionDB>());
                    if (distance < 1)
                    {
                        distance = 1;
                    }

                    var    drad                 = Math.Sin(tRad / distance);
                    var    srad                 = Math.Sin(drad) * tRad;
                    var    surfaceArea          = Math.PI * srad * srad;
                    double reflectionCoefficent = surfaceArea * sensorSig.Reflectivity;


                    var emmissionDB = emittingEntity.GetDataBlob <SensorProfileDB>();

                    foreach (var emitedItem in emmissionDB.EmittedEMSpectra)
                    {
                        var attenuated         = SensorProcessorTools.AttenuationCalc(emitedItem.Value, distance);//per meter^2
                        var reflectedMagnatude = attenuated * reflectionCoefficent;


                        //debug code:
                        if (emitedItem.Value < 0)
                        {
                            throw new Exception("Source should not be less than 0");
                        }
                        if (attenuated > emitedItem.Value)
                        {
                            throw new Exception("Attenuated value shoudl be less than source");
                        }
                        if (reflectedMagnatude > emitedItem.Value)
                        {
                            var source  = Stringify.Power(emitedItem.Value);
                            var reflec  = Stringify.Power(reflectedMagnatude);
                            var dist    = Stringify.Distance(distance);
                            var surface = Stringify.Distance(surfaceArea);
                            var dif     = Stringify.Power(emitedItem.Value - reflectedMagnatude);
                            //throw new Exception("final magnitude shoudl not be more than source");
                            //TODO: there's got to be a better way of calculating this. for now I'm just going to hack it.

                            reflectedMagnatude = emitedItem.Value * sensorSig.Reflectivity;
                        }
                        if (reflectedMagnatude < 0)
                        {
                            throw new Exception("Final magnitude should not be less than 0");
                        }



                        if (reflectedMagnatude > 0.001) //ignore it if the signal is less than a watt
                        {
                            if (sensorSig.ReflectedEMSpectra.ContainsKey(emitedItem.Key))
                            {
                                sensorSig.ReflectedEMSpectra[emitedItem.Key] = sensorSig.ReflectedEMSpectra[emitedItem.Key] + reflectedMagnatude;
                            }
                            else
                            {
                                sensorSig.ReflectedEMSpectra.Add(emitedItem.Key, reflectedMagnatude);
                            }
                        }
                    }
                }
            }
        }