Beispiel #1
0
        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            SimulatorConfiguration config = new SimulatorConfiguration(true);

            config.Headless = checkBox1.Checked;
            SimulationEngine.GlobalInstancePort.Update(config);
        }
Beispiel #2
0
        private static void Main(string[] args)
        {
            var configuration = SimulatorConfiguration.GetCurrentConfiguration();

            var instrumentationPublisher =
                new SenderInstrumentationManager(instrumentationEnabled: true, installInstrumentation: true)
                .CreatePublisher("Console");

            var carEmulator = new SimulationProfile("Console", 1, instrumentationPublisher, configuration);

            var options = SimulationScenarios
                          .AllScenarios
                          .ToDictionary(
                scenario => "Run " + scenario,
                scenario => (Func <CancellationToken, Task>)(token => carEmulator.RunEmulationAsync(scenario, token)));

            // Add Single shot
            foreach (var scenario in SimulationScenarios.AllScenarios)
            {
                var name = scenario;
                options.Add(
                    "Send 1 message from " + name,
                    token => carEmulator.RunOneMessageEmulationAsync(name, token)
                    );
            }

            ConsoleHost.WithOptions(options, configuration.ScenarioDuration);
        }
Beispiel #3
0
        /// <summary>
        ///  Randomly assign employees to a random office on a random floor, while ensuring that each floor has the correct number of employees.
        ////  All of the other configuration properties should be set before you do this. This should be the last step in setting up the configuration.
        /// </summary>
        /// <param name="configuration">The configuration to modify.</param>
        public static void AssignEmployeesToOffices(SimulatorConfiguration configuration)
        {
            Random random = new Random();

            // get list of all floors that have occupancy. all floor numbers must exist in the dictionary.
            IList <int> unfilledFloors = (from f in configuration.WorkplaceFloors
                                          where configuration.FloorPeopleMapping[f.FloorNumber] > 0
                                          select f.FloorNumber).OrderBy(f => f).ToList();

            foreach (var employee in configuration.Employees)
            {
                int floorNumber = unfilledFloors[random.Next(0, unfilledFloors.Count)];
                int floorId     = configuration.WorkplaceFloors.FirstOrDefault(f => f.FloorNumber == floorNumber).Id;
                IList <SimulatorWorkplaceRoom> officesOnFloor = configuration.WorkplaceRooms.Where(f => f.RoomType == SimulatorDataConstant.WorkplaceRoomType_Office && f.FloorId == floorId).ToList();
                int roomId = officesOnFloor[random.Next(0, officesOnFloor.Count)].Id;
                employee.OfficeId = roomId;
                int peopleOnFloor = (from e in configuration.Employees
                                     join r in configuration.WorkplaceRooms on e.OfficeId equals r.Id
                                     where r.FloorId == floorId
                                     select e).Count();
                if (peopleOnFloor >= configuration.FloorPeopleMapping[floorNumber])
                {
                    unfilledFloors.Remove(floorNumber);
                }
            }
        }
 private void Initialize()
 {
     //Dictionary is always created, but
     //when InstanceConfiguration[] NodesConfiguration is set it could be cleared
     Dictionary  = new SortedList <NodeDescriptorWrapper, InstanceConfiguration>();
     OPCDAClient = new OPCDAClientConfiguration();
     CommServer  = new CommServerConfiguration();
     Simulator   = new SimulatorConfiguration();
 }
Beispiel #5
0
        public static string RequiredRightsList(SimulatorConfiguration config, PlayerInfo player)
        {
            List <string> securityRequests = new List <string>();

            // Security-Settings
            if (player.RequestFileAccess)
            {
                if (!config.AllowFileAccess)
                {
                    securityRequests.Add("- " + Resource.AntPropertiesIoAccess);
                }
            }

            if (player.RequestDatabaseAccess)
            {
                if (!config.AllowDatabaseAccess)
                {
                    securityRequests.Add("- " + Resource.AntPropertiesDbAccess);
                }
            }

            if (player.RequestUserInterfaceAccess)
            {
                if (!config.AllowUserinterfaceAccess)
                {
                    securityRequests.Add("- " + Resource.AntPropertiesUiAccess);
                }
            }

            if (player.RequestReferences)
            {
                if (!config.AllowReferences)
                {
                    securityRequests.Add("- " + Resource.AntPropertiesRefAccess);
                }
            }

            if (player.RequestNetworkAccess)
            {
                if (!config.AllowNetworkAccess)
                {
                    securityRequests.Add("- " + Resource.AntPropertiesNetAccess);
                }
            }

            if (securityRequests.Count > 0)
            {
                return
                    (Resource.SimulationPluginRightsLocked + Environment.NewLine +
                     string.Join(Environment.NewLine, securityRequests.ToArray()));
            }

            return(string.Empty);
        }
Beispiel #6
0
        public static void SetEmployeesBreakroomUse(SimulatorConfiguration configuration, decimal breakroomPercentage)
        {
            // Convert truncates, so we'll round first, but the rounding is not really necessary.
            int breakRoomUserCount = Convert.ToInt32(Math.Round(configuration.Employees.Count * breakroomPercentage, 0, MidpointRounding.AwayFromZero));

            // Just set the first employees in the list. It's still random. We don't know where these employees will end up (necessarily).
            foreach (var item in configuration.Employees)
            {
                item.IsBreakroomUser = breakRoomUserCount > 0 ? true : false;
                breakRoomUserCount--;
            }
        }
Beispiel #7
0
 public EnvironmentDescription(
     int max_steps,
     SimulatorConfiguration simulation_configuration,
     Dictionary <string, Actor> actors,
     Dictionary <string, ConfigurableGameObject> configurables,
     float solved_threshold)
 {
     this.Configurables   = configurables;
     this.Actors          = actors;
     this.MaxSteps        = max_steps;
     this.FrameSkips      = simulation_configuration.FrameSkips;
     this.SolvedThreshold = solved_threshold;
     this.APIVersion      = "0.1.2";
 }
