/// <summary> /// add a work into event queue /// ワークをキューに追加(時間順。同時刻なら後の方に) /// </summary> /// <param name="workOrKanban">object either work or kanban</param> /// <returns></returns> public JitVariable Enqueue(DateTime dt, EventTypes type, JitVariable workOrKanban) { PrepareDummyItems(dt); LinkedListNode <Item> node; if (_sections.TryGetValue(TimeUtil.ClearSeconds(dt), out var topnode) == false) // 分毎にシーク位置をスキップできる { topnode = _dat.First; } for (node = topnode; node != null; node = node.Next) // 挿入位置を捜す { if (node.Value.DT > dt) { break; } } var item = new Item { DT = dt, Work = workOrKanban as JitWork, Kanban = workOrKanban as JitKanban, Type = type, }; if (node == null) // ポカヨケ { _dat.AddLast(item); } else { _dat.AddBefore(node, item); } return(workOrKanban); }
/// <summary> /// Add a class name /// </summary> /// <param name="classNames"></param> public void Add(string classNames) { var cn = classNames.Trim(); if (cn.StartsWith(":") == false) { throw new SyntaxErrorException("Class name should by started with : character"); } var adds = JitVariable.GetClassNames(classNames).ToList(); if (adds.Count < 3) { foreach (string c in adds) { if (_dat.Contains(c) == false) { _dat.Add(c); } } } else { _dat.AddRange(adds); _dat = _dat.Distinct().ToList(); } isHashed = false; }
/// <summary> /// access to a child value by instance name /// </summary> /// <param name="instanceName"></param> /// <returns></returns> public JitVariable this[string instanceName] { get { if (instanceName == "Global") { return(JitVariable.Global); } if (_dat.TryGetValue(instanceName, out JitVariable tm) == false) { tm = JitVariable.Null(Class.Object); tm.Name = instanceName; tm.Parent = Parent; _dat[instanceName] = tm; } return(tm); } set { if (instanceName == "Global") { throw new JitVariable.NotAllowErrorException("To change Global object is NOT allowed."); } JitVariable tm = value.Clone(); tm.Parent = Parent; _dat[instanceName] = tm; } }
public void Set(string classNames) { _dat = new List <string>(JitVariable.GetClassNames(classNames)); if (_dat.Contains(Class.Object) == false) { _dat.Insert(0, Class.Object); } isHashed = false; }
/// <summary> /// Find list node /// </summary> /// <param name="workOrKanban"></param> /// <returns></returns> public LinkedListNode <Item> Find(JitVariable workOrKanban) { for (var node = _dat.First; node != null; node = node.Next) { var ei = node.Value; if (ei is DummyItem || ei.Work is JitWork == false) { continue; } var w = ei.Work; if (w.Equals(workOrKanban)) { return(node); } } return(null); }
/// <summary> /// the constructor of this class /// </summary> public JitWork() { Classes.Set(":Work"); ChildVriables["Cost"][JitVariable.From("Count")].Value = JitVariable.From(1); // カウントコスト ChildVriables["Cost"][JitVariable.From("Random")].Value = JitVariable.From(MathUtil.Rand0()); // ランダムコスト 0~0.99999999 }
public void Add(JitVariable from) { Add(from.Classes); }
/// <summary> /// get child value by jfVariable key /// </summary> /// <param name="instanceName"></param> /// <returns></returns> public JitVariable this[JitVariable instanceName] { get => this[instanceName.Value.ToString()]; set => this[instanceName.Value.ToString()] = value;