示例#1
0
        static void Main(string[] args)
        {
            IoController superIoData    = new IoController(IoController.SuperIoDataOffset);
            IoController superIoPointer = new IoController(IoController.SuperIoPointerOffset);

            superIoPointer.Poke(0x00, 0x87);
            superIoPointer.Poke(0x00, 0x87);

            superIoPointer.Poke(0x00, 0x07);
            superIoData.Poke(0x00, 0x07);

            superIoPointer.Poke(0x00, 0xE9);

            while (true)
            {
                try
                {
                    Console.WriteLine($"Button State: {superIoData.Peek(0x00)}");
                }
                catch (Exception e)
                {
                    Console.WriteLine($"Button State Read Failed: {e.Message}");
                }
            }
        }
示例#2
0
        internal async Task Start()
        {
            try
            {
                IoController    = GpioController.GetDefault();
                _resetPowerDown = IoController.OpenPin(RESET_PIN);
                _resetPowerDown.Write(GpioPinValue.High);
                _resetPowerDown.SetDriveMode(GpioPinDriveMode.Output);
            }
            /* If initialization fails, throw an exception */
            catch (Exception ex)
            {
                throw new Exception("GPIO initialization failed", ex);
            }

            try
            {
                var settings = new SpiConnectionSettings(SPI_CHIP_SELECT_LINE);
                settings.ClockFrequency = 1000000;
                settings.Mode           = SpiMode.Mode0;
                String spiDeviceSelector = SpiDevice.GetDeviceSelector(SPI_CONTROLLER_NAME);
                var    devices           = await DeviceInformation.FindAllAsync(spiDeviceSelector);

                _spi = await SpiDevice.FromIdAsync(devices[0].Id, settings);
            }
            /* If initialization fails, display the exception and stop running */
            catch (Exception ex)
            {
                throw new Exception("SPI Initialization Failed", ex);
            }


            Reset();
        }
        public static void SnapshotBackupCode()
        {
            var i = 1;

            _areSavesAvaliable = Directory.GetFiles(CommonVariables.SaveLocation, "*.isgsf").Length > 0;

            if (!_areSavesAvaliable)
            {
                return;
            }
            if (Settings.Default.ArchiveBackups)
            {
                IoController.ArchiveCodec(false, SearchLocation, Settings.Default.AutoBackupLocation + "\\ImmortalSins-BackupSnapshot-" + DateTime.Now.ToString("yyyyMMddHHmm") + ".isarc2");
            }
            else
            {
                if (!Directory.Exists(BackupFolder))
                {
                    IoController.DirectoryCopy(SearchLocation, BackupFolder, true);
                }
                else
                {
                    var newBackupFolder = BackupFolder + "-" + i + "\\";
                    while (Directory.Exists(BackupFolder + "-" + i + "\\"))
                    {
                        i++;
                    }
                    IoController.DirectoryCopy(SearchLocation, newBackupFolder, true);
                }
            }
        }
示例#4
0
 /// <summary>
 /// Shows the MPAiSoundScoreBoard, if it exists.
 /// </summary
 public static void ShowMPAiSoundScoreReport()
 {
     if (File.Exists(MPAiSoundScoreReportHTMLAddress))
     {
         IoController.ShowInBrowser(MPAiSoundScoreReportHTMLAddress);
     }
 }
 public static void SingleBackupArchive()
 {
     if (!Directory.Exists(SingleBackupLocation))
     {
         return;
     }
     IoController.ArchiveCodec(false, SingleBackupLocation, Settings.Default.AutoBackupLocation + "\\ImmortalSins-SingleBackup.isarc2");
     Directory.Delete(SingleBackupLocation, true);
 }
示例#6
0
        private void CreateAndConnectIOSystem()
        {
            Subnet mySubnet = null;

            foreach (var subnet in MyProject.Subnets)
            {
                mySubnet = subnet;
                SetTextInRichTextBox(Color.Black, $"[{subnet.Name}] is founded");
            }
            foreach (IoSystem ioSystem1 in mySubnet.IoSystems)
            {
                SetTextInRichTextBox(Color.Black, $"[{ioSystem1.Name}] is founded");
            }
            NetworkInterface networkInterface = null;
            IoSystem         ioSystem         = null;

            foreach (Device device in MyProject.Devices)
            {
                foreach (DeviceItem Dev1 in device.DeviceItems)
                {
                    foreach (DeviceItem Dev2 in Dev1.DeviceItems)
                    {
                        if (Dev2.Name == "PROFINET interface_1" || Dev2.Name == "PROFINET interface" || Dev2.Name == "PROFINET Interface_1" || Dev2.Name == "SCALANCE interface_1")
                        {
                            networkInterface = ((IEngineeringServiceProvider)Dev2).GetService <NetworkInterface>();
                            if ((networkInterface.InterfaceOperatingMode & InterfaceOperatingModes.IoController) != 0)
                            {
                                SetTextInRichTextBox(Color.Black, "Bingo IO Controller");
                                IoControllerComposition ioControllers = networkInterface.IoControllers;
                                IoController            ioController  = ioControllers.First();
                                if (ioController.IoSystem != null)
                                {
                                    SetTextInRichTextBox(Color.Blue, $"{ioController.IoSystem.Name} IO system is already connected");
                                }
                                if ((ioController != null) && (ioController.IoSystem == null))
                                {
                                    ioSystem = ioController.CreateIoSystem("");
                                }
                            }
                            if ((networkInterface.InterfaceOperatingMode & InterfaceOperatingModes.IoDevice) != 0)
                            {
                                SetTextInRichTextBox(Color.Black, "Bingo IO Device");
                                IoConnectorComposition ioConnectors = networkInterface.IoConnectors;
                                IoConnector            ioConnector  = ioConnectors.First();
                                if (ioConnector != null)
                                {
                                    ioConnector.ConnectToIoSystem(ioSystem);
                                }
                            }
                        }
                    }
                }
            }
        }