Beispiel #8
0
 public FreeGameSetup()
 {
     Slot1 = new FreeGameSlot();
     Slot2 = new FreeGameSlot();
     Slot3 = new FreeGameSlot();
     Slot4 = new FreeGameSlot();
     Slot5 = new FreeGameSlot();
     Slot6 = new FreeGameSlot();
     Slot7 = new FreeGameSlot();
     Slot8 = new FreeGameSlot();
     SimulatorConfiguration = new SimulatorConfiguration();
     KnownSettingFiles      = new List <string>();
     Reset();
 }
        /// <summary>
        /// Service Start
        /// </summary>
        protected override void Start()
        {
            base.Start();
            _notificationTarget = new SimulationEnginePort();
            EntitySubscribeRequestType req = new EntitySubscribeRequestType();

            req.Name = "MainCamera";
            SimulationEngine.GlobalInstancePort.Subscribe(req, _notificationTarget);

            // Set the Simulator camera view and resolution
            UpdateCameraView view = new UpdateCameraView(new CameraView());

            view.Body.EyePosition = new Vector3(1, 5, 1);
            view.Body.LookAtPoint = new Vector3(0, 0, 0);
            view.Body.XResolution = 640;
            view.Body.YResolution = 480;
            SimulationEngine.GlobalInstancePort.Post(view);

            // get the current simulator configuration
            _defaultConfig = new SimulatorConfiguration(true);

            Activate(Arbiter.Choice(SimulationEngine.GlobalInstancePort.Query(_defaultConfig),
                                    delegate(SimulatorConfiguration config)
            {
                _defaultConfig = config;
                if (_embeddedSimUI != null)
                {
                    WinFormsServicePort.FormInvoke(delegate() { _embeddedSimUI.SetHeadless(config.Headless); });
                }
            },
                                    delegate(W3C.Soap.Fault fault)
            {
            }
                                    ));

            // Add the winform message handler to the interleave
            Activate(Arbiter.Interleave(
                         new TeardownReceiverGroup(),
                         new ExclusiveReceiverGroup
                         (
                             Arbiter.Receive <InsertSimulationEntity>(false, _notificationTarget, InsertEntityNotificationHandlerFirstTime),
                             Arbiter.Receive <FromWinformMsg>(true, _fromWinformPort, OnWinformMessageHandler)
                         ),
                         new ConcurrentReceiverGroup()
                         ));

            // Create the user interface form
            WinFormsServicePort.Post(new RunForm(CreateForm));
        }
        public MainWindowViewModel(IWindowManager windowManager, IMessageService messageService)
        {
            _messageService = messageService;
            _windowManager  = windowManager;
            _applyEvent    += MainWindowViewModel_applyEvent;
            Points          = new ObservableCollection <Point>();
            ISimulatorConfiguration config = new SimulatorConfiguration();

            serviceHost = new ServiceHost(typeof(Simulator.Core.ConfigurationService));
            serviceHost.AddServiceEndpoint(typeof(IConfigurationChange), new NetTcpBinding(), new Uri("net.tcp://localhost:30007/IConfigurationChange"));
            serviceHost.Open();
            _simulator              = new Core.Simulator(config);
            _simulator.updateEvent += Simulator_updateEvent;
            _simulator.Start();
        }
Beispiel #11
0
        static async Task <SimulatorConfiguration> CreateConfiguration(AppSettings appSettings)
        {
            EmployeeDataSource employeeDataSource = new EmployeeDataSource(appSettings.EmployeeApiUri, appSettings.EmployeeApiKey);

            SimulatorConfiguration simConfig = SimulatorConfigManager.GetDefaultConfiguration();

            simConfig.Employees = await GetEmployeesAsync(employeeDataSource, simConfig.FloorPeopleMapping.Sum(f => f.Value));

            // Mark employees who will use break room.
            SimulatorConfigManager.SetEmployeesBreakroomUse(simConfig, .25m);

            // This should always be done last!
            SimulatorConfigManager.AssignEmployeesToOffices(simConfig);

            return(simConfig);
        }
        public override bool OnStart()
        {
            try
            {
                ServicePointManager.DefaultConnectionLimit = int.MaxValue;

                // We obtain the number of instance running this role and pass it along
                // to the simulation profile. Note that we are not supporting runtime
                // changing in the number of instances. Adding new instances at runtime will
                // increase the number of cars beyond the number specified in the configuration.
                var instanceCount = RoleEnvironment.CurrentRoleInstance.Role.Instances.Count;

                // Obtain the simulation configuration and generate a simulation profile.  Set up
                // the cancellation token to terminate the simulation after the configured duration
                var configuration = SimulatorConfiguration.GetCurrentConfiguration();

                _scenario = string.IsNullOrEmpty(configuration.Scenario)
                    ? SimulationScenarios.DefaultScenario()
                    : configuration.Scenario;

                var instrumentationPublisher =
                    new SenderInstrumentationManager(instrumentationEnabled: true, installInstrumentation: false)
                    .CreatePublisher("WaWorkerHost");

                var hostName = ConfigurationHelper.SourceName;

                _simulationProfile = new SimulationProfile(
                    hostName,
                    instanceCount,
                    instrumentationPublisher,
                    configuration);

                _cancellationTokenSource.CancelAfter(configuration.ScenarioDuration);

                Logger.WorkerRoleStartedWith(configuration);
            }
            catch (Exception ex)
            {
                // Hard error on startup, usually configuration or security related
                // Ensure that we log this error, including a direct post to the local
                // event log
                LogHelpers.HandleRoleException(Logger, "OnStart()", ex);
                throw;
            }

            return(base.OnStart());
        }
