Exemple #1
0
        private int CreateEvent(EventControl item)
        {
            TagEvent model = item.GetModel();

            model.Id = GetTagEventId(model.DailyLogId); // 考虑到同时添加多条Event时,EventId要实时更新
            return(context.AddTagEvent(model));
        }
Exemple #2
0
 private void RefreshEventsGroup(TagHandler Tags)
 {
     for (int i = 0; i < EvGroups.Count; i++)
     {
         //All the events are in evGroups
         //refresh from OPC all events (diferents OPCs)
         if (EvGroups[i].opcgroup.ServerName.Length > 1)
         {
             EvGroups[i].opcgroup.GetData();
             Tags.RefreshFromGroup(EvGroups[i].opcgroup);
         }
         else
         {
             Tags.RefreshFromEvents(EvGroups[i].opcgroup);
         }
     }
     //Refresh the struc EVENTS (that contain inserts/updates)
     for (int i = 0; i < OPCEvents.Count; i++)
     {
         int indexer = Tags.SearchTag(OPCEvents[i].Tagevent);
         if (indexer != -1)
         {
             TagEvent evt = OPCEvents[i];
             evt.Activated   = Tags.Values[indexer].Activated;
             evt.Deactivated = Tags.Values[indexer].Deactivated;
             OPCEvents[i]    = evt;
         }
     }
 }
Exemple #3
0
        private List <TagEvent> IntiOPCEvents()
        {
            List <TagEvent> Events = new List <TagEvent>();
            string          sqlStr = "select TagEvent, PLC2DB_Tags.Enabled as Enabled from PLC2DB_Cfg, PLC2DB_Tags where right(rtrim(TagEvent),1) <> '$' and PLC2DB_Tags.Enabled  is null or PLC2DB_Tags.Enabled = 1 and TagEvent = PLC2DB_Tags.Tag group by TagEvent,  PLC2DB_Tags.Enabled";
            Logging         log    = new Logging(sqlStr);

            try
            {
                using (SqlConnection connection = new SqlConnection(IntData.CfgConn))
                {
                    connection.Open();
                    SqlCommand    cmd = new SqlCommand(sqlStr, connection);
                    SqlDataReader sdr = cmd.ExecuteReader();
                    while (sdr.Read())
                    {
                        TagEvent ev = new TagEvent
                        {
                            Tagevent = sdr[0].ToString().Trim(),
                            Enable   = Convert.ToBoolean(sdr[1])
                        };
                        ev.Targets     = MakeCommandsList(ev.Targets, ev.Tagevent);
                        ev.ScriptsList = FilluserProcedures(ev.ScriptsList, ev.Tagevent);
                        Events.Add(ev);
                    }
                }
                log.Success();
            }
            catch (Exception ex)
            {
                log.Fatal(ex);
            }
            return(Events);
        }
Exemple #4
0
        //update the list of unique tags
        private void MyUpdate(TagEvent e)
        {
            bool ModuleNameFound = false;

            //Search to see if tag exists
            foreach (Module m in ModuleList)
            {
                if (m.ModuleName == e.ModuleName)
                {
                    ModuleNameFound = true;

                    //module found, add tag or data if unique
                    m.Uniques(e);
                }
            }

            if (false == ModuleNameFound)
            {
                ModuleList.Add(new Module(e));

                ModuleList.Sort();

                //we have a new tag, redisplay them all
                ClearModuleTextBox('d');

                foreach (Module m in ModuleList)
                {
                    Trace.WriteLine(m.ModuleName + "\n");
                    AppendModuleTextBox(m.ModuleName + "\r\n");
                }
            }
        }
Exemple #5
0
    public static TagEvent Create(GameObject gameObject)
    {
        TagEvent e = new TagEvent();

        e.Type = QuarkEventType.Tag;
        e.Id   = gameObject.GetInstanceID();
        e.Tag  = gameObject.tag;
        return(e);
    }
 public void ShowEvent(TagEvent model)
 {
     txtTag.Text        = model.TagText ?? "Tag";
     txtEvent.Text      = model.EventText ?? "Event";
     dailyLogId         = model.DailyLogId;
     eventId            = model.Id;
     createTime         = model.CreateTime;
     lblCreateTime.Text = model.CreateTime.ToShortTimeString();
 }
Exemple #7
0
    public static void TriggerEvent(string eventName, object tag = null)
    {
        TagEvent thisEvent = null;

        if (Instance.eventDictionary.TryGetValue(eventName, out thisEvent))
        {
            thisEvent.Invoke(tag);
        }
    }
        public TagEvent GetModel()
        {
            TagEvent model = new TagEvent();

            model.Id         = eventId;
            model.DailyLogId = dailyLogId;
            model.EventText  = txtEvent.Text;
            model.TagText    = txtTag.Text;
            model.CreateTime = createTime;
            return(model);
        }
