Example #1
0
        Widget CreateTagsTable(TagsGroup g)
        {
            int       i = 0;
            uint      rows, count;
            Alignment alignment;
            Table     t;

            count = (uint)g.tags.Count + 1;
            rows  = count / COLS_PER_ROW + 1;

            alignment             = new Alignment(0.5F, 0.5F, 1, 1);
            alignment.LeftPadding = 20;
            t               = new Table(rows, COLS_PER_ROW, false);
            t.RowSpacing    = 2;
            t.ColumnSpacing = 5;
            foreach (Tag tag in g.tags)
            {
                CreateTagBox(t, tag, i, g);
                i++;
            }
            var addb = CreateAddTagButton(g);

            InsertInTable(t, addb, i);
            alignment.Add(t);
            g.table = alignment;
            return(alignment);
        }
Example #2
0
        Button CreateAddTagButton(TagsGroup g)
        {
            Button b = CreateButton(Catalog.GetString("Add new tag"), IconSize.Button);

            b.Clicked += (sender, e) => AddTag(g);
            return(b);
        }
Example #3
0
        protected override void Initialize()
        {
            TagsGroup ag = TagsHelper.GetTagsGroup();

            DetailGridView.DataSource = ag.Items;
            DetailGridView.DataBind();
        }
Example #4
0
        /// <summary>
        /// 获取一个别名实体
        /// </summary>
        /// <returns></returns>
        public TagsGroup GetTagsGroup()
        {
            TagsGroup ag = new TagsGroup();

            ag.FromFile(SystemTagsPath, "Tags.xml");
            return(ag);
        }
Example #5
0
        string LoadTagDictionary()
        {
            string        tagA     = "<a href=\"javascript:addTag('{0}')\" title=\"为文章添加标签 {0}?\"  >{0}</a> ";
            int           maxCount = 20;
            StringBuilder sb       = new StringBuilder();

            TagsGroup ag = TagsHelper.GetTagsGroup();
            int       i  = 1;

            foreach (TagsGroup.Item tag in ag.Items)
            {
                sb.AppendLine(string.Format(tagA, tag.Words));
                if (i % 2 == 0)
                {
                    sb.AppendLine("<br/>");
                }
                if (i > maxCount)
                {
                    break;
                }
                i++;
            }

            return(sb.ToString());
        }
        public KamaAcquisitionFile(string filename, AcquisitionInterface acquisitionInterface, ILogger logger,
                                   int eitDefaultChunkSize = 24000, int ecgDefaultChunkSize = 10)
        {
            FileName            = filename;
            Logger              = logger;
            EITDefaultChunkSize = eitDefaultChunkSize;
            ECGDefaultChunkSize = ecgDefaultChunkSize;

            RecordNumber = 1;
            H5E.set_auto(H5E.DEFAULT, null, IntPtr.Zero);
            fileId               = Hdf5.CreateFile(filename);
            groupRoot            = fileId;
            groupEIT             = Hdf5.CreateOrOpenGroup(groupRoot, "eit");
            ProcedureInformation = new ProcedureInformation(fileId, groupRoot, logger)
            {
                ProcedureDirectory = Path.GetDirectoryName(filename),
                StartDateTime      = DateTime.Now,
                EndDateTime        = DateTime.Now
            };

            SystemInformation            = new SystemInformation(fileId, groupRoot, logger);
            SystemInformation.SystemType = acquisitionInterface.ToString();
            //  InjectionGroup = new InjectionGroup(fileId, groupRoot);
            CalibrationGroup = new CalibrationGroup(fileId, groupRoot, logger);
            SystemEvents     = new SystemEventGroup(fileId, groupRoot, logger);
            RPosition        = new RPositionGroup(fileId, groupRoot, logger);
            Tags             = new TagsGroup(fileId, groupRoot, logger);
            UserEventsGroup  = new UserEventsGroup(fileId, groupRoot, logger);
        }
Example #7
0
        void RemoveGroup(TagsGroup g)
        {
            string msg = Catalog.GetString("Do you want to remove this subcategory and all its tags?");

            if (Config.GUIToolkit.QuestionMessage(msg, null, this))
            {
                EventType.Tags.RemoveAll(g.tags.Contains);
                mainvbox.Remove(g.container);
            }
        }
        void RemoveGroup(TagsGroup g)
        {
            string msg = Catalog.GetString("Do you want to remove this subcategory and all its tags?");

            if (App.Current.Dialogs.QuestionMessage(msg, null, this).Result)
            {
                EventType.Tags.RemoveRange(g.tags);
                mainvbox.Remove(g.container);
            }
        }