Beispiel #13
0
        private static void Main(string[] args)
        {
            var observableEventListener = new ObservableEventListener();

            var configuration = SimulatorConfiguration.GetCurrentConfiguration();

            observableEventListener.EnableEvents(ScenarioSimulatorEventSource.Log, configuration.GetLogLevel());

            observableEventListener.LogToConsole();

            var hostName = ConfigurationHelper.SourceName;

            _deviceSimulator = new SimulationProfile(hostName, configuration);

            // check for scenario specified on the command line
            if (args.Length > 0)
            {
                var scenario = args.Contains("/default", StringComparer.OrdinalIgnoreCase)
                    ? SimulationScenarios.DefaultScenario()
                    : args.First(x => !x.StartsWith("/", StringComparison.Ordinal));

                var ct = args.Contains("/webjob", StringComparer.OrdinalIgnoreCase)
                    ? GetWebJobCancellationToken()
                    : CancellationToken.None;

                ProvisionDevicesAsync(ct).Wait();

                _deviceSimulator.RunSimulationAsync(scenario, ct).Wait();

                return;
            }

            var options = new Dictionary <string, Func <CancellationToken, Task> >();

            options.Add("Provision Devices", ProvisionDevicesAsync);

            // no command line arguments, so prompt with a menu.
            foreach (var scenario in SimulationScenarios.AllScenarios)
            {
                options.Add("Run " + scenario, (Func <CancellationToken, Task>)(token => _deviceSimulator.RunSimulationAsync(scenario, token)));
            }

            //options.Add("Deprovision Devices", DeprovisionDevicesAsync);

            Tests.Common.ConsoleHost.RunWithOptionsAsync(options).Wait();
        }
        private static SimulatorConfiguration ParseConfiguration(XElement configEl)
        {
            var config = new SimulatorConfiguration();

            // Find the <MainAction>
            var mainActionEl = configEl.Element(ns + "MainAction");

            if (mainActionEl != null)
            {
                var actionList = ParseActionList(mainActionEl);
                if (actionList.Count != 1)
                {
                    throw new InvalidDataException("<MainAction> must contain exactly one Action element.");
                }
                config.MainAction = actionList[0];
            }

            // Parse quick actions.
            var quickActionElements = configEl.Elements(ns + "QuickAction");
            int i = 0;

            foreach (var el in quickActionElements)
            {
                i++;

                var quickActionName = el.Attribute("title")?.Value ?? $"Quick Action [{i.ToString()}]";
                var quickActionList = ParseActionList(el);
                if (quickActionList.Count != 1)
                {
                    throw new InvalidDataException("<QuickAction> must contain exactly one Action element.");
                }
                config.QuickActions.Add(new SimulatorConfiguration.QuickActionDescriptor()
                {
                    Name   = quickActionName,
                    Action = quickActionList[0]
                });
            }

            if (config.MainAction == null && config.QuickActions.Count == 0)
            {
                throw new ArgumentException("There must be a <MainAction> or at least one <QuickAction> element in the <SimulatorProject>.");
            }

            return(config);
        }
Beispiel #15
0
        /// <summary>Initializes a new instance of the <see cref="SimulatorStateMachine" /> class.</summary>
        /// <param name="timeSource">A source of the current time.</param>
        /// <param name="simulatorConfiguration"></param>
        public SimulatorStateMachine(IClock timeSource, SimulatorConfiguration simulatorConfiguration, ILog logger)
        {
            Contract.Requires(timeSource != null);
            log                 = logger;
            Configuration       = simulatorConfiguration;
            this.timeSource     = timeSource;
            DomeSupportRingOpen = false;
            ShutterStuck        = false;
            HardwareStatus      = new HardwareStatus
            {
                AtHome               = false,
                Coast                = 1,
                CurrentAzimuth       = 0,
                DeadZone             = 3,
                DomeCircumference    = 414,
                DsrSensor            = SensorState.Indeterminate,
                FirmwareVersion      = "V4",
                HomeClockwise        = 16,
                HomeCounterClockwise = 1,
                HomePosition         = 8,
                Humidity             = 255,
                Lx200Azimuth         = 999,
                Offset               = 0,
                ShutterSensor        = SensorState.Indeterminate,
                Slaved               = false,
                Snow = 255,
                // For weather items, 255 means no data
                Temperature   = 255,
                TimeStamp     = timeSource.GetCurrentTime(),
                UserPins      = 0,
                WeatherAge    = 128,
                WindDirection = 255,
                WindPeak      = 255,
                WindSpeed     = 255
            };

            SetAzimuthDependentSensorsAndStates();

            // Set the starting state and begin receiving.
            SimulatorState.Transition(new StateStartup(this));
            var receiveObservable = receiveSubject.AsObservable();

            receiveSubscription = receiveObservable.Subscribe(InputStimulus, EndOfSimulation);
        }
Beispiel #16
0
        public override bool OnStart()
        {
            try
            {
                var configuration = SimulatorConfiguration.GetCurrentConfiguration();
                var hostName      = ConfigurationHelper.SourceName;
                _deviceSimulator = new SimulationProfile(hostName, configuration);

                _deviceSimulator.ProvisionDevices(true);

                return(base.OnStart());
            }
            catch (Exception ex)
            {
                Trace.TraceError(ex.ToString());

                throw;
            }
        }