Exemple #9
0
        private void btnNewEvent_Click(object sender, EventArgs e)
        {
            MYUI.EventControl eventcontrol = new MYUI.EventControl();
            TagEvent          model        = new TagEvent();

            model.Id            = GetTagEventId(lblSearchTime.Text);
            model.DailyLogId    = lblSearchTime.Text;
            model.CreateTime    = DateTime.Now;
            eventcontrol.Status = MYUI.EventControl.StatusType.Create;
            eventcontrol.ShowEvent(model);
            flpContent.Controls.Add(eventcontrol);
        }
Exemple #10
0
        /// <see cref="ITagRepository.AddTag(TagEvent)" />
        public TagEvent AddTag(TagEvent model)
        {
            var tag = db.EventCategoryTags.FirstOrDefault(o => o.Name.ToLower().Equals(model.Name.ToLower()));

            if (tag != null)
            {
                return(tag);
            }
            tag = model;
            db.EventCategoryTags.Add(tag);
            db.SaveChanges();
            return(tag);
        }
Exemple #11
0
    public static void StopListening(string eventName, UnityAction <object> listener)
    {
        if (eventManager == null)
        {
            return;
        }
        TagEvent thisEvent = null;

        if (Instance.eventDictionary.TryGetValue(eventName, out thisEvent))
        {
            thisEvent.RemoveListener(listener);
        }
    }
 private bool IsInTags(Collider2D other, TagEvent tagEvent)
 {
     if (tagEvent.tags.Length != 0)
     {
         for (int i = 0; i < tagEvent.tags.Length; i++)
         {
             if (other.CompareTag(tagEvent.tags[i]))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Exemple #13
0
        public int DeleteTagEvent(TagEvent model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("delete from Event");
            strSql.Append(" where Id = @Id");

            Database  db        = DatabaseFactory.CreateDatabase("MYLOGConn");
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "Id", DbType.String, model.Id);

            return(db.ExecuteNonQuery(dbCommand));
        }
        public int DeleteTagEvent(TagEvent model)
        {
            SqliteHelper db = SqliteHelper.CreateDB(Environment.CurrentDirectory + "\\Sqlite.db");

            StringBuilder strSql = new StringBuilder();

            strSql.Append("delete from Event");
            strSql.Append(" where Id = @Id");

            SQLiteParameter[] parameters = new SQLiteParameter[] {
                new SQLiteParameter("@Id", model.Id)
            };

            return(db.ExecuteNonQuery(strSql.ToString(), parameters));
        }
Exemple #15
0
    public static void StartListening(string eventName, UnityAction <object> listener)
    {
        TagEvent thisEvent = null;

        if (Instance.eventDictionary.TryGetValue(eventName, out thisEvent))
        {
            thisEvent.AddListener(listener);
        }
        else
        {
            thisEvent = new TagEvent();
            thisEvent.AddListener(listener);
            Instance.eventDictionary.Add(eventName, thisEvent);
        }
    }
Exemple #16
0
        public int UpdateTagEvent(TagEvent model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Event set");
            strSql.Append(" Text = @Text");
            strSql.Append(",Tag = @Tag");
            strSql.Append(" where Id = @Id");

            Database  db        = DatabaseFactory.CreateDatabase("MYLOGConn");
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "Text", DbType.String, model.EventText);
            db.AddInParameter(dbCommand, "Tag", DbType.String, model.TagText);
            db.AddInParameter(dbCommand, "Id", DbType.String, model.Id);

            return(db.ExecuteNonQuery(dbCommand));
        }
        public int UpdateTagEvent(TagEvent model)
        {
            SqliteHelper db = SqliteHelper.CreateDB(Environment.CurrentDirectory + "\\Sqlite.db");

            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Event set");
            strSql.Append(" Text = @Text");
            strSql.Append(",Tag = @Tag");
            strSql.Append(" where Id = @Id");

            SQLiteParameter[] parameters = new SQLiteParameter[] {
                new SQLiteParameter("@Text", model.EventText),
                new SQLiteParameter("@Tag", model.TagText),
                new SQLiteParameter("@Id", model.Id)
            };

            return(db.ExecuteNonQuery(strSql.ToString(), parameters));
        }
Exemple #18
0
        public int AddTagEvent(TagEvent model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Event(");
            strSql.Append("Id, DailyLogId, Text, Tag, CreateTime)");
            strSql.Append(" values (");
            strSql.Append("@Id, @DailyLogId, @Text, @Tag, @CreateTime)");

            Database  db        = DatabaseFactory.CreateDatabase("MYLOGConn");
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "Id", DbType.String, model.Id);
            db.AddInParameter(dbCommand, "DailyLogId", DbType.String, model.DailyLogId);
            db.AddInParameter(dbCommand, "Text", DbType.String, model.EventText);
            db.AddInParameter(dbCommand, "Tag", DbType.String, model.TagText);
            db.AddInParameter(dbCommand, "CreateTime", DbType.DateTime, model.CreateTime);

            return(db.ExecuteNonQuery(dbCommand));
        }
        public List <TagEvent> GetTagEvents(string dailyLogId)
        {
            SqliteHelper db = SqliteHelper.CreateDB(Environment.CurrentDirectory + "\\Sqlite.db");

            StringBuilder strSql = new StringBuilder();

            strSql.Append("select Id, DailyLogId, Text, Tag, CreateTime from Event");
            strSql.Append(" where DailyLogId = @DailyLogId");

            SQLiteParameter[] parameters = new SQLiteParameter[] {
                new SQLiteParameter("@DailyLogId", dailyLogId)
            };

            db.ExecuteDataTable(strSql.ToString(), parameters);

            DataTable dt = db.ExecuteDataTable(strSql.ToString(), parameters);

            if (dt.Rows.Count > 0)
            {
                List <TagEvent> models = new List <TagEvent>();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    TagEvent model = new TagEvent();
                    model.Id         = dt.Rows[i]["Id"].ToString();
                    model.DailyLogId = dt.Rows[i]["DailyLogId"].ToString();
                    model.EventText  = dt.Rows[i]["Text"].ToString();
                    model.TagText    = dt.Rows[i]["Tag"].ToString();
                    DateTime CreateTime;
                    if (DateTime.TryParse(dt.Rows[i]["CreateTime"].ToString(), out CreateTime))
                    {
                        model.CreateTime = CreateTime;
                    }
                    models.Add(model);
                }
                return(models);
            }
            else
            {
                return(null);
            }
        }
        public int AddTagEvent(TagEvent model)
        {
            SqliteHelper db = SqliteHelper.CreateDB(Environment.CurrentDirectory + "\\Sqlite.db");

            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Event(");
            strSql.Append("Id, DailyLogId, Text, Tag, CreateTime)");
            strSql.Append(" values (");
            strSql.Append("@Id, @DailyLogId, @Text, @Tag, @CreateTime)");

            SQLiteParameter[] parameters = new SQLiteParameter[] {
                new SQLiteParameter("@Id", model.Id),
                new SQLiteParameter("@DailyLogId", model.DailyLogId),
                new SQLiteParameter("@Text", model.EventText),
                new SQLiteParameter("@Tag", model.TagText),
                new SQLiteParameter("@CreateTime", model.CreateTime),
            };

            return(db.ExecuteNonQuery(strSql.ToString(), parameters));
        }
Exemple #21
0
        public List <TagEvent> GetTagEvents(string dailyLogId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select Id, DailyLogId, Text, Tag, CreateTime from Event");
            strSql.Append(" where DailyLogId = @DailyLogId");

            Database  db        = DatabaseFactory.CreateDatabase("MYLOGConn");
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "DailyLogId", DbType.String, dailyLogId);

            DataTable dt = db.ExecuteDataSet(dbCommand).Tables[0];

            if (dt.Rows.Count > 0)
            {
                List <TagEvent> models = new List <TagEvent>();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    TagEvent model = new TagEvent();
                    model.Id         = dt.Rows[i]["Id"].ToString();
                    model.DailyLogId = dt.Rows[i]["DailyLogId"].ToString();
                    model.EventText  = dt.Rows[i]["Text"].ToString();
                    model.TagText    = dt.Rows[i]["Tag"].ToString();
                    DateTime CreateTime;
                    if (DateTime.TryParse(dt.Rows[i]["CreateTime"].ToString(), out CreateTime))
                    {
                        model.CreateTime = CreateTime;
                    }
                    models.Add(model);
                }

                return(models);
            }
            else
            {
                return(null);
            }
        }
