コード例 #1
0
ファイル: RobotIOPanel.cs プロジェクト: xiaodelea/synthesis
 /// <summary>
 /// Prompt user to download the log file
 /// </summary>
 public void DownloadLog()
 {
     if (EmulationWarnings.CheckRequirement(EmulationWarnings.Requirement.VMConnected))
     {
         EmulatorManager.FetchLogFile();
     }
 }
コード例 #2
0
 public override void Update()
 {
     if (loadingPanel.activeSelf)
     {
         Text t = loadingPanel.transform.Find("Text").GetComponent <Text>();
         if (!EmulatorManager.IsVMConnected())
         {
             uploadFinished = true;
             uploadSuccess  = false;
         }
         if (uploadFinished)
         {
             if (!uploadSuccess)
             {
                 UserMessageManager.Dispatch("Failed to upload new user program", EmulationWarnings.WARNING_DURATION);
             }
             t.text = "Loading...";
             loadingPanel.SetActive(false);
             uploadFinished = false;
         }
         else
         {
             if (Time.unscaledTime >= lastAdditionalDot + 0.75)
             {
                 dotCount = (dotCount + 1) % 4;
                 t.text   = "Loading";
                 for (int i = 0; i < dotCount; i++)
                 {
                     t.text += ".";
                 }
                 lastAdditionalDot = Time.unscaledTime;
             }
         }
     }
 }
コード例 #3
0
        public MainWindow()
        {
            InitializeComponent();

            emuMgr              = EmulatorManager.Instance;
            romMgr              = RomManager.Instance;
            romMgr.NewRomAdded += RomMgr_NewRomAdded;

            UpdateEmulatorList();
        }
コード例 #4
0
ファイル: RobotIOPanel.cs プロジェクト: xiaodelea/synthesis
 /// <summary>
 /// Empty stream buffer into UI
 /// </summary>
 public static void Update()
 {
     if (EmulatorManager.IsTryingToRunRobotCode() && !EmulatorManager.IsRobotCodeRestarting() && !printStreamOpen) // Start stream if needed
     {
         Task.Factory.StartNew(OpenPrintStream, TaskCreationOptions.LongRunning);
     }
     while (newPrintQueue.Count > 0)
     {
         AddLine(newPrintQueue.Dequeue());
     }
 }
コード例 #5
0
        public CheatsPage()
        {
            this.InitializeComponent();

            this.manager               = EmulatorManager.Current;
            this.storage               = StorageManager.Current;
            this.resources             = new ResourceLoader();
            this.validator             = this.manager.Emulator.CheatValidator;
            this.messageService        = new UWPMessageService(this.Dispatcher);
            this.cheatData             = new ObservableCollection <CheatDataWrapper>();
            this.cheatView.ItemsSource = this.cheatData;
        }
コード例 #6
0
 public void Update()
 {
     if (lastGameSpecificMessageFocused != gameSpecificMessage.isFocused)
     {
         InputControl.freeze            = gameSpecificMessage.isFocused;
         lastGameSpecificMessageFocused = gameSpecificMessage.isFocused;
     }
     VMConnectionImage.sprite       = EmulatorManager.IsVMConnected() ? StatusGood : StatusBad;
     robotCodeUploadedImage.sprite  = EmulatorManager.IsFRCUserProgramPresent() ? StatusGood : StatusBad;
     robotCodeRunningImage.sprite   = EmulatorManager.IsRunningRobotCode() ? StatusGood : StatusBad;
     robotCodeConnectedImage.sprite = EmulatorNetworkConnection.Instance.IsConnected() ? StatusGood : StatusBad;
 }
コード例 #7
0
        public async void RestartRobotCode()
        {
            if (EmulationWarnings.CheckRequirement(EmulationWarnings.Requirement.UserProgramPresent) && EmulationWarnings.CheckRequirement(EmulationWarnings.Requirement.UserProgramNotRestarting))
            {
                bool success = await EmulatorManager.RestartRobotCode();

                if (!success)
                {
                    UserMessageManager.Dispatch("Failed to restart user program", EmulationWarnings.WARNING_DURATION);
                }
            }
        }