Beispiel #17
0
        public static bool LockedRights(SimulatorConfiguration config, PlayerInfo player)
        {
            // Global check. If the player needs no rights there is no way to lock
            if (!RequestRights(player))
            {
                return(false);
            }

            // Fileaccess
            if (player.RequestFileAccess && !config.AllowFileAccess)
            {
                return(true);
            }

            // Database
            if (player.RequestDatabaseAccess && !config.AllowDatabaseAccess)
            {
                return(true);
            }

            // Refs
            if (player.RequestReferences && !config.AllowReferences)
            {
                return(true);
            }

            // Userinterfaces
            if (player.RequestUserInterfaceAccess && !config.AllowUserinterfaceAccess)
            {
                return(true);
            }

            // Network
            if (player.RequestNetworkAccess && !config.AllowNetworkAccess)
            {
                return(true);
            }

            // No locks
            return(false);
        }
        public void Start()
        {
            if (State == PluginState.Ready)
            {
                // Create new simulator
                Random rand = new Random();
                SimulatorConfiguration config = new SimulatorConfiguration()
                {
                    MapInitialValue = seed = rand.Next(0, int.MaxValue),
                };
                config.Teams.Add(new TeamInfo(Guid.NewGuid(), new List <PlayerInfo> {
                    setup.PlayerInfo
                }));

                sim             = new Simulator(config);
                control.Enabled = false;
            }

            if (State == PluginState.Paused)
            {
                paused = false;
            }
        }
        public void Start()
        {
            if (State == PluginState.Ready)
            {
                // Create new simulator
                SimulatorConfiguration config = setup.SimulatorConfiguration.Clone() as SimulatorConfiguration;
                FreeGameSlot[]         slots  = new[] {
                    setup.Slot1, setup.Slot2,
                    setup.Slot3, setup.Slot4,
                    setup.Slot5, setup.Slot6,
                    setup.Slot7, setup.Slot8
                };

                for (int i = 0; i < 8; i++)
                {
                    var hits = slots.Where(s => s.Team == i + 1 && s.PlayerInfo != null);
                    if (hits.Count() > 0)
                    {
                        var team = new TeamInfo()
                        {
                            Guid = Guid.NewGuid(), Name = "Team " + (i + 1)
                        };
                        team.Player.AddRange(hits.Select(p => p.PlayerInfo));
                        config.Teams.Add(team);
                    }
                }

                sim             = new Simulator(config);
                control.Enabled = false;
            }

            if (State == PluginState.Paused)
            {
                paused = false;
            }
        }
Beispiel #20
0
 public static void UpdateConfiguration(SimulatorConfiguration configuration)
 {
     Configuration.Storage.Load(configuration);
 }