Exemple #22
0
        private int DeleteEvent(EventControl item)
        {
            TagEvent model = item.GetModel();

            return(context.DeleteTagEvent(model));
        }
    public override void AddReward(BaseAgent agent, float[] vectorActions)
    {
        Reward           = AcademyParameters.Update(academy, RewardKeyVal, Reward);
        ContinuousReward = AcademyParameters.Update(academy, ContinuousRewardKeyVal, ContinuousReward);
        Penalty          = AcademyParameters.Update(academy, PenaltyKeyVal, Penalty);

        float labelValue;

        switch (LabelValue)
        {
        case LabelValueType.Boolean: labelValue = 1; break;

        case LabelValueType.Time: labelValue = Time.time; break;

        default: labelValue = 0; break;
        }


        Option <GameObject> triggerColCont =
            agent.TriggerCollider
            .Filter(tc => tc != null)
            .Map(tc => tc.gameObject)
            .Filter(gob => gob.tag == Tag);

        Option <Collider> prevFrame = PreviousFrame.Filter(p => p != null);

        Option <GameObject> triggerCol =
            triggerColCont
            .Filter(tc => !tc.SomeNotNull().Equals(prevFrame.Map(p => p.gameObject)));

        triggerCol
        .MatchSome(_ => {
            if (AgentCollisionMessage != "")
            {
                //TAG: MakeEvent myArea.Logger.Log(Logger.CreateMessage(LogMessageType.Agent, AgentCollisionMessage), agent);
            }

            //TAG: MakeEvent myArea.Logger.Log(String.Concat("Tagged ", agent.transform.position.y));
        });

        triggerColCont.MatchSome(_ => {
            agent.AddReward(ContinuousReward);
        });

        prevFrame
        .Filter(pc => triggerColCont.HasValue)
        .FlatMap(pc => pc.GetComponent <ObservableFields>().SomeNotNull())
        .MatchSome(lc => {
            if (RemoveOnLeave)
            {
                //TAG: MakeEvent myArea.Logger.Log(String.Concat("Removing label on leave ", Label));
                lc.FieldsHash.Remove(Label);
            }
        });

        triggerCol
        .Map(tc => tc.gameObject)
        .MatchSome(go => {
            ObservableFields lc = go.GetComponent <ObservableFields>();
            if ((lc == null || !lc.FieldsHash.ContainsKey(LabelPrevents)) && NewTag != "")
            {
                //TAG: MakeEvent myArea.Logger.Log(String.Concat("Adding tag ", NewTag));
                go.tag = NewTag;
                agent.area.EventSystem.RaiseEvent(TagEvent.Create(go));
                agent.area.EventSystem.RaiseEvent(TaggingEvent.Create(agent.gameObject, NewTag));
            }
        });

        ObservableFields selfFields = agent.gameObject.GetComponent <ObservableFields>();

        triggerCol
        .FlatMap(tc => tc.GetComponent <ObservableFields>().SomeNotNull())
        .MatchSome(lc => {
            if (lc.FieldsHash.ContainsKey(Label) && Time.time - lc.FieldsHash[Label] < Cooldown
                )
            {
                //TAG: MakeEvent myArea.Logger.Log(String.Concat("already there ", Label));
                if (Toggle)
                {
                    //TAG: MakeEvent myArea.Logger.Log(String.Concat("Removing label ", Label));
                    lc.FieldsHash.Remove(Label);
                }

                //TAG: MakeEvent myArea.Logger.Log(String.Concat("Penalizing already there ", Penalty));
                agent.AddReward(Penalty);

                if (DoneIfAlreadyThere)
                {
                    //TAG: MakeEvent myArea.Logger.Log(String.Concat("Done already there ", agent.gameObject.tag));
                    agent.Done();
                }

                if (ResetAreaIfAlreadyThere)
                {
                    //TAG: MakeEvent myArea.Logger.Log(String.Concat("Resetting already there ", agent.gameObject.tag));
                    myArea.ResetArea();
                }
            }
            else if (!lc.FieldsHash.ContainsKey(LabelPrevents) && !lc.FieldsHash.ContainsKey(Label) &&
                     (CooldownSelfTag == "" || selfFields == null || !selfFields.FieldsHash.ContainsKey(CooldownSelfTag) ||
                      Time.time - selfFields.FieldsHash[CooldownSelfTag] < Cooldown))
            {
                //TAG: MakeEvent myArea.Logger.Log(String.Concat("Adding reward ", Reward));
                agent.AddReward(Reward);
                if (Label != "")
                {
                    //TAG: MakeEvent myArea.Logger.Log(String.Concat("Adding label ", Label));
                    lc.FieldsHash.Add(Label, labelValue);
                }
            }
        });

        triggerCol
        .Filter((GameObject go) => Remove)
        .MatchSome(tc => GameObject.Destroy(tc));

        triggerCol
        .Filter((GameObject go) => Done)
        .MatchSome(_ => agent.Done());

        triggerCol
        .Filter((GameObject go) => Reset)
        .MatchSome(_ => {
            //TAG: MakeEvent myArea.Logger.Log(String.Concat("Reset on collide ", Tag));
            agent.Reset();
        });

        triggerCol
        .Filter((GameObject go) => ResetArea)
        .MatchSome(_ => myArea.ResetArea());

        PreviousFrame = agent.TriggerCollider;

        PreviousFrameTag = agent.gameObject.tag;
    }
 public void Tag(Token tag)
 {
     events.Enqueue(new TagEvent(tag.Content, e => TagEvent.Invoke(this, new EventArgs <string>(tag.Content))));
 }
Exemple #25
0
 public void SetCommanderTag(TagEvent tagEvt)
 {
     HasCommanderTag = tagEvt.TagID != 0;
 }