public void Execute(ArgumentList arguments, TaskList tasklist, TagList tags, TagFolder folder)
 {
     ILister lister = new Lister();
     if (arguments.GetParameter(arguments.GetLength() - 1) == "--export")
         lister = new HtmlLister();
     lister.ListFiltered(tasklist.FilterTasks(arguments.GetParameter(1)), arguments.GetParameter(1));
 }
Example #2
0
 public CreateHmiPresetConstantTagsTask(TiaPortal portal, TagFolder folder, ConstantLookup constants)
 {
     this.portal    = portal;
     this.folder    = folder;
     this.constants = constants;
     Description    = "Update HMI preset constant table " + PRESET_CONSTANT_TABLE_NAME;
 }
Example #3
0
 public void Execute(ArgumentList arguments, TaskList tasklist, TagList tags, TagFolder folder)
 {
     FileIO loader = new FileIO();
     if (tasklist.MarkAsDone(arguments.GetParameter(1)))
     loader.SaveTasks(tasklist.GetTasks());
         else
             Console.WriteLine("No task with that id found to mark as done");
 }
 public void Execute(ArgumentList arguments, TaskList tasks, TagList tags, TagFolder folder)
 {
     FileIO loader = new FileIO();
     TaskTagger tagTasks = new TaskTagger(tasks.GetTasks());
     if (tagTasks.Untag(arguments.GetParameter(1), arguments.GetParameter(2)))
         loader.SaveTasks(tagTasks.GetTasks());
     else
         Console.WriteLine("No task with that id found to untag");
 }
Example #5
0
 public CreateHmiTagsFromBlockTask(TiaPortal portal, PlcBlock block, TagFolder folder, string function, ConstantLookup constants)
 {
     this.portal    = portal;
     this.folder    = folder;
     this.block     = block;
     this.function  = function;
     this.constants = constants;
     Description    = "Update HMI tag table " + function + " for block " + block.Name;
 }
 public void Execute(ArgumentList arguments, TaskList tasklist, TagList tags, TagFolder folder)
 {
     FileIO loader = new FileIO();
     if (tasklist.RemoveTask(arguments.GetParameter(1)))
         {
         loader.SaveTasks(tasklist.GetTasks());
         Console.WriteLine("Task " + arguments.GetParameter(1) + " removed.");
         }
     else
     Console.WriteLine("No task with that id found to remove");
 }
Example #7
0
 public void Execute(ArgumentList arguments, TaskList tasklist, TagList tags, TagFolder folder)
 {
     ILister lister = new Lister();
     if (arguments.GetParameter(arguments.GetLength() - 1) == "--export")
         lister = new HtmlLister();
     if (arguments.GetLength() == 1 || arguments.GetParameter(1) == "--export")
         lister.ListNotDone(tasklist.GetTasks(), string.Empty);
     else if (arguments.GetParameter(1) == "all")
         lister.ListAllTasks(tasklist.GetTasks());
     else if (arguments.GetParameter(1) == "tags")
         lister.ListTags(tags, tasklist);
 }
Example #8
0
 public CreatePresetHmiTagsTask(TiaPortal portal, IList <PresetTag> tags, TagFolder folder, string table_name, string group_name, string db_name, string hmi_db_name, int nPresets)
 {
     this.portal    = portal;
     this.tags      = tags;
     this.folder    = folder;
     this.tableName = table_name;
     groupName      = group_name;
     dbName         = db_name;
     hmiDbName      = hmi_db_name;
     this.nPresets  = nPresets;
     Description    = "Create HMI tag table " + tableName;
 }
Example #9
0
 private void AddTagTables(TagFolder group)
 {
     foreach (TagTable tags in group.TagTables)
     {
         worker.ReportProgress(50, new NodeData(NodeDest.From, tags.Name, tags));
     }
     foreach (TagFolder child in group.Folders)
     {
         worker.ReportProgress(50, new NodeEnter(NodeDest.From, child.Name, true));
         AddTagTables(child);
         worker.ReportProgress(50, new NodeExit(NodeDest.From));
     }
 }
Example #10
0
 public void Execute(ArgumentList arguments, TaskList tasks, TagList tags, TagFolder folder)
 {
     ILister lister = new Lister();
     if (arguments.GetParameter(arguments.GetLength() - 1) == "--export")
         lister = new HtmlLister();
     if (arguments.GetLength() == 1 || arguments.GetParameter(1) == "--export")
         lister.ListNotDone(tasks.FilterDue("past"), string.Empty);
     else if (arguments.GetParameter(1) == "today")
         lister.ListNotDone(tasks.FilterDue("today"), string.Empty);
     else if (arguments.GetParameter(1) == "thisWeek")
         lister.ListNotDone(tasks.FilterDue("thisWeek"), string.Empty);
     else if (arguments.GetParameter(1) == "nextWeek")
         lister.ListNotDone(tasks.FilterDue("nextWeek"), string.Empty);
 }