Beispiel #21
0
 private void checkBoxHideUI_CheckedChanged(object sender, EventArgs e)
 {
     SimulatorConfiguration config = new SimulatorConfiguration(true);
     config.Headless = checkBoxHideUI.Checked;
     SimulationEngine.GlobalInstancePort.Update(config);
 }
        public SimulatorConfiguration NormalConfiguration()
        {
            SimulatorConfiguration configuration = new SimulatorConfiguration();

            configuration.ServicesConfiguration = new ServicesConfiguration();

            DeviceServiceCapabilities deviceServiceCapabilities = new DeviceServiceCapabilities();

            deviceServiceCapabilities.Network = new NetworkCapabilities();
            deviceServiceCapabilities.Network.Dot11Configuration          = true;
            deviceServiceCapabilities.Network.Dot11ConfigurationSpecified = true;
            deviceServiceCapabilities.Network.DynDNS = true;
            deviceServiceCapabilities.Network.Dot11ConfigurationSpecified = true;
            deviceServiceCapabilities.Network.HostnameFromDHCP            = true;
            deviceServiceCapabilities.Network.HostnameFromDHCPSpecified   = true;
            deviceServiceCapabilities.Network.IPFilter            = false;
            deviceServiceCapabilities.Network.IPFilterSpecified   = true;
            deviceServiceCapabilities.Network.IPVersion6          = false;
            deviceServiceCapabilities.Network.IPVersion6Specified = true;
            deviceServiceCapabilities.Network.NTP                        = 1;
            deviceServiceCapabilities.Network.NTPSpecified               = true;
            deviceServiceCapabilities.Network.ZeroConfiguration          = false;
            deviceServiceCapabilities.Network.ZeroConfigurationSpecified = true;

            deviceServiceCapabilities.Security = new SecurityCapabilities();

            deviceServiceCapabilities.System = new SystemCapabilities();
            deviceServiceCapabilities.System.HttpSystemBackup          = true;
            deviceServiceCapabilities.System.HttpSystemBackupSpecified = true;
            deviceServiceCapabilities.System.SystemLogging             = true;
            deviceServiceCapabilities.System.SystemLoggingSpecified    = true;

            configuration.ServicesConfiguration.DeviceServiceCapabilities = deviceServiceCapabilities;
            configuration.ServicesConfiguration.CreateOldStyleCapabilities();


            configuration.DeviceInformation                 = new DeviceInformation();
            configuration.DeviceInformation.Brand           = "ONVIF";
            configuration.DeviceInformation.FirmwareVersion = "1.0";
            configuration.DeviceInformation.HardwareId      = "12345";
            configuration.DeviceInformation.Model           = "Ideal PACS Device";
            configuration.DeviceInformation.SerialNumber    = "123456789";

            AccessControlServiceCapabilities accessControlServiceCapabilities = new AccessControlServiceCapabilities();

            accessControlServiceCapabilities.DisableAccessPoint          = true;
            accessControlServiceCapabilities.DisableAccessPointSpecified = true;
            accessControlServiceCapabilities.MaxLimit = 10;

            configuration.ServicesConfiguration.AccessControlCapabilities = accessControlServiceCapabilities;

            DoorControlServiceCapabilities doorControlServiceCapabilities = new DoorControlServiceCapabilities();

            doorControlServiceCapabilities.MaxLimit = 3;
            configuration.ServicesConfiguration.DoorServiceCapabilities = doorControlServiceCapabilities;

            configuration.ServicesConfiguration.InitializeXmlElements();

            List <Service> services = new List <Service>();

            {
                Service device = new Service();
                device.Namespace     = Common.Definitions.OnvifService.DEVICE;
                device.Version       = new OnvifVersion();
                device.Version.Major = 2;
                device.Version.Minor = 2;
                services.Add(device);
            }
            {
                Service events = new Service();
                events.Namespace     = Common.Definitions.OnvifService.EVENTS;
                events.Version       = new OnvifVersion();
                events.Version.Major = 2;
                events.Version.Minor = 2;
                services.Add(events);
            }

            {
                Service pacs = new Service();
                pacs.Namespace     = Common.Definitions.OnvifService.ACCESSCONTROL;
                pacs.Version       = new OnvifVersion();
                pacs.Version.Major = 2;
                pacs.Version.Minor = 2;
                services.Add(pacs);
            }
            {
                Service doorControl = new Service();
                doorControl.Namespace     = Common.Definitions.OnvifService.DOORCONTROL;
                doorControl.Version       = new OnvifVersion();
                doorControl.Version.Major = 2;
                doorControl.Version.Minor = 2;
                services.Add(doorControl);
            }

            configuration.ServicesConfiguration.Services = services;

            List <Scope> scopes = new List <Scope>();

            scopes.Add(new Scope()
            {
                ScopeItem = "onvif://www.onvif.org/profile/profilec"
            });
            scopes.Add(new Scope()
            {
                ScopeItem = "onvif://www.onvif.org/name/Simulator"
            });
            scopes.Add(new Scope()
            {
                ScopeItem = "onvif://www.onvif.org/hardware/PC"
            });
            scopes.Add(new Scope()
            {
                ScopeItem = "onvif://www.onvif.org/location/scope1"
            });

            configuration.Scopes = scopes;


            #region PACS initialization
            configuration.PacsConfiguration = new PacsConfiguration();

            {
                AccessPointInfo info = new AccessPointInfo();
                info.token        = "tokenAccessPoint1";
                info.Name         = "AccessPoint1 Name";
                info.Description  = "AccessPoint1 Description";
                info.AreaFrom     = "tokenArea1";
                info.AreaTo       = "tokenArea2";
                info.Enabled      = true;
                info.Type         = "tdc:Door";
                info.Entity       = "tokenDoor1";
                info.Capabilities = new AccessPointCapabilities();
                info.Capabilities.DisableAccessPoint = true;
                configuration.PacsConfiguration.AccessPointInfoList.Add(info);
            }

            {
                AccessPointInfo info = new AccessPointInfo();
                info.token        = "tokenAccessPoint2";
                info.Name         = "AccessPoint2 Name";
                info.Description  = "AccessPoint2 Description";
                info.Enabled      = true;
                info.Type         = "tdc:Door";
                info.Entity       = "tokenDoor1";
                info.Capabilities = new AccessPointCapabilities();
                info.Capabilities.DisableAccessPoint = false;
                configuration.PacsConfiguration.AccessPointInfoList.Add(info);
            }

            {
                AreaInfo info = new AreaInfo();
                info.token       = "tokenArea1";
                info.Name        = "Area1 Name";
                info.Description = "Area1 Description";
                configuration.PacsConfiguration.AreaInfoList.Add(info);
            }
            {
                AreaInfo info = new AreaInfo();
                info.token       = "tokenArea2";
                info.Name        = "Area2 Name";
                info.Description = "Area2Description";
                configuration.PacsConfiguration.AreaInfoList.Add(info);
            }

            {
                DoorInfo info = new DoorInfo();

                info.token       = "tokenDoor1";
                info.Name        = "Door1 Name";
                info.Description = "Door1 Description";
                DoorCapabilities value = new DoorCapabilities();
                value.Block           = true;
                value.DoubleLock      = true;
                value.Lock            = true;
                value.LockDown        = true;
                value.LockOpen        = true;
                value.MomentaryAccess = true;
                value.Unlock          = true;
                info.Capabilities     = value;
                configuration.PacsConfiguration.DoorInfoList.Add(info);
            }

            {
                DoorInfo info = new DoorInfo();

                info.token       = "tokenDoor2";
                info.Name        = "Door2 Name";
                info.Description = "Door2 Description";

                DoorCapabilities value = new DoorCapabilities();
                value.Block           = false;
                value.DoubleLock      = false;
                value.Lock            = false;
                value.LockDown        = false;
                value.LockOpen        = false;
                value.MomentaryAccess = false;
                value.Unlock          = false;

                info.Capabilities = value;

                configuration.PacsConfiguration.DoorInfoList.Add(info);
            }

            foreach (DoorInfo door in configuration.PacsConfiguration.DoorInfoList)
            {
                configuration.PacsConfiguration.DoorCapabilitiesList.Add(door.token, door.Capabilities);
                configuration.PacsConfiguration.DoorAccessList.Add(door.token, 0);
                configuration.PacsConfiguration.DoorAccessPreviousStateList.Add(door.token, DoorModeType.Unknown);
            }

            {
                DoorState value = new DoorState();

                value.DoorAlarm                      = DoorAlarmStateType.Normal;
                value.DoorDoubleLockMonitor          = DoorLockMonitorStateType.Locked;
                value.DoorDoubleLockMonitorSpecified = true;
                value.DoorLockMonitor                = DoorLockMonitorStateType.Locked;
                value.DoorMode    = DoorModeType.Locked;
                value.DoorMonitor = DoorMonitorStateType.Closed;
                value.DoorTamper  = DoorTamperStateType.NotInTamper;

                configuration.PacsConfiguration.DoorStateList.Add("tokenDoor1", value);
            }

            {
                DoorState value = new DoorState();

                value.DoorAlarm                      = DoorAlarmStateType.Normal;
                value.DoorDoubleLockMonitor          = DoorLockMonitorStateType.NotSupported;
                value.DoorDoubleLockMonitorSpecified = false;
                value.DoorLockMonitor                = DoorLockMonitorStateType.NotSupported;
                value.DoorMode    = DoorModeType.Locked;
                value.DoorMonitor = DoorMonitorStateType.NotSupported;
                value.DoorTamper  = DoorTamperStateType.NotSupported;

                configuration.PacsConfiguration.DoorStateList.Add("tokenDoor2", value);
            }

            #endregion

            return(configuration);
        }