示例#7
0
        private static void Main(string[] args)
        {
            string input;

            while ((input = Console.ReadLine()) != null)
            {
                // polecam zmienić formatowanie z None na Indented, jeśli zamierza Pani to czytać :D
                CallResult.Formatting = Formatting.None;

                var output = IoController.ExecuteInputLine(input);
                if (output != "")
                {
                    Console.WriteLine(output);
                }
            }
        }
 private static void UnpackSingleBackupPackage()
 {
     if (Directory.Exists(SingleBackupLocation))
     {
         Directory.Delete(SingleBackupLocation, true);
     }
     if (File.Exists(Settings.Default.AutoBackupLocation + "\\ImmortalSins-SingleBackup.isarc2"))
     {
         IoController.ArchiveCodec(true,
                                   Settings.Default.AutoBackupLocation + "\\ImmortalSins-SingleBackup.isarc2", SingleBackupLocation);
     }
     else
     {
         Directory.CreateDirectory(SingleBackupLocation);
     }
 }
        public static void MonitorSetupCode()
        {
            IoController.DiskCheck(Settings.Default.AutoBackupLocation);
            if (CommonVariables.PermissionError)
            {
                MessageBox.Show(Resources.BackupMonitorPermissionError, Resources.CommonWordWarning, MessageBoxButton.OK,
                                MessageBoxImage.Warning);
            }
            else if (CommonVariables.SpaceError)
            {
                MessageBox.Show(Resources.BackupMonitorSpaceError,
                                Resources.CommonWordWarning, MessageBoxButton.OK,
                                MessageBoxImage.Warning);
            }
            else if (!CommonVariables.IsDriveReady)
            {
                MessageBox.Show(Resources.BackupMonitorDNRError, Resources.CommonWordWarning, MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            if (CommonVariables.PermissionError || CommonVariables.SpaceError || !CommonVariables.IsDriveReady)
            {
                return;
            }
            if (Settings.Default.SingleBackupMode)
            {
                UnpackSingleBackupPackage();
            }
            var svw = new FileSystemWatcher
            {
                Path         = SearchLocation,
                NotifyFilter = NotifyFilters.LastWrite,
                Filter       = "GameSave*.isgsf"
            };

            svw.Changed            += OnChanged;
            svw.Created            += OnChanged;
            svw.Deleted            += OnChanged;
            svw.EnableRaisingEvents = true;
        }
示例#10
0
        private void TestButton_Click(object sender, RoutedEventArgs e)
        {
            DateTime t1 = DateTime.Now;

            Thread.Sleep(1000);

            string data = TestData.Text.Trim();

            string[] tempList = data.Split(new char[] { '|' });
            if (tempList.Length != 3)
            {
                return;
            }
            string       userName   = tempList[0];
            string       password   = tempList[1];
            string       command    = tempList[2];
            string       basePath   = System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "ClientConfig");
            string       configPath = System.IO.Path.Combine(basePath, curConfigFileName);;
            IoController ioc        = new IoController(configPath);

            ioc.OnShowErrMsg         += ioc_OnShowErrMsg;
            ioc.OnReceiveAlarmSignal += ioc_OnReceiveAlarmSignal;
            bool result = ioc.TestExecCommand(command);
        }
示例#11
0
 /// <summary>
 /// When the user selects instruction manual, launches the browser for them to read the github wiki.
 /// This isn't the best solution, especially with the current state of th ewiki, but for now, it was the one being used in the stable version.
 /// </summary>
 /// <param name="sender">Automatically generated by Visual Studio.</param>
 /// <param name="e">Automatically generated by Visual Studio.</param>
 private void instructionToolStripMenuItem_Click(object sender, EventArgs e)
 {
     // Open the browser to view the github wiki, at least until we get a proper system for this.
     IoController.ShowInBrowser("https://github.com/JSCooke/MPAi/wiki/Instruction-Manual");
 }