Example #11
0
 public void Execute(ArgumentList arguments, TaskList tasklist, TagList tags, TagFolder folder)
 {
     if (tasklist.HasSameTask(arguments.GetParameter(1)) == false)
     {
         Task task = new Task();
         FileIO loader = new FileIO();
         task.TaskDescription = arguments.GetParameter(1);
         task.IsNewTask = true;
         task = CheckDueDate(arguments, task);
         tasklist.AddTask(ref task);
         loader.SaveTasks(tasklist.GetTasks());
         Console.WriteLine("Task {0} added", task.TaskDescription);
     }
     else Console.WriteLine("Task already in list");
 }
 public void Execute(ArgumentList arguments, TaskList tasks, TagList tags, TagFolder folder)
 {
     FileIO loader = new FileIO();
     TaskTagger tagTasks = new TaskTagger(tasks.GetTasks());
     if (tagTasks.DeleteTag(arguments.GetParameter(1)) || tags.HasTag(arguments.GetParameter(1)))
     {
         Tag tagToRemove = tags.GetTag(tags.GetTagIndex(arguments.GetParameter(1)));
         tags.RemoveTag(ref tagToRemove);
         loader.SaveTags(tags);
         loader.SaveTasks(tagTasks.GetTasks());
         Console.WriteLine("Tag {0} deleted", arguments.GetParameter(1));
     }
     else
         Console.WriteLine("No tag with that name available");
 }
Example #13
0
 public void Execute(ArgumentList arguments, TaskList tasks, TagList tags, TagFolder folder)
 {
     FileIO loader = new FileIO();
     TaskTagger tagTasks = new TaskTagger(tasks.GetTasks());
     if (arguments.GetLength() == 2)
     {
         Tag tag = new Tag(arguments.GetParameter(1));
         tags.AddTag(ref tag);
         loader.SaveTags(tags);
     }
     else
     {
         if (tagTasks.AssignTag(arguments.GetParameter(1), arguments.GetParameter(2)))
         {
             loader.SaveTasks(tagTasks.GetTasks());
             Tag tag = new Tag(arguments.GetParameter(2));
             tags.AddTag(ref tag);
             loader.SaveTags(tags);
         }
         else
             Console.WriteLine("No task with that id found to tag");
     }
 }
 public void Execute(ArgumentList arguments, TaskList tasks, TagList tags, TagFolder folder)
 {
     FileIO loader = new FileIO();
     if (arguments.GetLength() == 2)
     {
         folder.FolderName = arguments.GetParameter(1);
         loader.SaveFolder(folder);
     }
     else if (arguments.GetLength() == 3 && arguments.GetParameter(1) == "tag")
     {
         Tag toAdd = new Tag(arguments.GetParameter(2));
         folder.AddTag(ref toAdd);
         loader.SaveFolder(folder);
     }
     else if (arguments.GetLength() == 3 && arguments.GetParameter(1) == "subfolder")
     {
         TagFolder toAdd = new TagFolder(arguments.GetParameter(2));
         folder.AddSubfolder(toAdd);
         loader.SaveFolder(folder);
     }
     else if (arguments.GetLength() == 5 && arguments.GetParameter(1) == "subfolder" && arguments.GetParameter(3) == "tag")
     {
         Tag toAdd = new Tag(arguments.GetParameter(4));
         TagFolder copy = folder.GetSubfolder(arguments.GetParameter(2));
         copy.AddTag(ref toAdd);
         folder.ReplaceSubFolder(folder.GetSubfolder(arguments.GetParameter(2)), copy);
         loader.SaveFolder(folder);
     }
     else if (arguments.GetLength() == 5 && arguments.GetParameter(1) == "subfolder" && arguments.GetParameter(3) == "subfolder")
     {
         TagFolder toAdd = new TagFolder(arguments.GetParameter(4));
         TagFolder copy = folder.GetSubfolder(arguments.GetParameter(2));
         copy.AddSubfolder(toAdd);
         folder.ReplaceSubFolder(folder.GetSubfolder(arguments.GetParameter(2)), copy);
         loader.SaveFolder(folder);
     }
 }