Beispiel #23
0
        public static SimulatorConfiguration GetDefaultConfiguration()
        {
            SimulatorConfiguration configuration = new SimulatorConfiguration();

            // Simulation will collect data every one hour.
            configuration.DataInterval = new TimeSpan(1, 0, 0);

            // Set workday start/end time
            configuration.StartOfWorkday = new TimeSpan(8, 0, 0);
            configuration.EndOfWorkday   = new TimeSpan(17, 0, 0);

            // Set start of simulation to the current date.
            // Begin with start of workday on first day and end at end of workday on last day.
            configuration.StartDateTime = GetDateBoundary(DateTime.Now, configuration.StartOfWorkday);

            // Four month time span and set the time to the end of the work day.
            configuration.EndDateTime = GetDateBoundary(configuration.StartDateTime.AddMonths(4), configuration.EndOfWorkday);

            // Number of people to be sick initially.
            configuration.InitialSickCount = 1;

            // Set initial infected stage of the sick people.
            configuration.InitialSickStage = SimulatorDataConstant.InfectionStage_Infected;

            // Set meeting time span to 1 hour.
            configuration.MeetingTimeSpan = new TimeSpan(1, 0, 0);

            // Set min and max meeting attendance numbers.
            configuration.MinMeetingAttendance = 4;
            configuration.MaxMeetingAttendance = 8;

            // Set the break time hours to 12-1pm
            configuration.BreakTimeOfDay = new TimeSpan(12, 0, 0);
            configuration.BreakTimeSpan  = new TimeSpan(1, 0, 0);

            // Get default workplace, virus, and virus stages.
            configuration.Workplace   = GetDefaultWorkplace();
            configuration.Virus       = GetDefaultVirus();
            configuration.VirusStages = GetDefaultVirusStages(configuration.Virus.Id);

            // Just set default workplace floors and people per floor.
            configuration.FloorPeopleMapping = GetDefaultFloorPeopleMapping();
            configuration.WorkplaceFloors    = GetWorkplaceFloors(configuration.Workplace.Id, configuration.FloorPeopleMapping.Count);

            // add all the rooms as requested
            AddRoomsToFloor(configuration.WorkplaceRooms, configuration.WorkplaceFloors.First(f => f.FloorNumber == 1).Id, 2, SimulatorDataConstant.WorkplaceRoomType_Office);

            AddRoomsToFloor(configuration.WorkplaceRooms, configuration.WorkplaceFloors.First(f => f.FloorNumber == 2).Id, 12, SimulatorDataConstant.WorkplaceRoomType_Office);
            AddRoomsToFloor(configuration.WorkplaceRooms, configuration.WorkplaceFloors.First(f => f.FloorNumber == 2).Id, 1, SimulatorDataConstant.WorkplaceRoomType_Breakroom);
            AddRoomsToFloor(configuration.WorkplaceRooms, configuration.WorkplaceFloors.First(f => f.FloorNumber == 2).Id, 2, SimulatorDataConstant.WorkplaceRoomType_Meeting);

            AddRoomsToFloor(configuration.WorkplaceRooms, configuration.WorkplaceFloors.First(f => f.FloorNumber == 3).Id, 15, SimulatorDataConstant.WorkplaceRoomType_Office);
            AddRoomsToFloor(configuration.WorkplaceRooms, configuration.WorkplaceFloors.First(f => f.FloorNumber == 3).Id, 1, SimulatorDataConstant.WorkplaceRoomType_Breakroom);
            AddRoomsToFloor(configuration.WorkplaceRooms, configuration.WorkplaceFloors.First(f => f.FloorNumber == 3).Id, 2, SimulatorDataConstant.WorkplaceRoomType_Meeting);

            AddRoomsToFloor(configuration.WorkplaceRooms, configuration.WorkplaceFloors.First(f => f.FloorNumber == 4).Id, 5, SimulatorDataConstant.WorkplaceRoomType_Office);
            AddRoomsToFloor(configuration.WorkplaceRooms, configuration.WorkplaceFloors.First(f => f.FloorNumber == 4).Id, 1, SimulatorDataConstant.WorkplaceRoomType_Breakroom);
            AddRoomsToFloor(configuration.WorkplaceRooms, configuration.WorkplaceFloors.First(f => f.FloorNumber == 4).Id, 3, SimulatorDataConstant.WorkplaceRoomType_Meeting);

            AddRoomsToFloor(configuration.WorkplaceRooms, configuration.WorkplaceFloors.First(f => f.FloorNumber == 5).Id, 50, SimulatorDataConstant.WorkplaceRoomType_Office);
            AddRoomsToFloor(configuration.WorkplaceRooms, configuration.WorkplaceFloors.First(f => f.FloorNumber == 5).Id, 1, SimulatorDataConstant.WorkplaceRoomType_Breakroom);
            AddRoomsToFloor(configuration.WorkplaceRooms, configuration.WorkplaceFloors.First(f => f.FloorNumber == 5).Id, 2, SimulatorDataConstant.WorkplaceRoomType_Meeting);

            // Just leave empty for now.
            configuration.Employees = new List <SimulatorEmployee>();

            configuration.CanGetSickInOffice = false;

            return(configuration);
        }
        /// <summary>
        /// Entry Point for the Dashboard Service
        /// </summary>
        protected override void Start()
        {
            // TT - Added code to create a default State if no
            // config file exists
            if (_state == null)
            {
                _state = new StateType();
                _state.Log = false;
                _state.LogFile = "";
                _state.Machine = "";
                _state.Port = 0;
            }

            // TT - Version 2 - The options "bag"
            // This is tacky, but we need to set the default values
            // in case there is no existing config.xml file
            if (_state.Options == null)
            {
                _state.Options = new GUIOptions();
                _state.Options.DeadZoneX = 80;
                _state.Options.DeadZoneY = 80;
                _state.Options.TranslateScaleFactor = 1.0;
                _state.Options.RotateScaleFactor = 0.5;
                _state.Options.ShowLRF = false;
                _state.Options.ShowArm = false;
                _state.Options.DisplayMap = false;

                // Raul - Sept 2007
                _state.Options.DisplaySonarMap = false;

                // Updated in later versions with more options
                // These values are in mm
                _state.Options.RobotWidth = 300;
                _state.Options.MaxLRFRange = 8192;
                _state.Options.DriveDistance = 300;
                // Speed is in mm/sec???
                _state.Options.MotionSpeed = 100;
                // Angle is in degrees
                _state.Options.RotateAngle = 45;
                // Camera update interval in milliseconds
                // Note that this is only required for the
                // simulated webcam because it does not provide
                // updates when you subscribe
                _state.Options.CameraInterval = 250;

                // Raul - Version 9
                _state.Options.SonarRange = 4000;
                _state.Options.SonarTransducerAngularRange = 15.0f;

                // Raul - Sonar transducer positions.
                // This is only valid for a single sonar array of 8 transducers!!
                _state.Options.SonarRadians = new double[8];
                // Orientations of the P3DX frontal sonar transducers
                _state.Options.SonarRadians[0] = (Math.PI * 90) / 180;
                _state.Options.SonarRadians[1] = (Math.PI * 50) / 180;
                _state.Options.SonarRadians[2] = (Math.PI * 30) / 180;
                _state.Options.SonarRadians[3] = (Math.PI * 10) / 180;
                _state.Options.SonarRadians[4] = -(Math.PI * 10) / 180;
                _state.Options.SonarRadians[5] = -(Math.PI * 30) / 180;
                _state.Options.SonarRadians[6] = -(Math.PI * 50) / 180;
                _state.Options.SonarRadians[7] = -(Math.PI * 90) / 180;

            }
            if (_state.Options.CameraInterval < 100)
                _state.Options.CameraInterval = 100;

            // Handlers that need write or exclusive access to state go under
            // the exclusive group. Handlers that need read or shared access, and can be
            // concurrent to other readers, go to the concurrent group.
            // Other internal ports can be included in interleave so you can coordinate
            // intermediate computation with top level handlers.
            Activate(Arbiter.Interleave(
                new TeardownReceiverGroup
                (
                    Arbiter.Receive<DsspDefaultDrop>(false, _mainPort, DropHandler)
                ),
                new ExclusiveReceiverGroup
                (
                    Arbiter.ReceiveWithIterator<Replace>(true, _mainPort, ReplaceHandler),
                    Arbiter.ReceiveWithIteratorFromPortSet<OnLoad>(true, _eventsPort, OnLoadHandler),
                    Arbiter.ReceiveFromPortSet<OnClosed>(true, _eventsPort, OnClosedHandler),
                    Arbiter.ReceiveWithIteratorFromPortSet<OnChangeJoystick>(true, _eventsPort, OnChangeJoystickHandler),
                    Arbiter.ReceiveFromPortSet<OnLogSetting>(true, _eventsPort, OnLogSettingHandler),
                    // TT - Added this handler for Connection parameters
                    Arbiter.ReceiveFromPortSet<OnConnectSetting>(true, _eventsPort, OnConnectSettingHandler),
                    // TT - Added this handler for Options
                    Arbiter.ReceiveFromPortSet<OnOptionSettings>(true, _eventsPort, OnOptionSettingsHandler),

                    
                    Arbiter.ReceiveWithIterator<cam.UpdateFrame>(true, _webCamNotify, CameraUpdateFrameHandler),
                    
                    Arbiter.ReceiveWithIteratorFromPortSet<OnConnectPanTilt>(true, _eventsPort, OnConnectPanTiltHandler)
                    

                    // Raul - Sept. Added this handler to disconnect cam - doesn't work yet
                    // Arbiter.ReceiveFromPortSet<OnDisconnectWebCam>(true, _eventsPort, OnDisconnectWebCamHandler),
                    // Raul - Handler for Cera Vision
                    // Arbiter.ReceiveWithIteratorFromPortSet<OnConnectVision>(true, _eventsPort, OnConnectVisionHandler),
                    // Arbiter.ReceiveFromPortSet<OnDisconnectVision>(true, _eventsPort, OnDisconnectVisionHandler)                   
                ),
                new ConcurrentReceiverGroup
                (
                    Arbiter.Receive<DsspDefaultLookup>(true,_mainPort,DefaultLookupHandler),
                    Arbiter.ReceiveWithIterator<Get>(true, _mainPort, GetHandler),
                    
                    // TT Dec-2006 - Updated for V1.0
                    Arbiter.ReceiveWithIterator<game.Replace>(true, _gameControllerNotify, JoystickReplaceHandler),
                    Arbiter.ReceiveWithIterator<sicklrf.Replace>(true, _laserNotify, OnLaserReplaceHandler),
                    

                    Arbiter.ReceiveWithIteratorFromPortSet<OnConnect>(true, _eventsPort, OnConnectHandler),
                    
                    Arbiter.ReceiveWithIterator<drive.Update>(true, _driveNotify, OnDriveUpdateNotificationHandler),
                    Arbiter.ReceiveWithIteratorFromPortSet<OnConnectMotor>(true, _eventsPort, OnConnectMotorHandler),
                    Arbiter.ReceiveWithIteratorFromPortSet<OnMove>(true, _eventsPort, OnMoveHandler),
                    
                    // TT May-2007 - Added Rotate and Translate
                    Arbiter.ReceiveWithIteratorFromPortSet<OnRotate>(true, _eventsPort, OnRotateHandler),
                    Arbiter.ReceiveWithIteratorFromPortSet<OnTranslate>(true, _eventsPort, OnTranslateHandler),
                    Arbiter.ReceiveWithIteratorFromPortSet<OnEStop>(true, _eventsPort, OnEStopHandler),
                    
                    // Raul - LRF
                    Arbiter.ReceiveWithIteratorFromPortSet<OnStartService>(true, _eventsPort, OnStartServiceHandler),
                    Arbiter.ReceiveWithIteratorFromPortSet<OnConnectSickLRF>(true, _eventsPort, OnConnectSickLRFHandler),
                    Arbiter.ReceiveFromPortSet<OnDisconnectSickLRF>(true, _eventsPort, OnDisconnectSickLRFHandler),

                    // Raul - Sonar 
                    Arbiter.ReceiveWithIteratorFromPortSet<OnConnectSonar>(true, _eventsPort, OnConnectSonarHandler),
                    Arbiter.ReceiveFromPortSet<OnDisconnectSonar>(true, _eventsPort, OnDisconnectSonarHandler),
                    Arbiter.ReceiveWithIterator<pxsonar.Replace>(true, _sonarNotify, OnSonarReplaceHandler),

                    // Raul - GPS
                    Arbiter.ReceiveWithIteratorFromPortSet<OnConnectGPS>(true, _eventsPort, OnConnectGPSHandler),
                    Arbiter.ReceiveFromPortSet<OnDisconnectGPS>(true, _eventsPort, OnDisconnectGPSHandler),
                    Arbiter.ReceiveWithIterator<pxGPS.Replace>(true, _gpsNotify, OnGPSReplaceHandler),

                    // Raul - Bumpers
                    Arbiter.ReceiveWithIteratorFromPortSet<OnConnectBumpers>(true, _eventsPort, OnConnectBumpersHandler),
                    Arbiter.ReceiveFromPortSet<OnDisconnectBumpers>(true, _eventsPort, OnDisconnectBumpersHandler),
                    Arbiter.ReceiveWithIterator<pxbumper.Replace>(true, _bumpersNotify, OnBumpersReplaceHandler),
                    Arbiter.ReceiveWithIterator<pxbumper.Update>(true, _bumpersNotify, OnBumperUpdateHandler),

                    Arbiter.ReceiveWithIteratorFromPortSet<OnConnectWebCam>(true, _eventsPort, OnConnectWebCamHandler),
                    Arbiter.ReceiveWithIteratorFromPortSet<OnPTMove>(true, _eventsPort, OnPanTiltMoveHandler)
                )
            ));

            DirectoryInsert();

            _notificationTarget = new SimulationEnginePort();
            EntitySubscribeRequestType req = new EntitySubscribeRequestType();
            req.Name = "PursuitCam";
            SimulationEngine.GlobalInstancePort.Subscribe(req, _notificationTarget);

            // Set the Simulator camera view and resolution
            UpdateCameraView view = new UpdateCameraView(new CameraView());
            view.Body.EyePosition = new Vector3(1, 5, 1);
            view.Body.LookAtPoint = new Vector3(0, 0, 0);
            view.Body.XResolution = 640;
            view.Body.YResolution = 480;
            SimulationEngine.GlobalInstancePort.Post(view);

            // get the current simulator configuration
            _defaultConfig = new SimulatorConfiguration(true);

            Activate(Arbiter.Choice(SimulationEngine.GlobalInstancePort.Query(_defaultConfig),
                delegate(SimulatorConfiguration config)
                {
                    _defaultConfig = config;
                    if (_driveControl != null)
                        WinFormsServicePort.FormInvoke(delegate() { _driveControl.SetHeadless(config.Headless); });
                },
                delegate(W3C.Soap.Fault fault)
                {
                }
            ));

            // Add the winform message handler to the interleave
            Activate(Arbiter.Interleave(
                new TeardownReceiverGroup(),
                new ExclusiveReceiverGroup
                (
                    Arbiter.Receive<InsertSimulationEntity>(false, _notificationTarget, InsertEntityNotificationHandlerFirstTime),
                    Arbiter.ReceiveFromPortSet<OnSimulLoaded>(true, _eventsPort, OnSimulLoadedHandler),
                    Arbiter.ReceiveFromPortSet<OnSimulDrag>(true, _eventsPort, OnSimulDragHandler),
                    Arbiter.ReceiveFromPortSet<OnSimulZoom>(true, _eventsPort, OnSimulZoomHandler)
                ),
                new ConcurrentReceiverGroup()
            ));


            WinFormsServicePort.Post(new RunForm(CreateForm));
        }