コード例 #8
0
        public ControllerOverlayPage()
        {
            this.InitializeComponent();
            var app = (App.Current as App);

            this.resources                           = new ResourceLoader();
            this.msgService                          = new UWPMessageService(this.Dispatcher);
            this.settings                            = app.Settings;
            this.keyDownHandler                      = new KeyEventHandler(handleKeyDown);
            this.pointerHandler                      = new PointerEventHandler(handlePointerPressed);
            this.pointerMoveHandler                  = new PointerEventHandler(handlePointerMoved);
            this.pointerReleaseHandler               = new TypedEventHandler <CoreWindow, PointerEventArgs>(handlePointerReleased);
            this.paneOpenHandler                     = new CallbackDelegate(handlePaneOpening);
            this.manualSnapshotButton.DataContext    = this.settings;
            this.customizeVPadButton.DataContext     = this.settings;
            this.controllerScaleSlider.DataContext   = this.settings;
            this.controllerOpacitySlider.DataContext = this.settings;
            this.controllerStyleCombobox.DataContext = this.settings;
            this.fpsPanel.DataContext                = this.settings;
            if (app.MainPage == null)
            {
                app.MainPageCreated += (p) =>
                {
                    this.manager = EmulatorManager.Current;
                    this.manager.MovedToForeground();
                    this.manager.Emulator.RenderComponent.FrameRateChanged += this.UpdateFPS;
                    SetSaveSlotContext(this.manager);
                    RegisterEvents(app);
                };
            }
            else
            {
                this.manager = EmulatorManager.Current;
                this.manager.MovedToForeground();
                this.manager.Emulator.RenderComponent.FrameRateChanged += this.UpdateFPS;
                RegisterEvents(app);
            }

            this.moveBarUp.Completed   += MoveBarUp_Completed;
            this.moveBarDown.Completed += MoveBarDown_Completed;

            this.moveLayoutBarDown.Completed           += MoveLayoutBarDown_Completed;
            this.moveLayoutBarUp.Completed             += MoveLayoutBarUp_Completed;
            this.moveLayoutBarFurtherDown.Completed    += MoveLayoutBarFurtherDown_Completed;
            this.moveLayoutBarHalfUp.Completed         += MoveLayoutBarHalfUp_Completed;
            this.moveLayoutBarCompletelyUp.Completed   += MoveLayoutBarCompletelyUp_Completed;
            this.moveLayoutBarCompletelyDown.Completed += MoveLayoutBarCompletelyDown_Completed;

            customizationPanel.DataContext = this;
        }
コード例 #9
0
        /// <summary>
        /// Метод для создания сетки и робота
        /// </summary>
        /// <param name="rowCount">количество строк</param>
        /// <param name="columnCount">количество столбцов</param>
        /// <param name="rowPoint">местоположение робота в строке</param>
        /// <param name="columnPoint">местоположение робота в столбце</param>
        public void CreateGrid(int rowCount, int columnCount, int rowPoint, int columnPoint)
        {
            _robot = new Robot {
                Row = rowPoint, Column = columnPoint
            };
            _grid = new Grid {
                RowCount = rowCount, ColumnCount = columnCount, Cells = new Cell[rowCount, columnCount]
            };
            var initCommand = new ViewGrid(_grid, _robot);

            _visibleGrid.Children.Clear();
            _manager      = new EmulatorManager(_visibleGrid, _grid.Cells, rowCount, columnCount);
            _visibleRobot = _robotInitializer.CreateRobot(Colors.Coral);
            _manager.AddRobot(_visibleRobot, rowPoint, columnPoint);
        }
コード例 #10
0
        public override void Start()
        {
            canvas           = GameObject.Find("Canvas");
            emulationToolbar = Auxiliary.FindObject(canvas, "EmulationToolbar");
            loadingPanel     = Auxiliary.FindObject(canvas, "LoadingPanel");

            useEmulationButtonText  = Auxiliary.FindObject(canvas, "UseEmulationButton").GetComponentInChildren <Text>();
            useEmulationButtonImage = Auxiliary.FindObject(canvas, "UseEmulationImage").GetComponentInChildren <Image>();

            try
            {
                EmulatorManager.programType = (UserProgram.Type)Enum.Parse(typeof(UserProgram.Type), PlayerPrefs.GetString("UserProgramType"), false);
            }
            catch (Exception) { }

            EmulatorManager.StartUpdatingStatus();
            EmulationDriverStation.Instance.BeginTrackingVMConnectionStatus();
        }
コード例 #11
0
ファイル: RobotIOPanel.cs プロジェクト: xiaodelea/synthesis
 /// <summary>
 /// Begin reading robot print-outs into the string buffer
 /// </summary>
 private static void OpenPrintStream()
 {
     printStreamOpen = true;
     if (remoteReader == null)
     {
         remoteReader = EmulatorManager.CreateRobotOutputStream();
     }
     while (remoteReader != null && EmulatorManager.IsTryingToRunRobotCode() && !EmulatorManager.IsRobotCodeRestarting() && EmulatorManager.IsRobotOutputStreamGood() && Instance && RobotIOPanel.Instance.enablePrints)
     {
         try
         {
             int r = remoteReader.Read();
             if (r != -1)
             {
                 char c = (char)r;
                 if (c == '\n' && (newPrintBuffer.Length > MIN_LINE_BUFFER_LEN || timeoutTimer.ElapsedMilliseconds > TIMEOUT)) // Concatenate multiple short prints if in quick enough succession
                 {
                     timeoutTimer.Restart();
                     newPrintQueue.Enqueue(newPrintBuffer);
                     newPrintBuffer = "";
                 }
                 else
                 {
                     newPrintBuffer += c;
                 }
             }
         }
         catch (Exception e)
         {
             Debug.Log(e.ToString());
             break;
         }
     }
     if (remoteReader != null)
     {
         remoteReader.Dispose();
         remoteReader = null;
         if (EmulatorManager.IsRobotOutputStreamGood())
         {
             EmulatorManager.CloseRobotOutputStream();
         }
     }
     printStreamOpen = false;
 }
