/// <summary> /// Returns a deep clone of this Keyword. Does not clone parents. /// </summary> /// <param name="KeywordToClone"></param> /// <returns></returns> public static PFSKeyword DeepClone(PFSKeyword KeywordToClone) { PFSKeyword pk = new PFSKeyword(KeywordToClone.Name); int NumberOfParameters = KeywordToClone.GetParametersNo(); for (int i = 1; i <= NumberOfParameters; i++) { pk.AddParameter(new PFSParameter(KeywordToClone.GetParameter(i).Type, KeywordToClone.GetParameter(i).Value)); } return pk; }
public DateTime?GetVariableDateTime(string Path, string Keyword) { PFSFile pfsFile = null; PFSKeyword pfsKeyword = null; if (!CheckAll(Path, Keyword, out pfsFile, out pfsKeyword)) { return(null); } try { int Year = pfsKeyword.GetParameter(1).ToInt(); int Month = pfsKeyword.GetParameter(2).ToInt(); int Day = pfsKeyword.GetParameter(3).ToInt(); int Hour = pfsKeyword.GetParameter(4).ToInt(); int Minute = pfsKeyword.GetParameter(5).ToInt(); int Second = pfsKeyword.GetParameter(6).ToInt(); DateTime dateTime = new DateTime(Year, Month, Day, Hour, Minute, Second); pfsFile.Close(); return(dateTime); } catch (Exception ex) { ErrorMessage = string.Format(CSSPDHIRes.CouldNotReadValueWithPath_AndKeyword_Error_, Path, Keyword, ex.Message + (ex.InnerException != null ? " Inner: " + ex.InnerException.Message : "")); OnCSSPDHIChanged(new CSSPDHIEventArgs(new CSSPDHIMessage("Error", -1, false, ErrorMessage))); pfsFile.Close(); return(null); } }
internal Branch(PFSSection Keyword) { _pfsHandle = Keyword; _definitions = _pfsHandle.GetKeyword("definitions", 1); _connections = _pfsHandle.GetKeyword("connections", 1); PFSKeyword _points = _pfsHandle.GetKeyword("points", 1); PointNumbers = new List <int>(); for (int i = 1; i <= _points.GetParametersNo(); i++) { PointNumbers.Add(_points.GetParameter(i).ToInt()); } }
//private string GetFileNameText(PFSFile pfsFile, string Path, string Keyword) //{ // string FileName = ""; // PFSSection pfsSectionFileName = pfsFile.GetSectionFromHandle(Path); // if (pfsSectionFileName != null) // { // PFSKeyword keyword = null; // try // { // keyword = pfsSectionFileName.GetKeyword(Keyword); // } // catch (Exception ex) // { // UpdateTaskError(AppTaskID, "PFS GetKeyword. Error [" + ex.Message + (ex.InnerException != null ? " Inner: " + ex.InnerException.Message : "") + "]"); // richTextBoxStatus.AppendText("PFS GetKeyword. Error [" + ex.Message + (ex.InnerException != null ? " Inner: " + ex.InnerException.Message : "") + "]\r\n"); // return FileName; // } // if (keyword != null) // { // try // { // FileName = keyword.GetParameter(1).ToFileName(); // } // catch (Exception ex) // { // UpdateTaskError(AppTaskID, "PFS GetParameter. Error [" + ex.Message + (ex.InnerException != null ? " Inner: " + ex.InnerException.Message : "") + "]"); // richTextBoxStatus.AppendText("PFS GetParameter. Error [" + ex.Message + (ex.InnerException != null ? " Inner: " + ex.InnerException.Message : "") + "]\r\n"); // return FileName; // } // } // } // return FileName; //} private string GetParameterResultFileName(PFSFile pfsFile, string Path, string Keyword) { //string NotUsed = ""; string FileName = ""; PFSSection pfsSection = pfsFile.GetSectionFromHandle(Path); if (pfsSection == null) { UpdateTaskError(AppTaskID, $"pfsSection not found for path {Path}"); richTextBoxStatus.AppendText($"pfsSection not found for path {Path}\r\n"); return(FileName); } PFSKeyword keyword = null; try { keyword = pfsSection.GetKeyword(Keyword); } catch (Exception ex) { UpdateTaskError(AppTaskID, "PFS GetKeyword. Error [" + ex.Message + (ex.InnerException != null ? " Inner: " + ex.InnerException.Message : "") + "]"); richTextBoxStatus.AppendText("PFS GetKeyword. Error [" + ex.Message + (ex.InnerException != null ? " Inner: " + ex.InnerException.Message : "") + "]\r\n"); return(FileName); } if (keyword != null) { try { FileName = keyword.GetParameter(1).ToResultFileName(); } catch (Exception ex) { UpdateTaskError(AppTaskID, "PFS GetParameter. Error [" + ex.Message + (ex.InnerException != null ? " Inner: " + ex.InnerException.Message : "") + "]"); richTextBoxStatus.AppendText("PFS GetParameter. Error [" + ex.Message + (ex.InnerException != null ? " Inner: " + ex.InnerException.Message : "") + "]\r\n"); return(FileName); } } return(FileName); }
public DateTime?SetVariableDateTime(string Path, string Keyword, DateTime value) { PFSFile pfsFile = null; PFSKeyword pfsKeyword = null; if (!CheckAll(Path, Keyword, out pfsFile, out pfsKeyword)) { return(null); } try { pfsKeyword.DeleteParameter(6); pfsKeyword.DeleteParameter(5); pfsKeyword.DeleteParameter(4); pfsKeyword.DeleteParameter(3); pfsKeyword.DeleteParameter(2); pfsKeyword.DeleteParameter(1); pfsKeyword.InsertNewParameterInt(value.Year, 1); pfsKeyword.InsertNewParameterInt(value.Month, 2); pfsKeyword.InsertNewParameterInt(value.Day, 3); pfsKeyword.InsertNewParameterInt(value.Hour, 4); pfsKeyword.InsertNewParameterInt(value.Minute, 5); pfsKeyword.InsertNewParameterInt(value.Second, 6); int Year = pfsKeyword.GetParameter(1).ToInt(); int Month = pfsKeyword.GetParameter(2).ToInt(); int Day = pfsKeyword.GetParameter(3).ToInt(); int Hour = pfsKeyword.GetParameter(4).ToInt(); int Minute = pfsKeyword.GetParameter(5).ToInt(); int Second = pfsKeyword.GetParameter(6).ToInt(); DateTime dateTime = new DateTime(Year, Month, Day, Hour, Minute, Second); pfsFile.Write(fi.FullName); pfsFile.Close(); return(dateTime); } catch (Exception ex) { // need to write test code for this part ErrorMessage = string.Format(CSSPDHIRes.CouldNotSetStartTimeWithPath_Keyword_Error_, Path, Keyword, ex.Message + (ex.InnerException != null ? " Inner: " + ex.InnerException.Message : "")); OnCSSPDHIChanged(new CSSPDHIEventArgs(new CSSPDHIMessage("Error", -1, false, ErrorMessage))); return(null); } }
public int GetValue(int index) { return(_keyword.GetParameter(index + 1).ToInt()); }
public string GetValue(int index) { return(_keyword.GetParameter(index + 1).ToString()); }
public Nullable <T> GetVariable <T>(string Path, string Keyword, int ParameterIndex) where T : struct { PFSFile pfsFile = null; PFSKeyword pfsKeyword = null; if (!CheckAll(Path, Keyword, out pfsFile, out pfsKeyword)) { return(null); } try { switch (typeof(T).ToString()) { case "System.Boolean": { object value = pfsKeyword.GetParameter(ParameterIndex).ToBoolean(); pfsFile.Close(); return((T?)value); } case "System.Double": { object value = pfsKeyword.GetParameter(ParameterIndex).ToDouble(); pfsFile.Close(); return((T?)value); } case "System.Int32": case "System.Int64": { object value = pfsKeyword.GetParameter(ParameterIndex).ToInt(); pfsFile.Close(); return((T?)value); } case "System.Single": { object value = pfsKeyword.GetParameter(ParameterIndex).ToSingle(); pfsFile.Close(); return((T?)value); } default: { return(null); } } } catch (Exception ex) { ErrorMessage = string.Format(CSSPDHIRes.ParameterIndex_DoesNotExistForSectionPath_AndKeyword_Error_, ParameterIndex, Path, Keyword, ex.Message + (ex.InnerException != null ? " Inner: " + ex.InnerException.Message : "")); OnCSSPDHIChanged(new CSSPDHIEventArgs(new CSSPDHIMessage("Error", -1, false, ErrorMessage))); pfsFile.Close(); return(null); } }
public double GetValue(int index) { return(_keyword.GetParameter(index + 1).ToDouble()); }
public DateTime GetDate(string Parameter) { PFSKeyword pk = _pfsHandle.GetKeyword(Parameter, 1); return(new DateTime(pk.GetParameter(1).ToInt(), pk.GetParameter(2).ToInt(), pk.GetParameter(3).ToInt(), pk.GetParameter(4).ToInt(), pk.GetParameter(5).ToInt(), 0)); }