Example #9
0
        void RemoveTag(Tag tag, TagsGroup g)
        {
            string msg = Catalog.GetString("Do you want to remove this tag?");

            if (Config.GUIToolkit.QuestionMessage(msg, null, this))
            {
                EventType.Tags.Remove(tag);
                g.tags.Remove(tag);
                g.container.Remove(g.table);
                g.container.PackStart(CreateTagsTable(g), true, true, 0);
                g.container.ShowAll();
            }
        }
Example #10
0
        void AddTag(TagsGroup g)
        {
            Tag t = new Tag(Catalog.GetString("New tag"), g.nameEntry.Text);

            EventType.Tags.Add(t);
            g.tags.Add(t);
            g.container.Remove(g.table);
            g.container.PackStart(CreateTagsTable(g), true, true, 0);
            g.container.ShowAll();
            if (focusEntry != null)
            {
                focusEntry.GrabFocus();
            }
        }
        void AddNewGroup(string name, List<Tag> tags)
        {
            TagsGroup g;
            Widget t;
            VBox vbox = new VBox (false, 5);
            HBox hbox = new HBox (false, 5);

            g = new TagsGroup (vbox, tags);
            hbox.PackStart (GroupBox (name, g), false, true, 0);
            t = CreateTagsTable (g);
            vbox.PackStart (hbox, true, true, 0);
            vbox.PackStart (t, true, true, 0);
            vbox.PackEnd (new HSeparator (), true, true, 0);
            vbox.ShowAll ();
            mainvbox.PackStart (vbox, true, true, 0);
        }
Example #12
0
        protected void QueryButton_Click(object sender, EventArgs e)
        {
            TagsGroup             ag    = TagsHelper.GetTagsGroup();
            List <TagsGroup.Item> items = new List <TagsGroup.Item>();

            foreach (TagsGroup.Item item in ag.Items)
            {
                if (item.Words.Contains(SearchTextBox.Text.Trim()))
                {
                    items.Add(item);
                }
            }
            DetailGridView.DataSource = items;
            DetailGridView.DataBind();
            // Initialize();
        }
Example #13
0
        void AddNewGroup(string name, List <Tag> tags)
        {
            TagsGroup g;
            Widget    t;
            VBox      vbox = new VBox(false, 5);
            HBox      hbox = new HBox(false, 5);

            g = new TagsGroup(vbox, tags);
            hbox.PackStart(GroupBox(name, g), false, true, 0);
            t = CreateTagsTable(g);
            vbox.PackStart(hbox, true, true, 0);
            vbox.PackStart(t, true, true, 0);
            vbox.PackEnd(new HSeparator(), true, true, 0);
            vbox.ShowAll();
            mainvbox.PackStart(vbox, true, true, 0);
        }
Example #14
0
        Box GroupBox(string name, TagsGroup g)
        {
            HBox   box   = new HBox(false, 5);
            Label  l     = new Label();
            Entry  entry = new Entry(name);
            Button b     = Button("gtk-remove");

            l.Markup       = Catalog.GetString("<b>Subcategory name:</b>");
            g.nameEntry    = entry;
            entry.Changed += (sender, e) => {
                foreach (Tag t in g.tags)
                {
                    t.Group = entry.Text;
                }
            };
            b.Clicked += (sender, e) => RemoveGroup(g);
            box.PackStart(l, false, false, 0);
            box.PackStart(entry, false, true, 0);
            box.PackStart(b, false, false, 0);
            return(box);
        }
