Example #1
0
        private string ReplaceActionOption(string Text, ToolAction A, Options.OptionListItem Ops)
        {
            if (Ops == null) return Text;

            var Temp = Text;

            foreach(var P in A.Defaults.Params)
            {
                var N = P.Name;
                var V = Ops.getString(N);
                if (V == null) V = P.ToString();

                string Mask = "{" + N + "}";
                Temp = Temp.Replace(Mask, V);
            }

            return Temp;
        }
Example #2
0
        private void LoadActions(CONF.XmlLoad X)
        {
            while (X.Read())
            {
                switch (X.ElementName)
                {
                    case "erase": taErase = LoadAction(X.GetSubtree()); break;
                    case "woption": taProgramOption = LoadAction(X.GetSubtree()); break;
                    case "wflash": taProgramFlash = LoadAction(X.GetSubtree()); break;
                    case "wdata": taProgramData = LoadAction(X.GetSubtree()); break;
                    case "vflash": taVerifyFlash = LoadAction(X.GetSubtree()); break;
                    case "vdata": taVerifyData = LoadAction(X.GetSubtree()); break;
                    case "lock": taLock = LoadAction(X.GetSubtree()); break;
                    case "launch": taLaunch = LoadAction(X.GetSubtree()); break;
                    case "convert": taConvert = LoadAction(X.GetSubtree()); break;
                    default:
                        {
                            ToolAction A = LoadAction(X.GetSubtree());
                            A.Name = X.ElementName;

                            taCustom.Add(A);
                        }
                        break;
                }
            }

            X.Close();
        }
Example #3
0
        private bool GenericToolAction(ToolAction A, string Device, string Dir, string Options, Options.OptionListItem Ops)
        {
            if (A == null) return ActionNotSupported();
            Error = "";
            Warning = "";

            string Command = A.Command;
            Command = Command.Replace("{device}", Device);
            Command = Command.Replace("{filename}", Options);
            Command = Command.Replace("{filenamewe}", Path.GetFileNameWithoutExtension(Options));
            Command = Command.Replace("{dir}", Dir);
            Command = ReplaceActionOption(Command, A, Ops);
            Command = ReplaceOptionByte(Command, Options);
            Command = ReplaceToolOption(Command);
            Command = ParseExternalToolVars(Command);

            List<string> Write = new List<string>();
            /*for (int i = 0; i < A.Write.Count; i++)
            {
                string T = A.Write[i];
                T = T.Replace("{device}", Device);
                T = T.Replace("{filename}", Options);
                T = T.Replace("{filenamewe}", Path.GetFileNameWithoutExtension(Options));
                T = T.Replace("{dir}", Dir);
                T = ReplaceOptionByte(T, Options);
                Write.Add(T);
            }*/

            return Exec(A, Command, Write, Dir);
        }
Example #4
0
        private ToolAction LoadAction(CONF.XmlLoad X)
        {
            ToolAction A = new ToolAction();

            while (X.Read())
            {
                switch (X.ElementName)
                {
                    case "command": A.Command = X.GetAttribute("value"); break;
                    case "toolpath": A.CustomToolPath = X.GetAttribute("value"); break;
                    case "params":
                        {
                            CONF.XmlLoad Subtree = X.GetSubtree();
                            while (Subtree.Read())
                            {
                                var Name = Subtree.ElementName;
                                var Def = Subtree.GetAttribute("default") ?? "";

                                A.Defaults.setString(Name, Def);
                            }
                            Subtree.Close();
                        }
                        break;
                    case "error":
                        {
                            CONF.XmlLoad Subtree = X.GetSubtree();
                            while (Subtree.Read())
                            {
                                switch (Subtree.ElementName)
                                {
                                    case "string": A.ErrorMask.Add(Subtree.GetAttribute("value")); break;
                                }
                            }
                            Subtree.Close();
                        }
                        break;
                    case "internal":
                        {
                            CONF.XmlLoad Subtree = X.GetSubtree();
                            while (Subtree.Read())
                            {
                                switch (Subtree.ElementName)
                                {
                                    case "string": A.Write.Add(Subtree.GetAttribute("value")); break;
                                }
                            }
                            Subtree.Close();
                        }
                        break;
                }
            }

            return A;
        }
Example #5
0
        private bool Exec(ToolAction A, string Command, List<string> Write, string Dir)
        {
            string P = (A.CustomToolPath != null) ? A.CustomToolPath : ToolPath;
            string Output = ExternalTool.Run(P, Command, Write, Dir);

            if (Output == null) return false;

            var E = GetMessage(Output, A.ErrorMask);
            if (E != null)
            {
                Error = E;
                return false;
            }

            var W = GetMessage(Output, A.WarningMask);
            if (W != null) Warning = W;

            return true;
        }