コード例 #12
0
 /// <summary>
 /// Indicator for VM connection status
 /// </summary>
 private System.Collections.IEnumerator UpdateVMConnectionStatus() // TODO move to emulation toolbar
 {
     while (true)
     {
         if (EmulatorManager.IsVMConnected())
         {
             VMConnectionStatusImage.sprite = EmulatorConnection;
             if (EmulatorNetworkConnection.Instance.IsConnected())
             {
                 VMConnectionStatusMessage.text = "Connected";
             }
             else
             {
                 VMConnectionStatusMessage.text = "Ready";
                 RobotDisabled();
             }
             if (!EmulatorManager.IsRunningRobotCodeRunner() && !EmulatorManager.IsTryingToRunRobotCode() && !EmulatorManager.IsRobotCodeRestarting())
             {
                 EmulatorManager.RestartRobotCode();
             }
         }
         else
         {
             if (!EmulatorManager.IsVMInstalled())
             {
                 VMConnectionStatusImage.sprite = EmulatorNotInstalled;
                 VMConnectionStatusMessage.text = "Not Installed";
             }
             else if (!EmulatorManager.IsVMRunning())
             {
                 VMConnectionStatusImage.sprite = StartEmulator;
                 VMConnectionStatusMessage.text = "Start Emulator";
             }
             else
             {
                 VMConnectionStatusImage.sprite = EmulatorConnection;
                 VMConnectionStatusMessage.text = "Starting";
             }
             RobotDisabled();
         }
         yield return(new WaitForSeconds(1.0f)); // s
     }
 }
コード例 #13
0
ファイル: RobotIOPanel.cs プロジェクト: xiaodelea/synthesis
        public void ToggleRobotPrints()
        {
            bool newEnable = !enablePrints;

            // TODO warn and wait if last command didnt finish
            if (!enablePrints && newEnable && EmulatorManager.IsRobotOutputStreamGood()) // When trying to enable, wait until old connection closes
            {
                UserMessageManager.Dispatch("Waiting to close last readout connection", EmulationWarnings.WARNING_DURATION);
            }
            else
            {
                enablePrints = newEnable;
                enablePrintsButtonImage.sprite = enablePrints ? SelectedButtonImage : UnselectedButtonImage;
                if (enablePrints && !EmulatorManager.IsTryingToRunRobotCode())
                {
                    UserMessageManager.Dispatch("Readout enabled, waiting for robot program to start", EmulationWarnings.WARNING_DURATION);
                }
            }
        }
コード例 #14
0
ファイル: RobotIOPanel.cs プロジェクト: xiaodelea/synthesis
        public void Update()
        {
            if (shouldBeActive)                                                                                             // Handle hiding the panel. Other UIs don't hide automatically, but this one is big and should.
            {
                if (InputControl.GetButtonDown(new KeyMapping("Hide Menu", KeyCode.H, Input.Enums.KeyModifier.Ctrl), true)) // TODO make global control
                {
                    mainPanel.SetActive(!mainPanel.activeSelf);
                }
            }
            if (mainPanel.activeSelf) // Update rest of UI
            {
                bool anyFieldfocused = false;
                foreach (var group in robotIOGroups)
                {
                    anyFieldfocused = anyFieldfocused || group.Update();
                }
                if (anyFieldfocused != lastAnyFieldfocused)
                {
                    InputControl.freeze = anyFieldfocused; // Prevent users inputting values from triggering controls
                    lastAnyFieldfocused = anyFieldfocused;
                }

                if (miniCamera == null)
                {
                    InitMiniCamera();
                }
                UpdateMiniCamera();
                Resize();

                DynamicCamera.ControlEnabled = false;
            }
            else if (lastActive)
            {
                DynamicCamera.ControlEnabled = true;
            }
            if (enablePrints && EmulatorManager.IsTryingToRunRobotCode() && !EmulatorManager.IsRobotCodeRestarting()) // Update robot prints
            {
                RobotPrintManager.Update();
            }

            lastActive = mainPanel.activeSelf;
        }