Example #15
0
        void CreateTagBox(Table t, Tag tag, int i, TagsGroup g)
        {
            HBox   box         = new HBox(false, 2);
            Entry  tagEntry    = new Entry(tag.Value);
            Label  hotkeyLabel = new Label(tag.HotKey.ToString());
            Button editHK      = Button("gtk-edit");
            Button b           = Button("gtk-remove");

            b.Clicked += (sender, e) => RemoveTag(tag, g);

            editHK.Clicked += (sender, e) => {
                HotKey hotkey = Config.GUIToolkit.SelectHotkey(tag.HotKey);
                if (hotkey != null)
                {
                    try {
                        if (EventType.Tags.Select(tt => tt.HotKey).Contains(hotkey))
                        {
                            throw new HotkeyAlreadyInUse(hotkey);
                        }
                        tag.HotKey       = hotkey;
                        hotkeyLabel.Text = hotkey.ToString();
                    } catch (HotkeyAlreadyInUse ex) {
                        Config.GUIToolkit.ErrorMessage(ex.Message, this);
                    }
                }
            };

            tagEntry.Changed += (o, e) => {
                tag.Value = tagEntry.Text;
            };
            focusEntry = tagEntry;

            box.PackStart(tagEntry, false, false, 0);
            box.PackStart(hotkeyLabel, false, false, 0);
            box.PackStart(editHK, false, false, 0);
            box.PackStart(b, false, false, 0);
            InsertInTable(t, box, i);
        }
