コード例 #1
0
        public static async Task <bool> DeployNativeLibraries(List <Tuple <string, string> > files, string remoteDirectory, string propertiesName)
        {
            List <string> fileList = new List <string>(files.Count);

            MemoryStream memStream = new MemoryStream();
            StreamWriter writer    = new StreamWriter(memStream);

            foreach (Tuple <string, string> tuple in files)
            {
                fileList.Add(tuple.Item1);
                await writer.WriteLineAsync($"{tuple.Item1}={tuple.Item2}");
            }

            writer.Flush();

            memStream.Position = 0;

            OutputWriter.Instance.WriteLine("Deploying native files");
            bool nativeDeploy = await RoboRIOConnection.DeployFiles(fileList, remoteDirectory, ConnectionUser.Admin);

            bool md5Deploy = await RoboRIOConnection.DeployFile(memStream, $"{remoteDirectory}/{propertiesName}.properties", ConnectionUser.Admin);

            await RoboRIOConnection.RunCommand("ldconfig", ConnectionUser.Admin);

            writer.Dispose();
            memStream.Dispose();

            return(nativeDeploy && md5Deploy);
        }
コード例 #2
0
        public async Task <bool> CheckMonoInstall()
        {
            OutputWriter.Instance.WriteLine("Checking for Mono install");
            var retVal = await RoboRIOConnection.RunCommand($"test -e {DeployProperties.RoboRioMonoBin}", ConnectionUser.LvUser);

            return(retVal.ExitStatus == 0);
        }
コード例 #3
0
        public async Task StartRobotCode(string robotName, bool debug, Project robotProject)
        {
            //TODO: Make debug work. Forcing debug to false for now so code always runs properly.
            debug = false;

            if (SettingsProvider.TeamSettingsPage.Netconsole)
            {
                await StartNetConsole();
            }
            string deployedCmd;
            string deployedCmdFrame;

            if (debug)
            {
                deployedCmd      = string.Format(DeployProperties.RobotCommandDebug, robotName);
                deployedCmdFrame = DeployProperties.RobotCommandDebugFileName;
            }
            else
            {
                deployedCmd      = string.Format(DeployProperties.RobotCommand, robotName);
                deployedCmdFrame = DeployProperties.RobotCommandFileName;
            }

            string args = GetCommandLineArguments(robotProject);

            //Kill the currently running robot program
            await RoboRIOConnection.RunCommand(DeployProperties.KillOnlyCommand, ConnectionUser.LvUser);

            //Combining all other commands, since they should be safe running together.
            List <string> commands = new List <string>();

            //Write the robotCommand file
            commands.Add($"echo {deployedCmd} {args} > {DeployProperties.CommandDir}/{deployedCmdFrame}");
            if (debug)
            {
                //If debug write the debug flag.
                commands.AddRange(DeployProperties.DebugFlagCommand);
            }
            //Add all commands to restart
            commands.AddRange(DeployProperties.DeployKillCommand);
            //run all commands
            await RoboRIOConnection.RunCommands(commands.ToArray(), ConnectionUser.LvUser);

            //Run sync so files are written to disk.
            await RoboRIOConnection.RunCommand("sync", ConnectionUser.LvUser);
        }
コード例 #4
0
        public async Task <bool> StartConnectionTask(string teamNumber)
        {
            ConnectionReturn connected = await RoboRIOConnection.CheckConnection(teamNumber);

            if (connected != null)
            {
                StringBuilder builder = new StringBuilder();
                builder.AppendLine("Connected to RoboRIO...");
                builder.AppendLine("Interface: " + connected.ConnectionType);
                builder.Append("IP Address: " + connected.ConnectionIp);
                OutputWriter.Instance.WriteLine(builder.ToString());
                m_connectionValues = connected;
                return(true);
            }
            else
            {
                OutputWriter.Instance.WriteLine("Failed to Connect to RoboRIO...");
                return(false);
            }
        }
コード例 #5
0
        public static async Task <bool> CheckAndDeployNativeLibraries(string remoteDirectory, string propertiesName, string dirToUpload, IList <string> ignoreFiles)
        {
            MemoryStream stream   = new MemoryStream();
            bool         readFile =
                await
                RoboRIOConnection.ReceiveFile($"{remoteDirectory}/{propertiesName}.properties", stream,
                                              ConnectionUser.LvUser);

            string nativeLoc = dirToUpload;

            var fileMd5List = await GetMD5ForFiles(nativeLoc, ignoreFiles);

            if (!readFile)
            {
                // Libraries definitely do not exist, deploy
                return(await DeployNativeLibraries(fileMd5List, remoteDirectory, propertiesName));
            }

            stream.Position = 0;

            bool         foundError = false;
            int          readCount  = 0;
            StreamReader reader     = new StreamReader(stream);
            string       line       = null;

            while (!string.IsNullOrWhiteSpace(line = reader.ReadLine()))
            {
                // Split line at =
                string[] split = line.Split('=');
                if (split.Length < 2)
                {
                    continue;
                }
                readCount++;
                foreach (Tuple <string, string> tuple in fileMd5List)
                {
                    if (split[0] == tuple.Item1)
                    {
                        // Found a match file name
                        if (split[1] != tuple.Item2)
                        {
                            foundError = true;
                        }
                        break;
                    }
                }
                if (foundError)
                {
                    break;
                }
            }

            reader.Dispose();

            if (foundError || readCount != fileMd5List.Count)
            {
                return(await DeployNativeLibraries(fileMd5List, remoteDirectory, propertiesName));
            }

            OutputWriter.Instance.WriteLine("Native libraries exist. Skipping deploy");
            return(true);
        }
コード例 #6
0
 public async Task CreateMonoDirectory()
 {
     OutputWriter.Instance.WriteLine("Creating Mono Deploy Directory");
     await RoboRIOConnection.RunCommand($"mkdir -p {DeployProperties.DeployDir}", ConnectionUser.LvUser);
 }
コード例 #7
0
 public async Task <bool> DeployRobotFiles(List <string> files)
 {
     OutputWriter.Instance.WriteLine("Deploying robot files");
     return(await RoboRIOConnection.DeployFiles(files, DeployProperties.DeployDir, ConnectionUser.LvUser));
 }