Beispiel #25
0
 public static void Load(SimulatorConfiguration configuration)
 {
     _instance = configuration;
 }
        private SimulatorEngine GetSimulatorEngineInstance()
        {
            SimulatorConfiguration sc = SimulatorConfigManager.GetDefaultConfiguration();

            return(new SimulatorEngine(sc));
        }
Beispiel #27
0
        public RightsRequest(SimulatorConfiguration config, PlayerInfoFilename player)
        {
            playerInfo = player;
            InitializeComponent();
            yesButton.Enabled = acceptCheckBox.Checked;

            colonyLabel.Text = player.ColonyName;
            authorLabel.Text =
                string.Format(Resource.AntPropertiesAuthorFormat, player.FirstName, player.LastName);

            if (player.RequestFileAccess)
            {
                if (config.AllowFileAccess)
                {
                    rightsListView.Items.Add(Resource.AntPropertiesIoAccess, open);
                }
                else
                {
                    locked = true;
                    rightsListView.Items.Add(Resource.AntPropertiesIoAccess, closed);
                }
            }
            if (player.RequestDatabaseAccess)
            {
                if (config.AllowDatabaseAccess)
                {
                    rightsListView.Items.Add(Resource.AntPropertiesDbAccess, open);
                }
                else
                {
                    locked = true;
                    rightsListView.Items.Add(Resource.AntPropertiesDbAccess, closed);
                }
            }
            if (player.RequestReferences)
            {
                if (config.AllowReferences)
                {
                    rightsListView.Items.Add(Resource.AntPropertiesRefAccess, open);
                }
                else
                {
                    locked = true;
                    rightsListView.Items.Add(Resource.AntPropertiesRefAccess, closed);
                }
            }
            if (player.RequestUserInterfaceAccess)
            {
                if (config.AllowUserinterfaceAccess)
                {
                    rightsListView.Items.Add(Resource.AntPropertiesUiAccess, open);
                }
                else
                {
                    locked = true;
                    rightsListView.Items.Add(Resource.AntPropertiesUiAccess, closed);
                }
            }
            if (player.RequestNetworkAccess)
            {
                if (config.AllowNetworkAccess)
                {
                    rightsListView.Items.Add(Resource.AntPropertiesNetAccess, open);
                }
                else
                {
                    locked = true;
                    rightsListView.Items.Add(Resource.AntPropertiesNetAccess, closed);
                }
            }

            if (locked)
            {
                sorryPanel.Visible  = true;
                acceptPanel.Visible = false;
                AcceptButton        = closeButton;
                CancelButton        = closeButton;
            }
            else
            {
                sorryPanel.Visible  = false;
                acceptPanel.Visible = true;
                AcceptButton        = yesButton;
                CancelButton        = noButton;
            }
        }