Example #16
0
        /// <summary>
        /// Loads and restores main storage
        /// </summary>
        /// <param name="target"></param>
        /// <returns></returns>
        public Store Load(string target)
        {
            var context = new StoreContext(target);

            var store  = new Store();
            var scales = new Dictionary <int, Scale>();

            foreach (var scaleCfg in context.Scales)
            {
                scales.Add(
                    scaleCfg.Id,
                    new Scale {
                    Name        = scaleCfg.Name,
                    Description = scaleCfg.Description,
                    Units       = scaleCfg.Units,
                    DevMax      = scaleCfg.DevMax,
                    DevMin      = scaleCfg.DevMin,
                    Max         = scaleCfg.Max,
                    Min         = scaleCfg.Min,
                }
                    );
            }


            foreach (var cfg in context.Connections)
            {
                var connectionSource = connectionSerializers[cfg.ClassName].Unpack(cfg);
                store.ConnectionsSources.Add(cfg.Name, connectionSource);
            }

            var storedDeviceToTemplates = context.DeviceToTemplates
                                          .Include(e => e.Device)
                                          .Include(e => e.Template)
                                          .ThenInclude(e => e.Tags)
                                          .ThenInclude((TagCfg e) => e.TagsToTagsGroups)
                                          .ThenInclude((TagsToTagsGroups e) => e.TagsGroupCfg)
                                          .Include(e => e.Template)
                                          .ThenInclude(e => e.Alarms)
                                          .ThenInclude((AlarmCfg e) => e.Category)
                                          .Include(e => e.Template)
                                          .ThenInclude(e => e.Archives)
                                          .ToList();

            var facilityConfigs = context.Facilities.Include(e => e.Devices).ToList();

            foreach (var facilityCfg in facilityConfigs)
            {
                var facility = new Facility
                {
                    AccessName  = facilityCfg.AccessName,
                    Name        = facilityCfg.Name,
                    Description = facilityCfg.Description,
                    Id          = facilityCfg.Id,
                };


                foreach (var deviceCfg in facilityCfg.Devices)
                {
                    var protocolSerializer = protorolSerializers[deviceCfg.ClassName];
                    var device             = protocolSerializer.UnpackDevice(deviceCfg, store);

                    // Обработка шаблона (переделать этот код когда в EF Core будет реализован релейшн many2many)
                    foreach (var deviceToTemplate in storedDeviceToTemplates.Where(e => e.DeviceId == deviceCfg.Id))
                    {
                        var template = deviceToTemplate.Template;
                        // Распакуем тэги
                        foreach (var tagCfg in template.Tags)
                        {
                            var tag = protocolSerializer.UnpackTag(tagCfg);
                            tag.TemplateId = template.Id;
                            if (scales.ContainsKey(tagCfg.ScaleId))
                            {
                                tag.Scale = scales[tagCfg.ScaleId];
                            }

                            // добавим/восстановим/создадим группы тэгов

                            foreach (var tttg in tagCfg.TagsToTagsGroups)
                            {
                                var       tagGroupCfg = tttg.TagsGroupCfg;
                                TagsGroup tagGroup;
                                if (device.Groups.ContainsKey(tagGroupCfg.Name))
                                {
                                    tagGroup = device.Groups[tagGroupCfg.Name];
                                }
                                else
                                {
                                    tagGroup = new TagsGroup
                                    {
                                        Name        = tagGroupCfg.Name,
                                        Description = tagGroupCfg.Description,
                                        Min         = tagGroupCfg.Min,
                                    };
                                    device.Groups.AddByName(tagGroup);
                                }
                                tag.Groups.AddByName(tagGroup);
                            }

                            // добавим тэг в сервис архива
                            if (tagCfg.ArchiveCfg != default)
                            {
                                var tagLogConfig = new TagLogger.TagLogConfig(tag)
                                {
                                    Hyst         = tagCfg.ArchiveCfg.Hyst,
                                    PeriodMaxSec = tagCfg.ArchiveCfg.PeriodMaxSec,
                                    PeriodMinSec = tagCfg.ArchiveCfg.PeriodMinSec,
                                    TagLogInfo   = new TagLogger.Entities.TagLogInfo
                                    {
                                        DeviceName         = deviceCfg.Name,
                                        FacilityAccessName = facilityCfg.AccessName,
                                        TagName            = tagCfg.Name,
                                    }
                                };

                                store.TagLogService.Configs.Add(tagLogConfig);
                            }

                            device.Tags.AddByName(tag);
                        }

                        // Распакуем алармы
                        foreach (var alarmCfg in template.Alarms)
                        {
                            var alarmInfo = new AlarmLogger.Entities.AlarmInfo
                            {
                                Category           = alarmCfg.Category,
                                Name               = alarmCfg.Name,
                                Condition          = alarmCfg.Condition,
                                Description        = alarmCfg.Description,
                                DeviceName         = device.Name,
                                FacilityAccessName = facility.AccessName,
                                TemplateTxt        = alarmCfg.TemplateTxt,
                            };
                            var alarmConfig = AlarmLogger.AlarmConfig.From(alarmCfg, device.Tags.Values, alarmInfo);
                            store.AlarmService.Configs.Add(alarmConfig);
                        }
                    }

                    facility.Devices.AddByName(device);
                }

                store.Facilities.Add(facility.AccessName, facility);
            }
            context.Dispose();
            context = null;
            return(store);
        } // Load();
 Button CreateAddTagButton(TagsGroup g)
 {
     Button b = CreateButton (Catalog.GetString ("Add new tag"), IconSize.Button);
     b.Clicked += (sender, e) => AddTag (g);
     return b;
 }
        void CreateTagBox(Table t, Tag tag, int i, TagsGroup g)
        {
            HBox box = new HBox (false, 2);
            Entry tagEntry = new Entry (tag.Value);
            Label hotkeyLabel = new Label (tag.HotKey.ToString ());
            Button editHK = Button ("gtk-edit");
            Button b = Button ("gtk-remove");

            b.Clicked += (sender, e) => RemoveTag (tag, g);

            editHK.Clicked += (sender, e) => {
                HotKey hotkey = App.Current.GUIToolkit.SelectHotkey (tag.HotKey);
                if (hotkey != null) {
                    try {
                        if (EventType.Tags.Select (tt => tt.HotKey).Contains (hotkey)) {
                            throw new HotkeyAlreadyInUse (hotkey);
                        }
                        tag.HotKey = hotkey;
                        hotkeyLabel.Text = hotkey.ToString ();
                    } catch (HotkeyAlreadyInUse ex) {
                        App.Current.Dialogs.ErrorMessage (ex.Message, this);
                    }
                }
            };

            tagEntry.Changed += (o, e) => {
                tag.Value = tagEntry.Text;
            };
            focusEntry = tagEntry;

            box.PackStart (tagEntry, false, false, 0);
            box.PackStart (hotkeyLabel, false, false, 0);
            box.PackStart (editHK, false, false, 0);
            box.PackStart (b, false, false, 0);
            InsertInTable (t, box, i);
        }
        Widget CreateTagsTable(TagsGroup g)
        {
            int i = 0;
            uint rows, count;
            Alignment alignment;
            Table t;

            count = (uint)g.tags.Count + 1;
            rows = count / COLS_PER_ROW + 1;

            alignment = new Alignment (0.5F, 0.5F, 1, 1);
            alignment.LeftPadding = 20;
            t = new Table (rows, COLS_PER_ROW, false);
            t.RowSpacing = 2;
            t.ColumnSpacing = 5;
            foreach (Tag tag in g.tags) {
                CreateTagBox (t, tag, i, g);
                i++;
            }
            var addb = CreateAddTagButton (g);
            InsertInTable (t, addb, i);
            alignment.Add (t);
            g.table = alignment;
            return alignment;
        }
        Box GroupBox(string name, TagsGroup g)
        {
            HBox box = new HBox (false, 5);
            Label l = new Label ();
            Entry entry = new Entry (name);
            Button b = Button ("gtk-remove");

            l.Markup = Catalog.GetString ("<b>Subcategory name:</b>");
            g.nameEntry = entry;
            entry.Changed += (sender, e) => {
                foreach (Tag t in g.tags) {
                    t.Group = entry.Text;
                }
            };
            b.Clicked += (sender, e) => RemoveGroup (g);
            box.PackStart (l, false, false, 0);
            box.PackStart (entry, false, true, 0);
            box.PackStart (b, false, false, 0);
            return box;
        }
 void RemoveGroup(TagsGroup g)
 {
     string msg = Catalog.GetString ("Do you want to remove this subcategory and all its tags?");
     if (App.Current.Dialogs.QuestionMessage (msg, null, this).Result) {
         EventType.Tags.RemoveAll (g.tags.Contains);
         mainvbox.Remove (g.container);
     }
 }
 void RemoveTag(Tag tag, TagsGroup g)
 {
     string msg = Catalog.GetString ("Do you want to remove this tag?");
     if (App.Current.Dialogs.QuestionMessage (msg, null, this).Result) {
         EventType.Tags.Remove (tag);
         g.tags.Remove (tag);
         g.container.Remove (g.table);
         g.container.PackStart (CreateTagsTable (g), true, true, 0);
         g.container.ShowAll ();
     }
 }
