public virtual void Initialize() { try { // Log = new Log(ConfigurationManager.AppSettings["txtlog"], Convert.ToBoolean(ConfigurationManager.AppSettings["logtofile"])); // initialize Communicators Communicator = CommunicatorList?.ToDictionary((p) => p.Name); Crane = CraneList?.ToDictionary((p) => p.Name); Conveyor = ConveyorList?.ToDictionary((p) => p.Name); Segment = SegmentList?.ToDictionary((p) => p.Name); // initialize ConveyorUnits ConveyorList?.ForEach(p => p.Initialize(this)); SegmentList?.ForEach(p => p.Initialize(this)); CraneList?.ForEach(p => p.Initialize(this)); CommunicatorList?.ForEach(prop => prop.Initialize(this)); StrategyList?.ForEach(p => p.Initialize(this)); SteeringCommands?.Initialize(this); ConveyorList?.ForEach(prop => prop.Startup()); CraneList?.ForEach(prop => prop.Startup()); SteeringCommands?.Startup(); WMS?.Initialize(this); } catch (Exception ex) { AddEvent(Event.EnumSeverity.Error, Event.EnumType.Exception, ex.Message); AddEvent(Event.EnumSeverity.Error, Event.EnumType.Exception, String.Format("{0} BasicWarehouse.Initialize failed", Name)); } }
private UriTemplateBuilder(SegmentList segments, QueryStringList queryString, Type controlledEntityType, bool isRegexMode = false) { _controlledEntityType = controlledEntityType; _isRegexMode = isRegexMode; _segments = segments; _queryString = queryString; }
public static List <Line> SigRoomBounds(Room room) { StringBuilder sb = new StringBuilder(); IList <IList <BoundarySegment> > segs = room.GetBoundarySegments(new SpatialElementBoundaryOptions()); List <Line> lines = new List <Line>(); if (null != segs) { foreach (IList <BoundarySegment> SegmentList in segs) { for (int i = 0; i < SegmentList.Count(); i++) { lines.Add(Line.CreateUnbound(SegmentList[i].GetCurve().GetEndPoint(0), SegmentList[i].GetCurve().GetEndPoint(1) - SegmentList[i].GetCurve().GetEndPoint(0))); } } } for (int i = 0; i < lines.Count(); i++) { for (int j = 0; j < lines.Count(); j++) { if (j != i) { if (lines[i].Direction == lines[j].Direction || lines[i].Direction == -lines[j].Direction) { if (lines[i].Distance(lines[j].Origin) <= offset) { lines.RemoveAt(j); } } } } } return(lines); }
public SegmentList Seg() { global::System.IntPtr cPtr = pocketsphinxPINVOKE.Decoder_Seg(swigCPtr); SegmentList ret = (cPtr == global::System.IntPtr.Zero) ? null : new SegmentList(cPtr, false); return(ret); }
/// <summary> /// Removes a segment from the message /// </summary> /// <param name="segmentName">Segment to be removed</param> /// <param name="index">Zero-based index of the segment to be removed, in case of multiple. Default is 0.</param> /// <returns>True if found and removed successfully, otherwise false</returns> public bool RemoveSegment(string segmentName, int index = 0) { try { if (!SegmentList.ContainsKey(segmentName)) { return(false); } var list = SegmentList[segmentName]; if (list.Count <= index) { return(false); } list.RemoveAt(index); SegmentCount--; return(true); } catch (Exception ex) { throw new HL7Exception("Unable to add remove segment. Error - " + ex.Message); } }
public FrustumSphereIntersection(Camera cam, Vector3 center, float radius) { main = cam; camTransform = cam.transform; allSegments = new SegmentList(); SetSphere(center, radius); }
/// <summary> /// Sets the Value of specific Field/Component/SubComponent, creates Field/Component/SubComponent if needed /// throws error if field/component index is not valid /// </summary> /// <param name="strValueFormat">Field/Component position in format SEGMENTNAME.FieldIndex.ComponentIndex.SubComponentIndex example PID.5.2</param> /// <param name="strValue">Value for the specified field/component</param> /// <returns>void</returns> public void PutValue(string strValueFormat, string strValue) { string segmentName = string.Empty; int componentIndex = 0; int subComponentIndex = 0; List <string> allComponents = MessageHelper.SplitString(strValueFormat, new char[] { '.' }); int comCount = allComponents.Count; bool isValid = validateValueFormat(allComponents); if (isValid) { segmentName = allComponents[0]; if (SegmentList.ContainsKey(segmentName)) { var segment = SegmentList[segmentName].First(); if (comCount >= 2) { var field = ensureField(segment, allComponents[1]); if (comCount >= 3) { Int32.TryParse(allComponents[2], out componentIndex); var component = field.EnsureComponent(componentIndex); if (comCount == 4) { Int32.TryParse(allComponents[3], out subComponentIndex); var subComponent = component.EnsureSubComponent(subComponentIndex); subComponent.Value = strValue; } else { component.Value = strValue; } } else { field.Value = strValue; } } else { segment.Value = strValue; } } else { throw new HL7Exception("Segment name not available"); } } else { throw new HL7Exception("Request format is not valid", HL7Exception.INVALID_REQUEST); } }
/// <summary> /// Analyzes the contents of an OMF file as a library or non-library. /// </summary> private OmfSegment.ParseResult DoAnalyze(Formatter formatter, bool parseAsLibrary) { bool first = true; int offset = 0; int len = mFileData.Length; List <string> msgs = new List <string>(); while (len > 0) { OmfSegment.ParseResult result = OmfSegment.ParseHeader(mFileData, offset, parseAsLibrary, msgs, out OmfSegment seg); if (result == OmfSegment.ParseResult.Success) { if (!seg.ParseBody(formatter, msgs)) { OmfSegment.AddErrorMsg(msgs, offset, "parsing of segment " + seg.SegNum + " '" + seg.SegName + "' incomplete"); //result = OmfSegment.ParseResult.Failure; } } MessageList.Clear(); foreach (string str in msgs) { MessageList.Add(str); } if (result == OmfSegment.ParseResult.IsLibrary) { // Need to start over in library mode. Debug.WriteLine("Restarting in library mode"); return(result); } else if (result == OmfSegment.ParseResult.Failure) { // Could be a library we failed to parse, could be a totally bad file. // If we were on the first segment, fail immediately so we can retry as // library. If not, it's probably not a library (assuming the Library // Dictionary segment appears first), but rather a partially-bad OMF. if (first) { return(result); } break; } first = false; Debug.Assert(seg.FileLength > 0); SegmentList.Add(seg); offset += seg.FileLength; len -= seg.FileLength; Debug.Assert(len >= 0); } Debug.WriteLine("Num segments = " + SegmentList.Count); return(OmfSegment.ParseResult.Success); }
public MapSegment AppendSegment(MapCoordinate end) { MapSegment lastSegment = SegmentList.OrderByDescending(ii => ii.Index).FirstOrDefault(); MapSegment segment = new MapSegment(lastSegment.Index + 1, lastSegment.EndLocation, end); SegmentList.Add(segment); return(segment); }
private void AddSegmentExecute() { Segment = new LEDSegment(); Segment.Id = id; Segment.Name = SegmentName; Segment.Type = SegmentType; SegmentList.Add(Segment); id++; }
/// <summary> /// Create the first segment, which will have an index of zero. /// </summary> /// <param name="start"></param> /// <param name="end"></param> public MapSegment AddFirstSegment(MapCoordinate start, MapCoordinate end) { SegmentList.Clear(); MapSegment segment = new MapSegment(0, start, end); SegmentList.Add(segment); return(segment); }
/// <summary> /// Checks if segmentList is empty. /// </summary> /// <returns>TRUE if segmentList is empty, else FALSE.</returns> static public Boolean IsEmpty() { if (SegmentList.Any()) { return(false); } else { return(true); } }
/// <summary> /// Safely returns the <see cref="Value{TValue}"/> from a complex object. /// </summary> /// <param name="source"></param> /// <param name="getter"></param> /// <typeparam name="TSegment"></typeparam> /// <typeparam name="T"></typeparam> /// <returns></returns> public static SegmentList <T> Select <TSegment, T>(this Segment <TSegment> source, Func <TSegment, SegmentList <T> > getter) where TSegment : HL7Segment where T : HL7Segment { if (source == null || !source.HasValue) { return(SegmentList.Missing <T>()); } return(getter(source.Value) ?? SegmentList.Missing <T>()); }
/// <summary> /// Safely returns the <see cref="SegmentList{TValue}"/> from the parsed result. /// </summary> /// <param name="result"></param> /// <param name="getter"></param> /// <typeparam name="TCursor"></typeparam> /// <typeparam name="TLayout"></typeparam> /// <typeparam name="TSegment"></typeparam> /// <returns></returns> public static SegmentList <TSegment> Select <TCursor, TLayout, TSegment>(this Result <Cursor <TCursor>, TLayout> result, Func <TLayout, SegmentList <TSegment> > getter) where TLayout : X12Layout where TSegment : X12Segment { if (result == null || !result.HasResult) { return(SegmentList.Missing <TSegment>()); } return(getter(result.Result) ?? SegmentList.Missing <TSegment>()); }
public override Stream UnParse() { if (mSegments == null) { mSegments = new SegmentList(handler); } MemoryStream s = new MemoryStream(); mSegments.UnParse(s); return(s); }
/// <summary> /// Safely returns the <see cref="Segment{T}"/> from a layout object. /// </summary> /// <param name="source"></param> /// <param name="getter"></param> /// <typeparam name="TLayout"></typeparam> /// <typeparam name="TSegment"></typeparam> /// <returns></returns> public static SegmentList <TSegment> Select <TLayout, TSegment>(this Layout <TLayout> source, Func <TLayout, SegmentList <TSegment> > getter) where TLayout : Layout where TSegment : X12Segment { if (source == null) { return(SegmentList.Missing <TSegment>()); } return(getter(source.Value) ?? SegmentList.Missing <TSegment>()); }
private void XmlFileToList(string filepath) { SegmentList.Clear(); using (var sr = new StreamReader(filepath)) { var deserializer = new XmlSerializer(typeof(ObservableCollection <LEDSegment>)); ObservableCollection <LEDSegment> tmpList = (ObservableCollection <LEDSegment>)deserializer.Deserialize(sr); foreach (var item in tmpList) { SegmentList.Add(item); } } id = SegmentList.Count; }
public bool AddNewSegment(Segment newSegment) { try { newSegment.SequenceNo = SegmentCount++; if (!SegmentList.ContainsKey(newSegment.Name)) { SegmentList[newSegment.Name] = new List <Segment>(); } SegmentList[newSegment.Name].Add(newSegment); return(true); } catch (Exception ex) { SegmentCount--; throw new HL7Exception("Unable to add new segment Error - " + ex.Message); } }
private void XmlFileToList(string filepath) { SegmentList.Clear(); using (var sr = new StreamReader(filepath)) { var deserializer = new XmlSerializer(typeof(ObservableCollection <LEDSegment>)); ObservableCollection <LEDSegment> tmpList = (ObservableCollection <LEDSegment>)deserializer.Deserialize(sr); foreach (var item in tmpList) { if (item.Type == "PWM") { item.ONOff = "0"; item.PWM = "150"; } else { item.ONOff = "Auto"; item.PWM = "0"; } SegmentList.Add(item); } } }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(SegmentList obj) { return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr); }
protected override void Parse(Stream s) { mSegments = new SegmentList(handler, s); }
public VBSI(int apiVersion, EventHandler handler, SegmentList segments) : base(apiVersion, handler, null) { mSegments = segments; }
/// <summary> /// Constructor for the <c>WeakCache</c> object. This is /// used to create a cache that stores values in such a way that /// when the key is garbage collected the value is removed from /// the map. This is similar to the concurrent hash map. /// </summary> /// <param name="size"> /// this is the number of segments within the cache /// </param> public WeakCache(int size) { this.list = new SegmentList(size); }
/// <summary> /// Get the Value of specific Field/Component/SubCpomponent, throws error if field/component index is not valid /// </summary> /// <param name="strValueFormat">Field/Component position in format SEGMENTNAME.FieldIndex.ComponentIndex.SubComponentIndex example PID.5.2</param> /// <returns>Value of specified field/component/subcomponent</returns> public string GetValue(string strValueFormat) { string segmentName = string.Empty; int componentIndex = 0; int subComponentIndex = 0; string strValue = string.Empty; List <string> allComponents = MessageHelper.SplitString(strValueFormat, new char[] { '.' }); int comCount = allComponents.Count; bool isValid = validateValueFormat(allComponents); if (isValid) { segmentName = allComponents[0]; if (SegmentList.ContainsKey(segmentName)) { var segment = SegmentList[segmentName].First(); if (comCount == 4) { Int32.TryParse(allComponents[2], out componentIndex); Int32.TryParse(allComponents[3], out subComponentIndex); try { var field = this.getField(segment, allComponents[1]); strValue = field.ComponentList[componentIndex - 1].SubComponentList[subComponentIndex - 1].Value; } catch (Exception ex) { throw new HL7Exception("SubComponent not available - " + strValueFormat + " Error: " + ex.Message); } } else if (comCount == 3) { Int32.TryParse(allComponents[2], out componentIndex); try { var field = this.getField(segment, allComponents[1]); strValue = field.ComponentList[componentIndex - 1].Value; } catch (Exception ex) { throw new HL7Exception("Component not available - " + strValueFormat + " Error: " + ex.Message); } } else if (comCount == 2) { try { var field = this.getField(segment, allComponents[1]); strValue = field.Value; } catch (Exception ex) { throw new HL7Exception("Field not available - " + strValueFormat + " Error: " + ex.Message); } } else { try { strValue = segment.Value; } catch (Exception ex) { throw new HL7Exception("Segment value not available - " + strValueFormat + " Error: " + ex.Message); } } } else { throw new HL7Exception("Segment name not available: " + strValueFormat); } } else { throw new HL7Exception("Request format is not valid: " + strValueFormat); } return(this.Encoding.Decode(strValue)); }
/// <summary>Paints the barcode. If no exception was thrown a valid barcode is available. </summary> public virtual void paintCode() { int maxErr, lenErr, tot, pad; if ((options & PDF417_USE_RAW_CODEWORDS) != 0) { if (lenCodewords > MAX_DATA_CODEWORDS || lenCodewords < 1 || lenCodewords != codewords[0]) { throw new System.ArgumentException("Invalid codeword size."); } } else { if (text == null) throw new System.NullReferenceException("Text cannot be null."); if (text.Length > ABSOLUTE_MAX_TEXT_SIZE) { throw new System.IndexOutOfRangeException("The text is too big."); } segmentList = new SegmentList(this); breakString(); //dumpList(); assemble(); segmentList = null; codewords[0] = lenCodewords = cwPtr; } maxErr = maxPossibleErrorLevel(MAX_DATA_CODEWORDS + 2 - lenCodewords); if ((options & PDF417_USE_ERROR_LEVEL) == 0) { if (lenCodewords < 41) errorLevel = 2; else if (lenCodewords < 161) errorLevel = 3; else if (lenCodewords < 321) errorLevel = 4; else errorLevel = 5; } if (errorLevel < 0) errorLevel = 0; else if (errorLevel > maxErr) errorLevel = maxErr; if (codeColumns < 1) codeColumns = 1; else if (codeColumns > 30) codeColumns = 30; if (codeRows < 3) codeRows = 3; else if (codeRows > 90) codeRows = 60; lenErr = 2 << errorLevel; bool fixedColumn = (options & PDF417_FIXED_ROWS) == 0; bool skipRowColAdjust = false; tot = lenCodewords + lenErr; if ((options & PDF417_FIXED_RECTANGLE) != 0) { tot = codeColumns * codeRows; if (tot > MAX_DATA_CODEWORDS + 2) { tot = MaxSquare; } if (tot < lenCodewords + lenErr) tot = lenCodewords + lenErr; else skipRowColAdjust = true; } else if ((options & (PDF417_FIXED_COLUMNS | PDF417_FIXED_ROWS)) == 0) { double c, b; fixedColumn = true; if (aspectRatio < 0.001) aspectRatio = 0.001f; else if (aspectRatio > 1000) aspectRatio = 1000; b = 73 * aspectRatio - 4; c = (-b + System.Math.Sqrt(b * b + 4 * 17 * aspectRatio * (lenCodewords + lenErr) * yHeight)) / (2 * 17 * aspectRatio); //UPGRADE_WARNING: Narrowing conversions may produce unexpected results in C#. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1042"' codeColumns = (int)(c + 0.5); if (codeColumns < 1) codeColumns = 1; else if (codeColumns > 30) codeColumns = 30; } if (!skipRowColAdjust) { if (fixedColumn) { codeRows = (tot - 1) / codeColumns + 1; if (codeRows < 3) codeRows = 3; else if (codeRows > 90) { codeRows = 90; codeColumns = (tot - 1) / 90 + 1; } } else { codeColumns = (tot - 1) / codeRows + 1; if (codeColumns > 30) { codeColumns = 30; codeRows = (tot - 1) / 30 + 1; } } tot = codeRows * codeColumns; } if (tot > MAX_DATA_CODEWORDS + 2) { tot = MaxSquare; } errorLevel = maxPossibleErrorLevel(tot - lenCodewords); lenErr = 2 << errorLevel; pad = tot - lenErr - lenCodewords; cwPtr = lenCodewords; while (pad-- != 0) codewords[cwPtr++] = TEXT_MODE; codewords[0] = lenCodewords = cwPtr; calculateErrorCorrection(lenCodewords); lenCodewords = tot; outPaintCode(); }
private void RemoveSegmentExecute() { SegmentList.Remove(SelectedSegment); id--; }
/// <summary> /// Resets the Story data structure. /// </summary> static public void Reset() { SegmentList.Clear(); Title = ""; Author = ""; }
/** Paints the barcode. If no exception was thrown a valid barcode is available. */ public void PaintCode() { int maxErr, lenErr, tot, pad; if ((options & PDF417_USE_RAW_CODEWORDS) != 0) { if (lenCodewords > MAX_DATA_CODEWORDS || lenCodewords < 1 || lenCodewords != codewords[0]) { throw new ArgumentException(MessageLocalization.GetComposedMessage("invalid.codeword.size")); } } else { if (text == null) throw new ArgumentNullException(MessageLocalization.GetComposedMessage("text.cannot.be.null")); if (text.Length > ABSOLUTE_MAX_TEXT_SIZE) { throw new ArgumentOutOfRangeException(MessageLocalization.GetComposedMessage("the.text.is.too.big")); } segmentList = new SegmentList(); BreakString(); //dumpList(); Assemble(); segmentList = null; codewords[0] = lenCodewords = cwPtr; } maxErr = MaxPossibleErrorLevel(MAX_DATA_CODEWORDS + 2 - lenCodewords); if ((options & PDF417_USE_ERROR_LEVEL) == 0) { if (lenCodewords < 41) errorLevel = 2; else if (lenCodewords < 161) errorLevel = 3; else if (lenCodewords < 321) errorLevel = 4; else errorLevel = 5; } if (errorLevel < 0) errorLevel = 0; else if (errorLevel > maxErr) errorLevel = maxErr; if (codeColumns < 1) codeColumns = 1; else if (codeColumns > 30) codeColumns = 30; if (codeRows < 3) codeRows = 3; else if (codeRows > 90) codeRows = 90; lenErr = 2 << errorLevel; bool fixedColumn = (options & PDF417_FIXED_ROWS) == 0; bool skipRowColAdjust = false; tot = lenCodewords + lenErr; if ((options & PDF417_FIXED_RECTANGLE) != 0) { tot = codeColumns * codeRows; if (tot > MAX_DATA_CODEWORDS + 2) { tot = GetMaxSquare(); } if (tot < lenCodewords + lenErr) tot = lenCodewords + lenErr; else skipRowColAdjust = true; } else if ((options & (PDF417_FIXED_COLUMNS | PDF417_FIXED_ROWS)) == 0) { double c, b; fixedColumn = true; if (aspectRatio < 0.001) aspectRatio = 0.001f; else if (aspectRatio > 1000) aspectRatio = 1000; b = 73 * aspectRatio - 4; c = (-b + Math.Sqrt(b * b + 4 * 17 * aspectRatio * (lenCodewords + lenErr) * yHeight)) / (2 * 17 * aspectRatio); codeColumns = (int)(c + 0.5); if (codeColumns < 1) codeColumns = 1; else if (codeColumns > 30) codeColumns = 30; } if (!skipRowColAdjust) { if (fixedColumn) { codeRows = (tot - 1) / codeColumns + 1; if (codeRows < 3) codeRows = 3; else if (codeRows > 90) { codeRows = 90; codeColumns = (tot - 1) / 90 + 1; } } else { codeColumns = (tot - 1) / codeRows + 1; if (codeColumns > 30) { codeColumns = 30; codeRows = (tot - 1) / 30 + 1; } } tot = codeRows * codeColumns; } if (tot > MAX_DATA_CODEWORDS + 2) { tot = GetMaxSquare(); } errorLevel = MaxPossibleErrorLevel(tot - lenCodewords); lenErr = 2 << errorLevel; pad = tot - lenErr - lenCodewords; if ((options & PDF417_USE_MACRO) != 0) { // the padding comes before the control block System.Array.Copy(codewords, macroIndex, codewords, macroIndex + pad, pad); cwPtr = lenCodewords + pad; while (pad-- != 0) codewords[macroIndex++] = TEXT_MODE; } else { cwPtr = lenCodewords; while (pad-- != 0) codewords[cwPtr++] = TEXT_MODE; } codewords[0] = lenCodewords = cwPtr; CalculateErrorCorrection(lenCodewords); lenCodewords = tot; OutPaintCode(); }
/// <summary> /// Constructor for the <c>HashCache</c> object. This is /// used to create a cache that stores values in such a way that /// when the key is garbage collected the value is removed from /// the map. This is similar to the concurrent hash map. /// </summary> /// <param name="size"> /// This is the number of segments within the cache. /// </param> public HashCache(int size) { this.list = new SegmentList(size); }
/// <summary> /// Sets the Value of specific Field/Component/SubCpomponent, throws error if field/component index is not valid /// </summary> /// <param name="strValueFormat">Field/Component position in format SEGMENTNAME.FieldIndex.ComponentIndex.SubComponentIndex example PID.5.2</param> /// <param name="strValue">Value for the specified field/component</param> /// <returns>boolean</returns> public bool SetValue(string strValueFormat, string strValue) { bool isValid = false; bool isSet = false; string segmentName = string.Empty; int fieldIndex = 0; int componentIndex = 0; int subComponentIndex = 0; int comCount = 0; List <string> AllComponents = MessageHelper.SplitString(strValueFormat, new char[] { '.' }); comCount = AllComponents.Count; isValid = validateValueFormat(AllComponents); if (isValid) { segmentName = AllComponents[0]; if (SegmentList.ContainsKey(segmentName)) { if (comCount == 4) { Int32.TryParse(AllComponents[1], out fieldIndex); Int32.TryParse(AllComponents[2], out componentIndex); Int32.TryParse(AllComponents[3], out subComponentIndex); try { SegmentList[segmentName].First().FieldList[fieldIndex - 1].ComponentList[componentIndex - 1].SubComponentList[subComponentIndex - 1].Value = strValue; isSet = true; } catch (Exception ex) { throw new HL7Exception("SubComponent not available - " + strValueFormat + " Error: " + ex.Message); } } else if (comCount == 3) { Int32.TryParse(AllComponents[1], out fieldIndex); Int32.TryParse(AllComponents[2], out componentIndex); try { SegmentList[segmentName].First().FieldList[fieldIndex - 1].ComponentList[componentIndex - 1].Value = strValue; isSet = true; } catch (Exception ex) { throw new HL7Exception("Component not available - " + strValueFormat + " Error: " + ex.Message); } } else if (comCount == 2) { Int32.TryParse(AllComponents[1], out fieldIndex); try { SegmentList[segmentName].First().FieldList[fieldIndex - 1].Value = strValue; isSet = true; } catch (Exception ex) { throw new HL7Exception("Field not available - " + strValueFormat + " Error: " + ex.Message); } } else { throw new HL7Exception("Cannot overwrite a segment value"); } } else { throw new HL7Exception("Segment name not available"); } } else { throw new HL7Exception("Request format is not valid"); } return(isSet); }
public VBSI(EventHandler handler, SegmentList segments) : base(handler, null) { mSegments = segments; }