Example #15
0
        static public void ImportHMITagTableXML(XmlDocument doc, TagFolder folder)
        {
            FileInfo path = TempFile.File("import_tagtable_", "xml");

            try
            {
                XmlWriter writer = XmlWriter.Create(path.ToString());
                doc.Save(writer);
                writer.Close();

                folder.TagTables.Import(path, ImportOptions.Override);
            }
            finally
            {
                try
                {
                    path.Delete();
                }
                catch (IOException e)
                {
                    Console.WriteLine("Failed to delete temporary file: " + e.Message);
                }
            }
        }
        public void Execute(ArgumentList arguments, TaskList tasklist, TagList tags, TagFolder folder)
        {
            FileIO loader = new FileIO();
            switch (arguments.GetTypeOfChange())
            {
                case 0:
                    if (tasklist.ChangeTask(arguments.GetParameter(1), arguments.GetParameter(3), 0))
                        Console.WriteLine("Task {0} changed to {1}", arguments.GetParameter(1), arguments.GetParameter(3));
                    else
                        Console.WriteLine("No task with that id found to change");
                    break;
                case 1:
                    if (tasklist.ChangeTask(arguments.GetParameter(1), arguments.GetParameter(3), 1))
                        Console.WriteLine("Task {0} due date changed to {1}", arguments.GetParameter(1), arguments.GetParameter(3));
                    else
                        Console.WriteLine("No task with that id found to change");
                    break;
                case 2:
                    if (tasklist.ChangeTask(arguments.GetParameter(1), arguments.GetParameter(3), 0) && tasklist.ChangeTask(arguments.GetParameter(1), arguments.GetParameter(5), 1))
                        Console.WriteLine("Task {0} changed to {1}, due date changed to {2}", arguments.GetParameter(1), arguments.GetParameter(3), arguments.GetParameter(5));
                    else
                        Console.WriteLine("No task with that id found to change");
                    break;
                case 3:
                    if (tasklist.ChangeTask(arguments.GetParameter(1), arguments.GetParameter(3), 1) && tasklist.ChangeTask(arguments.GetParameter(1), arguments.GetParameter(5), 0))
                        Console.WriteLine("Task {0} changed to {1}, due date changed to {2}", arguments.GetParameter(1), arguments.GetParameter(5), arguments.GetParameter(3));
                    else
                        Console.WriteLine("No task with that id found to change");
                    break;
                default:
                    Console.WriteLine("Wrong arguments for change command");
                    break;
            }

            loader.SaveTasks(tasklist.GetTasks());
        }
Example #17
0
 public HMItagInfo(PlcBlock block, TagFolder folder, string function)
 {
     this.block    = block;
     this.folder   = folder;
     this.function = function;
 }
 public void Execute(ArgumentList arguments, TaskList tasklist, TagList tags, TagFolder folder)
 {
     var lister = new Lister();
     lister.ListAllTasks(tasklist.FilterByTagList(folder.GetAllTags()));
 }
