Ejemplo n.º 1
0
        /// <summary>
        /// 定时发送MES心跳信号线程,目前固定每隔2秒钟发送一次,间隔时间不能修改
        /// </summary>
        private void MESHeartBeat()
        {
            while (!threadTerminated)
            {
                DateTime now = DateTime.Now;
                if (cycleReadConnection != null)
                {
                    TimeSpan timeSpan = now - LastMESHearBeatTime;
                    if (timeSpan.TotalMilliseconds >= 2000)
                    {
                        CustomTag tag = FindTag("COMM", "MES_Heart_Beat");
                        if (tag != null && tag is SiemensBoolOfTag)
                        {
                            SiemensBoolOfTag heartBeatTag = tag as SiemensBoolOfTag;
                            heartBeatTag.Value = !heartBeatTag.Value;
                            try
                            {
                                cycleReadConnection.WriteToPLC(
                                    DBType,
                                    DBNumber,
                                    heartBeatTag);
                            }
                            catch (Exception error)
                            {
                                _log.Error(error.Message, error);
                            }
                        }

                        LastMESHearBeatTime = now;
                    }
                }

                Thread.Sleep(500);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 构造方法
        /// </summary>
        /// <param name="parent">TagGroup对象</param>
        /// <param name="node">SubTagGroup属性的Xml节点</param>
        /// <param name="eventTagRegister">西门子Tag注册委托</param>
        public SiemensSubTagGroup(
            CustomTagGroup parent,
            XmlNode node,
            TagRegisterHandler eventTagRegister) : base(parent, node)
        {
            _tagRegisterInParentHandler = eventTagRegister;
            _log  = Logger.Get <SiemensSubTagGroup>();
            _tags = new SiemensTagCollection(this, OnTagInGroupRegister);

            if (!(parent is SiemensTagGroup))
            {
                throw new Exception("parent对象必须是SiemensTagGroup对象");
            }

            _log.Trace($"创建[SubTagGroup={Prefix}]");

            XmlNode childNode = node.FirstChild;

            while (childNode != null)
            {
                SiemensTagCreator creator = new SiemensTagCreator();
                CustomTag         tag     = creator.CreateProduct(this, childNode);
                if (tag != null)
                {
                    _tags.Add(tag);
                }

                childNode = childNode.NextSibling;
            }
        }
Ejemplo n.º 3
0
        public void AttributeParametersSet()
        {
            CustomTag inst = factory.CreateTagInstance(CustomTagFactoryTests.CUSTOM_TAG, tagWithAttribParams);

            Assert.AreEqual("Foo", inst.Parameters["name"]);
            Assert.AreEqual("Bar", inst.Parameters["place"]);
        }
Ejemplo n.º 4
0
        public void TagSimpleElementParametersRender()
        {
            string content  = "My favorite color is {0}";
            string param    = "color";
            string tag      = "x:Foo";
            string val      = "blue";
            string template = "<script type='text/os-template' tag='{0}'>\n{1}</script>";

            template = String.Format(template, tag, string.Format(content, "${My." + param + "}"));

            string elemInstMarkup = "<{0}><{1}>{2}</{1}></{0}>";


            string tagInstanceMarkup = string.Format(elemInstMarkup, new string[] { tag, param, val });
            string expected          = string.Format(content, val);

            factory.RegisterCustomTag(tag, template);
            CustomTag inst = factory.CreateTagInstance(tag, tagInstanceMarkup);

            Assert.AreEqual(val, inst.Parameters[param], "Registered instance value incorrect");

            string result = ControlTestHelper.GetRenderedContents(inst);

            result = ControlTestHelper.NormalizeRenderResult(result);
            Assert.AreEqual(expected, result, "Rendered results incorrect");
        }
Ejemplo n.º 5
0
 public static void Init()
 {
     JMMUser.Populate(a => a.JMMUserID);
     CloudAccount.Populate(a => a.CloudID);
     ImportFolder.Populate(a => a.ImportFolderID);
     AniDB_Anime.Populate(a => a.AniDB_AnimeID);
     AniDB_Episode.Populate(a => a.AniDB_EpisodeID);
     AniDB_File.Populate(a => a.AniDB_FileID);
     AniDB_Anime_Title.Populate(a => a.AniDB_Anime_TitleID);
     AniDB_Anime_Tag.Populate(a => a.AniDB_Anime_TagID);
     AniDB_Tag.Populate(a => a.AniDB_TagID);
     CustomTag.Populate(a => a.CustomTagID);
     CrossRef_CustomTag.Populate(a => a.CrossRef_CustomTagID);
     CrossRef_File_Episode.Populate(a => a.CrossRef_File_EpisodeID);
     VideoLocalPlace.Populate(a => a.VideoLocal_Place_ID);
     VideoLocal.Populate(a => a.VideoLocalID);
     VideoLocalUser.Populate(a => a.VideoLocal_UserID);
     GroupFilter.Populate(a => a.GroupFilterID);
     AnimeEpisode.Populate(a => a.AnimeEpisodeID);
     AnimeEpisode_User.Populate(a => a.AnimeEpisode_UserID);
     AnimeSeries.Populate(a => a.AnimeSeriesID);
     AnimeSeries_User.Populate(a => a.AnimeSeries_UserID);
     AnimeGroup.Populate(a => a.AnimeGroupID);
     AnimeGroup_User.Populate(a => a.AnimeGroup_UserID);
     GroupFilter.PostProcess();
     CleanUpMemory();
 }
Ejemplo n.º 6
0
    // OnTriggerEnter() event listener.
    private void OnTriggerEnter(Collider other)
    {
        Transform otherTransform  = other.transform;
        Transform parentTransform = otherTransform.parent;

        CustomTag customTag = otherTransform.GetComponent(typeof(CustomTag)) as CustomTag;

        if (otherTransform.CompareTag(interactableTag) && customTag != null && customTag.hasTag(targetTag))
        {
            detachControllerObjects(otherTransform, parentTransform);

            // Destroy Other Children
            foreach (Transform child in otherTransform)
            {
                Destroy(child.gameObject);
            }

            // Destroy Other
            Destroy(otherTransform.gameObject);

            // Destroy Other Parent
            if (parentTransform != null)
            {
                Destroy(parentTransform.gameObject);
            }
        }
    }
Ejemplo n.º 7
0
        private void OnTicketTagAdded(string obj)
        {
            var cachedTag = AppServices.MainDataContext.SelectedDepartment.TicketTagGroups.Single(
                x => x.Id == SelectedTicketTag.Id);

            Debug.Assert(cachedTag != null);
            var ctag = cachedTag.TicketTags.SingleOrDefault(x => x.Name.ToLower() == CustomTag.ToLower());

            if (ctag == null && cachedTag.SaveFreeTags)
            {
                using (var workspace = WorkspaceFactory.Create())
                {
                    var tt = workspace.Single <TicketTagGroup>(x => x.Id == SelectedTicketTag.Id);
                    Debug.Assert(tt != null);
                    var tag = tt.TicketTags.SingleOrDefault(x => x.Name.ToLower() == CustomTag.ToLower());
                    if (tag == null)
                    {
                        tag = new TicketTag()
                        {
                            Name = CustomTag
                        };
                        tt.TicketTags.Add(tag);
                        workspace.Add(tag);
                        workspace.CommitChanges();
                    }
                }
            }
            DataContext.SelectedTicket.UpdateTag(SelectedTicketTag, new TicketTag {
                Name = CustomTag
            });
            CustomTag = string.Empty;
            InvokeTagUpdated(SelectedTicketTag);
        }
        public void ParentConnections()
        {
            CreateParser("<custom>" + "<custom>something</custom>" + "</custom>");
            parser.AddScanner(new CustomScanner(this, false));
            parser.AddScanner(new AnotherScanner());
            ParseAndAssertNodeCount(3);

            CustomTag customTag = (CustomTag)node[0];

            AssertStringEquals("first custom tag html", "<CUSTOM></CUSTOM>", customTag.ToHtml());
            Assert.IsNull(customTag.Parent, "first custom tag should have no parent");

            customTag = (CustomTag)node[1];
            AssertStringEquals("first custom tag html", "<CUSTOM>something</CUSTOM>", customTag.ToHtml());
            Assert.IsNull(customTag.Parent, "second custom tag should have no parent");

            Node firstChild = customTag[0];

            AssertType("firstChild", typeof(StringNode), firstChild);
            CompositeTag parent = firstChild.Parent;

            Assert.IsNotNull(parent, "first child parent should not be null");
            Assert.AreSame(customTag, parent, "parent and custom tag should be the same");

            EndTag endTag = (EndTag)node[2];

            AssertStringEquals("first custom tag html", "</CUSTOM>", endTag.ToHtml());
            Assert.IsNull(endTag.Parent, "end tag should have no parent");
        }
        public void CompositeTagWithDeadlock()
        {
            CreateParser("<custom>" + "<another>something" + "</custom>" + "<custom>" + "<another>else</another>" +
                         "</custom>");
            parser.AddScanner(new AnotherScanner(true));
            CustomTag customTag = ParseCustomTag(2);
            int       x         = customTag.ChildCount;

            Assert.AreEqual(1, customTag.ChildCount, "child count");
            Assert.IsFalse(customTag.EmptyXmlTag, "custom tag should not be xml end tag");
            Assert.AreEqual(0, customTag.StartTag.ElementBegin, "starting loc");
            Assert.AreEqual(7, customTag.StartTag.ElementEnd, "ending loc");
            Assert.AreEqual(1, customTag.tagData.StartLine, "starting line position");
            Assert.AreEqual(1, customTag.tagData.EndLine, "ending line position");
            AnotherTag anotherTag = (AnotherTag)customTag[0];

            Assert.AreEqual(1, anotherTag.ChildCount, "anotherTag child count");
            StringNode stringNode = (StringNode)anotherTag[0];

            AssertStringEquals("anotherTag child text", "something", stringNode.ToPlainTextString());
            AssertStringEquals("first custom tag html", "<CUSTOM><ANOTHER>something</ANOTHER></CUSTOM>",
                               customTag.ToHtml());
            customTag = (CustomTag)node[1];
            AssertStringEquals("second custom tag html", "<CUSTOM><ANOTHER>else</ANOTHER></CUSTOM>", customTag.ToHtml());
        }
        public void CompositeTagWithAnotherTagChild()
        {
            CreateParser("<Custom>" + "<Another/>" + "</Custom>");
            parser.AddScanner(new AnotherScanner());
            CustomTag customTag = ParseCustomTag(1);
            int       x         = customTag.ChildCount;

            Assert.AreEqual(1, customTag.ChildCount, "child count");
            Assert.IsFalse(customTag.EmptyXmlTag, "custom tag should not be xml end tag");
            Assert.AreEqual(0, customTag.StartTag.ElementBegin, "starting loc");
            Assert.AreEqual(7, customTag.StartTag.ElementEnd, "ending loc");
            Assert.AreEqual(0, customTag.ElementBegin, "custom tag starting loc");
            Assert.AreEqual(26, customTag.ElementEnd, "custom tag ending loc");

            Node child = customTag[0];

            AssertType("child", typeof(AnotherTag), child);
            AnotherTag tag = (AnotherTag)child;

            Assert.AreEqual(8, tag.ElementBegin, "another tag start pos");
            Assert.AreEqual(17, tag.ElementEnd, "another tag ending pos");

            Assert.AreEqual(18, customTag.EndTag.ElementBegin, "custom end tag start pos");
            AssertStringEquals("child html", "<ANOTHER/>", child.ToHtml());
        }
Ejemplo n.º 11
0
    private void ProcessAsteroid(Collider2D other)
    {
        CustomTag ct = other.GetComponent <CustomTag>();

        if (ct != null && !ct.HasTag("grabbed"))
        {
            float amount;
            if (ct.HasTag("ice"))
            {
                AudioManager.Instance.PlayAsteroidCollected(other.transform.position, 1f);
                amount = other.GetComponent <Rigidbody2D>().mass;
                Destroy(other.gameObject);
                ship.ice += amount;
                if (QuestManager.instance.currentQuest.goal.goalType == GoalType.CollectIce)
                {
                    QuestManager.instance.currentQuest.goal.currentAmount = (int)ship.ice;
                }
            }
            else if (ct.HasTag("iron"))
            {
                AudioManager.Instance.PlayAsteroidCollected(other.transform.position, 1f);
                amount = other.GetComponent <Rigidbody2D>().mass;
                Destroy(other.gameObject);
                ship.iron += amount;
                if (QuestManager.instance.currentQuest.goal.goalType == GoalType.CollectIron)
                {
                    QuestManager.instance.currentQuest.goal.currentAmount = (int)ship.iron;
                }
            }
        }
    }
Ejemplo n.º 12
0
        public static void Init()
        {
            JMMUser.Populate();
            CloudAccount.Populate();
            ImportFolder.Populate();
            AniDB_Anime.Populate();
            AniDB_Episode.Populate();
            AniDB_File.Populate();
            AniDB_Anime_Title.Populate();
            AniDB_Anime_Tag.Populate();
            AniDB_Tag.Populate();
            CustomTag.Populate();
            CrossRef_CustomTag.Populate();
            CrossRef_File_Episode.Populate();
            VideoLocalPlace.Populate();
            VideoLocal.Populate();
            VideoLocalUser.Populate();
            GroupFilter.Populate();
            AnimeEpisode.Populate();
            AnimeEpisode_User.Populate();
            AnimeSeries.Populate();
            AnimeSeries_User.Populate();
            AnimeGroup.Populate();
            AnimeGroup_User.Populate();

            // Update Contracts if necessary
            try
            {
                JMMUser.RegenerateDb();
                CloudAccount.RegenerateDb();
                ImportFolder.RegenerateDb();
                AniDB_Anime.RegenerateDb();
                AniDB_Episode.RegenerateDb();
                AniDB_File.RegenerateDb();
                AniDB_Anime_Title.RegenerateDb();
                AniDB_Anime_Tag.RegenerateDb();
                AniDB_Tag.RegenerateDb();
                CustomTag.RegenerateDb();
                CrossRef_CustomTag.RegenerateDb();
                CrossRef_File_Episode.RegenerateDb();
                VideoLocalPlace.RegenerateDb();
                VideoLocal.RegenerateDb();
                VideoLocalUser.RegenerateDb();
                AnimeEpisode.RegenerateDb();
                AnimeEpisode_User.RegenerateDb();
                AnimeSeries.RegenerateDb();
                AnimeSeries_User.RegenerateDb();
                AnimeGroup.RegenerateDb();
                AnimeGroup_User.RegenerateDb();

                GroupFilter.RegenerateDb();
                GroupFilter.PostProcess();
            }
            catch (Exception e)
            {
                LogManager.GetCurrentClassLogger().Error(e, "There was an error starting the Database Factory");
            }
            CleanUpMemory();
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 构造方法
        /// </summary>
        /// <param name="parent">TagGroup对象所依赖的Device对象</param>
        /// <param name="node">TagGroup对象属性的Xml节点</param>
        /// <param name="eventTagRegister">西门子Tag注册委托</param>
        public SiemensTagGroup(
            CustomDevice parent,
            XmlNode node,
            TagRegisterHandler eventTagRegister) : base(parent, node)
        {
            if (!(parent is SiemensDevice))
            {
                throw new Exception("parent对象必须是SiemensDevice对象");
            }

            if (node.Name.ToUpper() != "TAGGROUP")
            {
                throw new Exception($"Xml节点[{node.Name}]不是\"TagGroup\"");
            }

            _tagRegisterInParentHandler = eventTagRegister;

            _log    = Logger.Get <SiemensTagGroup>();
            _tags   = new SiemensTagCollection(this, OnTagInGroupRegister);
            _groups = new SiemensSubTagGroupCollection(this);

            _log.Trace($"创建TagGroup[{Name}]");

            #region 创建Tag
            if (node.HasChildNodes)
            {
                SiemensTagCreator creator   = new SiemensTagCreator();
                XmlNode           childNode = node.FirstChild;
                while (childNode != null)
                {
                    string nodeName = childNode.Name.ToUpper();
                    switch (nodeName)
                    {
                    case "TAG":
                        CustomTag tag = creator.CreateProduct(this, childNode);
                        if (tag != null)
                        {
                            _tags.Add(tag);
                        }
                        break;

                    case "SUBTAGGROUP":
                        SiemensSubTagGroup subTagGroup =
                            new SiemensSubTagGroup(
                                this,
                                childNode,
                                OnTagInGroupRegister);
                        if (subTagGroup != null)
                        {
                            _groups.Add(subTagGroup);
                        }
                        break;
                    }

                    childNode = childNode.NextSibling;
                }
            }
            #endregion
        }
Ejemplo n.º 14
0
        public IElement <CustomTag, IElement <TTag, TParent> > AddCustomChild(string name)
        {
            var tag   = new CustomTag(name);
            var child = new Element <CustomTag, IElement <TTag, TParent> >(Document, Root, this, tag, serializerFactory);

            childs.Add(child);
            return(child);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Tag对象注册事件
        /// </summary>
        /// <param name="group">TagGroup对象</param>
        /// <param name="tag">Tag对象</param>
        private void OnTagInGroupRegister(CustomGroup group, CustomTag tag)
        {
            _tagRegisterInParentHandler?.Invoke(group, tag);

            SiemensTag siemensTag = tag as SiemensTag;

            Block.Add(siemensTag.DB_Offset, siemensTag.Length);
        }
Ejemplo n.º 16
0
        public void TestRenderStaticTag()
        {
            CustomTag inst = factory.CreateTagInstance(CustomTagFactoryTests.CUSTOM_TAG);

            string result = ControlTestHelper.GetRenderedContents(inst);

            Assert.AreEqual(CustomTagFactoryTests.CUSTOM_TAG_RESULT, result);
        }
Ejemplo n.º 17
0
        public void CreateInitialCustomTags()
        {
            try
            {
                // group filters

                if (RepoFactory.CustomTag.GetAll().Count() > 0)
                {
                    return;
                }

                Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(ServerSettings.Culture);

                // Dropped
                CustomTag tag = new CustomTag
                {
                    TagName        = Commons.Properties.Resources.CustomTag_Dropped,
                    TagDescription = Commons.Properties.Resources.CustomTag_DroppedInfo
                };
                RepoFactory.CustomTag.Save(tag);

                // Pinned
                tag = new CustomTag
                {
                    TagName        = Commons.Properties.Resources.CustomTag_Pinned,
                    TagDescription = Commons.Properties.Resources.CustomTag_PinnedInfo
                };
                RepoFactory.CustomTag.Save(tag);

                // Ongoing
                tag = new CustomTag
                {
                    TagName        = Commons.Properties.Resources.CustomTag_Ongoing,
                    TagDescription = Commons.Properties.Resources.CustomTag_OngoingInfo
                };
                RepoFactory.CustomTag.Save(tag);

                // Waiting for Series Completion
                tag = new CustomTag
                {
                    TagName        = Commons.Properties.Resources.CustomTag_SeriesComplete,
                    TagDescription = Commons.Properties.Resources.CustomTag_SeriesCompleteInfo
                };
                RepoFactory.CustomTag.Save(tag);

                // Waiting for Bluray Completion
                tag = new CustomTag
                {
                    TagName        = Commons.Properties.Resources.CustomTag_BlurayComplete,
                    TagDescription = Commons.Properties.Resources.CustomTag_BlurayCompleteInfo
                };
                RepoFactory.CustomTag.Save(tag);
            }
            catch (Exception ex)
            {
                Logger.Error(ex, "Could not Create Initial Custom Tags: " + ex);
            }
        }
Ejemplo n.º 18
0
        public void TestRegisterTag()
        {
            string tag = CustomTagFactoryTests.CUSTOM_TAG;

            CustomTag inst = factory.CreateTagInstance(tag);

            Assert.AreEqual(tag, inst.MarkupTag);
            Assert.AreEqual(tag, template.Tag);
        }
        private CustomTag ParseCustomTag(int expectedNodeCount)
        {
            parser.AddScanner(new CustomScanner(this));
            ParseAndAssertNodeCount(expectedNodeCount);
            AssertType("node", typeof(CustomTag), node[0]);
            CustomTag customTag = (CustomTag)node[0];

            return(customTag);
        }
        private void CommandBinding_DeleteCustomTag(object sender, ExecutedRoutedEventArgs e)
        {
            object obj = e.Parameter;

            if (obj == null)
            {
                return;
            }

            try
            {
                Cursor = Cursors.Wait;
                string res = "";


                // NOTE if we are disabling an image we should also make sure it is not the default
                CustomTag tag = null;
                if (obj.GetType() == typeof(CustomTag))
                {
                    tag = (CustomTag)obj;
                    res = VM_ShokoServer.Instance.ShokoServices.DeleteCustomTag(tag.CustomTagID);
                }

                if (res.Length > 0)
                {
                    MessageBox.Show(res, Shoko.Commons.Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
                }
                else
                {
                    CustomTag ctagToRemove = null;
                    foreach (CustomTag ctag in VM_ShokoServer.Instance.AllCustomTags)
                    {
                        if (ctag.CustomTagID == tag.CustomTagID)
                        {
                            ctagToRemove = ctag;
                            break;
                        }
                    }

                    if (ctagToRemove != null)
                    {
                        VM_ShokoServer.Instance.AllCustomTags.Remove(ctagToRemove);
                        VM_ShokoServer.Instance.ViewCustomTagsAll.Refresh();

                        //TODO: Custom Tags -  update any cached data for affected anime
                    }
                }
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
            finally
            {
                Cursor = Cursors.Arrow;
            }
        }
Ejemplo n.º 21
0
        public CustomTag GetByTagID(int id, ISession session)
        {
            CustomTag cr = session
                           .CreateCriteria(typeof(CustomTag))
                           .Add(Restrictions.Eq("CustomTagID", id))
                           .UniqueResult <CustomTag>();

            return(cr);
        }
Ejemplo n.º 22
0
        public static void DrawTagHelpLabel()
        {
            string tagsText = TextTagParser.GetTagHelp();

            if (CustomTag.activeCustomTags.Count > 0)
            {
                tagsText += "\n\n\t-------- CUSTOM TAGS --------";
                List <Transform> activeCustomTagGroup = new List <Transform>();
                foreach (CustomTag ct in CustomTag.activeCustomTags)
                {
                    if (ct.transform.parent != null)
                    {
                        if (!activeCustomTagGroup.Contains(ct.transform.parent.transform))
                        {
                            activeCustomTagGroup.Add(ct.transform.parent.transform);
                        }
                    }
                    else
                    {
                        activeCustomTagGroup.Add(ct.transform);
                    }
                }
                foreach (Transform parent in activeCustomTagGroup)
                {
                    string    tagName        = parent.name;
                    string    tagStartSymbol = "";
                    string    tagEndSymbol   = "";
                    CustomTag parentTag      = parent.GetComponent <CustomTag>();
                    if (parentTag != null)
                    {
                        tagName        = parentTag.name;
                        tagStartSymbol = parentTag.TagStartSymbol;
                        tagEndSymbol   = parentTag.TagEndSymbol;
                    }
                    tagsText += "\n\n\t" + tagStartSymbol + " " + tagName + " " + tagEndSymbol;
                    foreach (Transform child in parent)
                    {
                        tagName        = child.name;
                        tagStartSymbol = "";
                        tagEndSymbol   = "";
                        CustomTag childTag = child.GetComponent <CustomTag>();
                        if (childTag != null)
                        {
                            tagName        = childTag.name;
                            tagStartSymbol = childTag.TagStartSymbol;
                            tagEndSymbol   = childTag.TagEndSymbol;
                        }
                        tagsText += "\n\t      " + tagStartSymbol + " " + tagName + " " + tagEndSymbol;
                    }
                }
            }
            tagsText += "\n";
            float pixelHeight = EditorStyles.miniLabel.CalcHeight(new GUIContent(tagsText), EditorGUIUtility.currentViewWidth);

            EditorGUILayout.SelectableLabel(tagsText, GUI.skin.GetStyle("HelpBox"), GUILayout.MinHeight(pixelHeight));
        }
Ejemplo n.º 23
0
        private String RenderCustomTag(CustomTag customTag, Type tagType)
        {
            var    tagRenderer = CustomTagRendererFactory.Create(tagType);
            String result      = "";

            EvalExpressions(customTag.LiquidExpressionTrees,
                            args => result   = tagRenderer.Render(_templateContext, args.ToList()).StringVal,
                            errors => result = FormatErrors(errors));
            return(result);
        }
Ejemplo n.º 24
0
        /// <summary>
        /// 控制Tag值变化后的操作
        /// </summary>
        /// <param name="tag">控制Tag对象</param>
        private void ControlTagValueChanged(CustomTag tag)
        {
            DCSGatewayLogEntity log = new DCSGatewayLogEntity();

            log.TriggerTag.TagName = tag.Name;
            log.TriggerTag.Offset  = tag.DB_Offset.ToString();
            if (tag is SiemensBoolOfTag ltag)
            {
                log.TriggerTag.Offset += $".{ltag.Position}";
            }

            Stopwatch sw = new Stopwatch();

            sw.Start();
            IIRAPDCSTrade trade =
                IRAPDCSTraderCreator
                .CreateInstance(
                    tag.Name.Replace("_", ""),
                    log);

            if (trade != null)
            {
                List <SiemensTag> writeTags = trade.Do(this, tag as SiemensTag);
                foreach (SiemensTag writeTag in writeTags)
                {
                    try
                    {
                        specialRWConnection.WriteToPLC(DBType, DBNumber, writeTag);
                    }
                    catch (Exception error)
                    {
                        log.Errors.Add(error);
                        _log.Error(
                            $"写[{writeTag.Name}]的时候出错:{error.Message}", error);
                    }
                }
            }
            sw.Stop();
            _log.Debug($"触发信号[{tag.Name}]的执行时长:[{sw.ElapsedMilliseconds}]毫秒");
            log.TotalExecutionTime = sw.ElapsedMilliseconds;

            try
            {
                if (log.ActionCode != "GetOPCStatus" ||
                    GlobalParams.Instance.GetOPCStatusLogRecord ||
                    log.Errors.Count > 0)
                {
                    Log4MongoDB.WriteLog(log);
                }
            }
            catch (Exception error)
            {
                _log.Error(error.Message, error);
            }
        }
Ejemplo n.º 25
0
    public void Dock(bool showShop)
    {
        if (player.GetComponent <CapsuleController>().isConnected)
        {
            GameObject module = player.GetComponent <CapsuleController>().connected;
            CustomTag  ct     = module.GetComponent <CustomTag>();
            if (ct.HasTag("booster"))
            {
                storedBooster++;
            }
            else if (ct.HasTag("hauler"))
            {
                storedHauler++;
            }
            else if (ct.HasTag("scanner"))
            {
                storedScanner++;
            }
            else if (ct.HasTag("lander"))
            {
                storedLander++;
            }

            GameMaster.Instance.currentCapsule.GetComponent <CapsuleController>().DestroyConnected();
        }
        if (!canDock)
        {
            return;
        }
        AudioManager.Instance.PlayDockingSound();
        joint.connectedBody = player.GetComponent <Rigidbody2D>();
        float   angOffset = joint.angularOffset;
        Vector2 linOffset = joint.linearOffset;

        joint.autoConfigureOffset = true;
        joint.enabled             = true;
        joint.autoConfigureOffset = false;
        joint.angularOffset       = angOffset;
        joint.linearOffset        = linOffset;
        docked  = true;
        canDock = false;
        player.GetComponent <CapsuleController>().enabled = false;
        player.GetComponent <SelectorScript>().enabled    = false;
        player.GetComponent <GravityApplier>().enabled    = false;
        player.GetComponent <BuildingPlacer>().enabled    = false;
        player.GetComponent <HealthManager>().health      = 100;
        player.transform.Find("HUD").gameObject.SetActive(false);
        if (showShop)
        {
            dockingScreen.SetActive(true);
        }
        hangarLight.SetActive(true);
        //gui.SetActive(false);
    }
Ejemplo n.º 26
0
 public void Save(CustomTag obj)
 {
     using (var session = JMMService.SessionFactory.OpenSession())
     {
         // populate the database
         using (var transaction = session.BeginTransaction())
         {
             session.SaveOrUpdate(obj);
             transaction.Commit();
         }
     }
 }
Ejemplo n.º 27
0
    private void OnCollisionStay2D(Collision2D other)
    {
        CustomTag ct = other.gameObject.GetComponent <CustomTag>();

        if (ct != null && other.gameObject.GetComponent <CustomTag>().HasTag("lavaPlanet"))
        {
            if (canTakeDamage)
            {
                Damage(1, 1);
            }
        }
    }
Ejemplo n.º 28
0
        public static void Init()
        {
            JMMUser.Populate();
            CloudAccount.Populate();
            ImportFolder.Populate();
            AniDB_Anime.Populate();
            AniDB_Episode.Populate();
            AniDB_File.Populate();
            AniDB_Anime_Title.Populate();
            AniDB_Anime_Tag.Populate();
            AniDB_Tag.Populate();
            CustomTag.Populate();
            CrossRef_CustomTag.Populate();
            CrossRef_File_Episode.Populate();
            VideoLocalPlace.Populate();
            VideoLocal.Populate();
            VideoLocalUser.Populate();
            GroupFilter.Populate();
            AnimeEpisode.Populate();
            AnimeEpisode_User.Populate();
            AnimeSeries.Populate();
            AnimeSeries_User.Populate();
            AnimeGroup.Populate();
            AnimeGroup_User.Populate();

            // Update Contracts if necessary
            JMMUser.RegenerateDb();
            CloudAccount.RegenerateDb();
            ImportFolder.RegenerateDb();
            AniDB_Anime.RegenerateDb();
            AniDB_Episode.RegenerateDb();
            AniDB_File.RegenerateDb();
            AniDB_Anime_Title.RegenerateDb();
            AniDB_Anime_Tag.RegenerateDb();
            AniDB_Tag.RegenerateDb();
            CustomTag.RegenerateDb();
            CrossRef_CustomTag.RegenerateDb();
            CrossRef_File_Episode.RegenerateDb();
            VideoLocalPlace.RegenerateDb();
            VideoLocal.RegenerateDb();
            VideoLocalUser.RegenerateDb();
            AnimeEpisode.RegenerateDb();
            AnimeEpisode_User.RegenerateDb();
            AnimeSeries.RegenerateDb();
            AnimeSeries_User.RegenerateDb();
            AnimeGroup.RegenerateDb();
            AnimeGroup_User.RegenerateDb();

            GroupFilter.RegenerateDb();
            GroupFilter.PostProcess();
            CleanUpMemory();
        }
Ejemplo n.º 29
0
        public void TestCloneTag()
        {
            string    tag    = "foo:Bar";
            CustomTag target = new CustomTag();

            Assert.IsTrue(string.IsNullOrEmpty(target.MarkupTag), "Empty tag is not null");
            target = new CustomTag(tag);
            Assert.AreEqual(tag, target.MarkupTag, "Markup tag not taken off constructor");

            CustomTag target2 = (CustomTag)target.Clone();

            Assert.AreEqual(tag, target2.MarkupTag, "Cloned tag incorrect");
        }
Ejemplo n.º 30
0
        /// <summary>
        /// 增加Tag对象
        /// </summary>
        /// <param name="tag">Tag对象</param>
        public override void Add(CustomTag tag)
        {
            string typeName = tag.GetType().Name;

            if (!typeName.Contains("Siemens"))
            {
                throw new Exception("tag对象不是西门子Tag对象");
            }

            _tags.Add(tag.Name, tag);

            OnTagRegister?.Invoke(_parent, tag as SiemensTag);
        }