Example #23
0
            protected override bool ParseInternal(ParseContext context)
            {
                var startPos = context.Position;

                if (this.OpenTag == null)
                {
                    this.ReadSpaces(context);
                    this.OpenTag = this.ReadSingle <Tag>(context);
                }
                if (this.OpenTag != null)
                {
                    int textStart  = context.Position;
                    int textLength = 0;
                    while (true)
                    {
                        Tag tag = new Tag {
                            Source = this.Source, Start = context.Position
                        };
                        while (!tag.MarkBeginAndParse(context))
                        {
                            if (context.Position >= context.Source.Length)
                            {
                                context.Position = startPos;
                                return(false);
                            }
                            context.Position++;
                            textLength++;
                        }
                        if (!tag.IsEndTag)
                        {
                            var tagGrpStart = context.Position;
                            var tagGrup     = new TagsGroup(tag);
                            if (tagGrup.Parse(context))
                            {
                                if (textLength > 0)
                                {
                                    if (this.Contents == null)
                                    {
                                        this.Contents = new List <Match>();
                                    }
                                    this.Contents.Add(new Text {
                                        Source = this.Source, Start = textStart, Length = textLength
                                    });
                                    textStart  = context.Position;
                                    textLength = 0;
                                }
                                this.Contents.Add(tagGrup);
                            }
                            else
                            {
                                textLength += tag.Length;
                            }
                        }
                        else
                        {
                            if (tag.Name == this.OpenTag.Name)
                            {
                                if (textLength > 0)
                                {
                                    if (this.Contents == null)
                                    {
                                        this.Contents = new List <Match>();
                                    }
                                    this.Contents.Add(new Text {
                                        Source = this.Source, Start = textStart, Length = textLength
                                    });
                                    textStart  = context.Position;
                                    textLength = 0;
                                }
                                this.CloseTag = tag;
                                return(true);
                            }
                            else
                            {
                                textLength += tag.Length;
                            }
                        }
                    }
                }
                context.Position = startPos;
                return(false);
            }
 void AddTag(TagsGroup g)
 {
     Tag t = new Tag (Catalog.GetString ("New tag"), g.nameEntry.Text);
     EventType.Tags.Add (t);
     g.tags.Add (t);
     g.container.Remove (g.table);
     g.container.PackStart (CreateTagsTable (g), true, true, 0);
     g.container.ShowAll ();
     if (focusEntry != null) {
         focusEntry.GrabFocus ();
     }
 }