Example #19
0
        private void WriteButton_Click(object sender, EventArgs e)
        {
            if (task_dialog == null)
            {
                task_dialog = new TaskDialog();
            }
            task_dialog.Clear();

            Project             proj  = tiaPortal.Projects[0];
            LanguageAssociation langs = proj.LanguageSettings.ActiveLanguages;

            string[] cultures        = langs.Select(l => l.Culture.Name).ToArray();
            string   default_culture = proj.LanguageSettings.ReferenceLanguage.Culture.Name;

            foreach (PresetTagList.Row row in presetList)
            {
                row.Tag.labels.AddMissingCultures(cultures, default_culture);
                if (row.Tag.state_labels != null)
                {
                    foreach (MultilingualText text in row.Tag.state_labels.Values)
                    {
                        text.AddMissingCultures(cultures, default_culture);
                    }
                }
            }
            // Sort the groups into separate lists of tags
            Dictionary <string, List <PresetTag> > tag_groups = tagGroups(presetList);


            ConstantLookup constants = new ConstantLookup();

            constants.Populate(tiaPortal, plcSoftware);

            // Create databases for all groups
            foreach (string group_name in tag_groups.Keys)
            {
                string db_name     = PRESET_DB_PREFIX + group_name;
                string hmi_db_name = PRESET_HMI_DB_PREFIX + group_name;
                var    tags        = tag_groups[group_name];

                string value_type_name  = "PresetValueType_" + group_name;
                string enable_type_name = "PresetEnableType_" + group_name;

                task_dialog.AddTask(new CreatePresetTypesTask(tiaPortal, tags, typeGroup, value_type_name, enable_type_name));
                string recall_block_name = "PresetRecall_" + group_name;
                task_dialog.AddTask(new CreatePresetRecallBlockTask(tiaPortal, tags, resultGroup, recall_block_name, value_type_name, enable_type_name));
                string store_block_name         = "PresetStore_" + group_name;
                string store_enabled_block_name = "PresetStoreEnabled_" + group_name;
                task_dialog.AddTask(new CreatePresetStoreBlockTask(tiaPortal, tags, resultGroup, store_block_name, store_enabled_block_name, value_type_name, enable_type_name));
            }

            task_dialog.AddTask(new CreatePlcCompileTask(tiaPortal, plcSoftware));

            foreach (HmiTarget hmi in hmiTargets)
            {
                // Create HMI tags
                TagFolder preset_tag_folder = hmi.TagFolder.Folders.Find("Preset");
                if (preset_tag_folder != null)
                {
                    task_dialog.AddTask(new CreateHmiPresetConstantTagsTask(tiaPortal, preset_tag_folder, constants));
                }
            }

            // Create HMI for all groups
            foreach (string group_name in tag_groups.Keys)
            {
                var    tags        = tag_groups[group_name];
                string db_name     = PRESET_DB_PREFIX + group_name;
                string hmi_db_name = PRESET_HMI_DB_PREFIX + group_name;

                foreach (HmiTarget hmi in hmiTargets)
                {
                    string            popup_name   = "PresetPopup_" + group_name;
                    ScreenPopupFolder popup_folder = hmi.ScreenPopupFolder;
                    ScreenPopup       popup        = popup_folder.ScreenPopups.Find(popup_name);
                    if (popup == null)
                    {
                        task_dialog.AddTask(new MessageTask("Skipping preset group " + group_name + " for HMI " + hmi.Name,
                                                            MessageLog.Severity.Info,
                                                            "Assuming preset group " + group_name + " is not used by this HMI since the pop-up screen " + popup_name + " was not found"));
                        continue;
                    }

                    String list_prefix = "PresetTextList_" + group_name + "_";
                    TextListComposition hmi_text_lists = hmi.TextLists;

                    // Text list that are candidates for deletion
                    List <String> delete_lists = new List <string>();
                    // Find all preset text lists
                    foreach (var list in hmi_text_lists)
                    {
                        if (list.Name.StartsWith(list_prefix))
                        {
                            delete_lists.Add(list.Name);
                        }
                    }

                    // Create text lists

                    int count = 1;
                    foreach (PresetTag tag in tags)
                    {
                        if (tag.state_labels != null)
                        {
                            string list_name = list_prefix + count;
                            delete_lists.Remove(list_name); // Don't delete this list
                            task_dialog.AddTask(new CreateHmiTextListTask(tiaPortal, list_name, hmi_text_lists, tag.state_labels));
                        }
                        count++;
                    }

                    // Delete old textlists
                    task_dialog.AddTask(new DeleteHmiTextListTask(tiaPortal, list_prefix, hmi_text_lists, delete_lists));

                    // Get number of presets configured
                    string count_entry_name          = "PresetCount_" + group_name;
                    ConstantLookup.Entry count_entry = constants.Lookup(count_entry_name);
                    if (count_entry == null)
                    {
                        throw new Exception("Global constant " + count_entry_name + " not found");
                    }


                    int nPresets = int.Parse(count_entry.value);

                    Dictionary <int, MultilingualText> preset_names = new Dictionary <int, MultilingualText>();
                    // Create preset name list


                    {
                        for (int p = 1; p <= nPresets; p++)
                        {
                            string           name_string = "<hmitag length='20' type='Text' name='PresetName_" + group_name + "_" + p + "'>Preset " + p + "</hmitag>";
                            MultilingualText text        = new MultilingualText();
                            foreach (string c in cultures)
                            {
                                text.AddText(c, name_string);
                            }
                            preset_names.Add(p, text);
                        }

                        string list_name = "PresetNameList_" + group_name;
                        task_dialog.AddTask(new CreateHmiTextListTask(tiaPortal, list_name, hmi_text_lists, preset_names));
                    }
                    // Create HMI tags
                    TagFolder preset_tag_folder = hmi.TagFolder.Folders.Find("Preset");
                    if (preset_tag_folder != null)
                    {
                        string table_name = "Preset_" + group_name;
                        task_dialog.AddTask(new CreatePresetHmiTagsTask(tiaPortal, tags, preset_tag_folder, table_name, group_name, db_name, hmi_db_name, nPresets));
                    }
                    else
                    {
                        MessageBox.Show("No HMI tag group name 'Preset' was found for HMI " + hmi.Name + ". No tag tables will be updated.");
                    }

                    // Load template screen

                    ScreenTemplate obj_templ = hmi.ScreenTemplateFolder.ScreenTemplates.Find("ObjectTemplate");
                    if (obj_templ != null)
                    {
                        XmlDocument templates = TIAutils.ExportScreenTemplateXML(obj_templ);

                        // Create popups
                        task_dialog.AddTask(new CreatePresetScreenPopupTask(tiaPortal, tags, popup_folder, templates, popup_name, group_name));
                    }
                    else
                    {
                        MessageBox.Show("No template screen named ObjectTemplate found for HMI " + hmi.Name + ". Some screens will not be updated.");
                    }
                }
            }


            task_dialog.Show();
        }
Example #20
0
 public void Execute(ArgumentList arguments, TaskList tasklist, TagList tags, TagFolder folder)
 {
     if (arguments.GetLength() == 1)
         Program.DisplayHelp();
 }