コード例 #15
0
        public async void LoadCode()
        {
            string[] selectedFiles = SFB.StandaloneFileBrowser.OpenFilePanel("Robot Code Executable", "C:\\", "", false);
            if (selectedFiles.Length != 1)
            {
                AnalyticsManager.GlobalInstance.LogEventAsync(AnalyticsLedger.EventCatagory.EmulationTab,
                                                              AnalyticsLedger.EventAction.CodeType,
                                                              "No Code",
                                                              AnalyticsLedger.getMilliseconds().ToString());
            }
            else
            {
                UserProgram userProgram = new UserProgram(selectedFiles[0]);
                if (userProgram.ProgramType == UserProgram.Type.INVALID)
                {
                    UserMessageManager.Dispatch("Invalid user program type", EmulationWarnings.WARNING_DURATION);
                }
                else if (userProgram.Size > EmulatorManager.MAX_FILE_SIZE)
                {
                    UserMessageManager.Dispatch(Math.Round((double)userProgram.Size / (1024 * 1024), 2) + " MB user program is too large (capacity is " + Math.Round((double)EmulatorManager.MAX_FILE_SIZE / (1024 * 1024), 2) + " MB)", EmulationWarnings.WARNING_DURATION);
                }
                else
                {
                    if (userProgram.Size > EmulatorManager.WARNING_FILE_SIZE)
                    {
                        UserMessageManager.Dispatch("Uploading large, " + Math.Round((double)userProgram.Size / (1024 * 1024), 2) + " MB user program. Upload may take a while.", EmulationWarnings.WARNING_DURATION);
                    }
                    PlayerPrefs.SetString("UserProgramType", userProgram.ProgramType.ToString());

                    AnalyticsManager.GlobalInstance.LogEventAsync(AnalyticsLedger.EventCatagory.EmulationTab,
                                                                  AnalyticsLedger.EventAction.CodeType,
                                                                  userProgram.ProgramType.ToString(),
                                                                  AnalyticsLedger.getMilliseconds().ToString());

                    loadingPanel.SetActive(true);
                    uploadSuccess = await EmulatorManager.SCPFileSender(userProgram);

                    uploadFinished = true;
                }
            }
        }
コード例 #16
0
        public void OnVMConnectionStatusClicked()
        {
            if (EmulationWarnings.CheckRequirement((EmulationWarnings.Requirement.VMInstalled)) && !EmulatorManager.IsVMRunning() && !EmulatorManager.IsVMConnected())
            {
                AnalyticsManager.GlobalInstance.LogEventAsync(AnalyticsLedger.EventCatagory.EmulationTab,
                                                              AnalyticsLedger.EventAction.Clicked,
                                                              "Emulation Start",
                                                              AnalyticsLedger.getMilliseconds().ToString());

                if (EmulatorManager.StartEmulator()) // If successful
                {
                    EmulationDriverStation.Instance.SetActive(true);
                }
                else
                {
                    UserMessageManager.Dispatch("Emulator failed to start.", EmulationWarnings.WARNING_DURATION);
                }
            }
            else if (EmulatorManager.IsVMRunning())
            {
                EmulationDriverStation.Instance.SetKillEmulatorDialogActive(true);
            }
        }
コード例 #17
0
        public GameSearchViewModel(EmulatorManager emulatorManager)
        {
            mEmulatorManager = emulatorManager;
            mSearchInputCommand = new SearchInputCommand(this);
            mSearchDeleteCommand = new SearchDeleteCommand(this);
            mSearchClearCommand = new SearchClearCommand(this);
            mLaunchGameCommand = new LaunchGameCommand();

            addRangeToGames(mEmulatorManager.games);

            searchInputs = new ObservableCollection<SearchInputObject>();
            SearchInputObject obj;
            for (char c = 'A'; c <= 'Z'; ++c)
            {
                obj = new SearchInputObject();
                obj.actualChar = c;
                obj.display = c.ToString();
                obj.command = mSearchInputCommand;
                searchInputs.Add(obj);
            }

            obj = new SearchInputObject();
            obj.display = "_";
            obj.command = mSearchInputCommand;
            obj.actualChar = ' ';
            searchInputs.Add(obj);

            obj = new SearchInputObject();
            obj.display = "<";
            obj.command = mSearchDeleteCommand;
            searchInputs.Add(obj);

            obj = new SearchInputObject();
            obj.display = "Clear";
            obj.command = mSearchClearCommand;
            searchInputs.Add(obj);
        }
コード例 #18
0
 public CustomCommand()
 {
     emuMgr = EmulatorManager.Instance;
 }
コード例 #19
0
 public GameSearch(EmulatorManager emulatorManager)
 {
     mGameSearchVM = new GameSearchViewModel(emulatorManager);
     InitializeComponent();
 }
コード例 #20
0
 public void KillEmulator()
 {
     EmulatorManager.KillEmulator();
 }
コード例 #21
0
 public PlayCommand()
 {
     romMgr = RomManager.Instance;
     emuMgr = EmulatorManager.Instance;
 }