internal static void Run(PerkinElmerConfig config) { Gc = config; Check(); _cancellation.CancelAfter(TimeSpan.FromMilliseconds((Gc.Peroid + Gc.Interval) * 60000)); _timer.Interval = Gc.Peroid * 60000; bartimer.Interval = _timer.Interval / 100; Start(); }
public GlobalSettings() { InitializeComponent(); _config = XmlHandle.XmlRead(); txtbox_InstrumentKey.Text = _config.InstrumentKey; txtbox_UserName.Text = _config.UserId; txtbox_password.Text = _config.Password; txtbox_rstFilePath.Text = _config.ResultPath.FullName; }
internal static PerkinElmerConfig XmlRead() { _xmlFile = XDocument.Load(XmlFileInfo.FullName); PerkinElmerConfig config = new PerkinElmerConfig(); try { var root = _xmlFile.Element("node"); if (root != null) { foreach (var e in root.Descendants()) { var stringValue = e.Value; var value = int.TryParse(stringValue, out var val) ? val : -1; switch (e.Name.LocalName) { case "lowestPeroidLimit": config.PeroidLimit[0] = value; break; case "highestPeroidLimit": config.PeroidLimit[1] = value; break; case "instrumentStopPeroid": config.InstrumentStopPeroid = value; break; case "userID": config.UserId = stringValue; break; case "password": config.Password = stringValue; break; case "instrumentKey": config.InstrumentKey = stringValue; break; case "ResultFile": config.ResultPath = new DirectoryInfo(stringValue); break; } } } } catch (Exception e) { Console.WriteLine(e.Message); } return(config); }
private void Apply_button_Click(object sender, EventArgs e) { _gc = XmlHandle.XmlRead(); #region Check validity of data input _gc.Peroid = double.TryParse(Peroid_textbox.Text, out double peroid) ? peroid : 15; _gc.Interval = double.TryParse(WaitingTime.Text, out double interal) ? interal : 3; _gc.Max = int.TryParse(RunTimes_textbox.Text, out int max) ? max : 1; #endregion Runtime.Run(_gc); }
/* #region TcAccess.dll import * * [DllImport(@"C:\PenExe\TcWS\Ver6.3.2\Bin\TcAccess.dll", ExactSpelling = true, SetLastError = true)] * private static extern void TcAccessInit(); * * [DllImport("TcAccess.dll", ExactSpelling = true, SetLastError = true)] * private static extern bool TcAccessLoggedOn(); * * [DllImport("TcAccess.dll", ExactSpelling = true, SetLastError = true)] * private static extern short VbTcAccessLogon(string username, string password); * * [DllImport("TcAccess.dll", ExactSpelling = true, SetLastError = true)] * internal static extern IntPtr VbTcAccessOpenConversation(string Topic); * * [DllImport("TcAccess.dll", ExactSpelling = true, SetLastError = true)] * internal static extern string TcAccessErrorMessage(); * * [DllImport("TcAccess.dll", ExactSpelling = true, SetLastError = true)] * internal static extern short VbTcAccessSet(IntPtr intPtr, string itemName, string value); * * [DllImport("TcAccess.dll", ExactSpelling = true, SetLastError = true)] * internal static extern short VbTcAccessGet(IntPtr intPtr, string itemName, out IntPtr value); * * [DllImport("TcAccess.dll", ExactSpelling = true, SetLastError = true)] * private static extern short VbTcAccessCloseConversation(IntPtr conv); * #endregion */ private static IntPtr TcAccessInitial(string pattern, PerkinElmerConfig config) { log.Debug("Initialing TcAccess"); LoadLib(); TcAccessInit().Invoke(); if (!TcAccessLoggedOn().Invoke()) { VbTcAccessLogon().Invoke(config.UserId, config.Password); } log.Info("Initialed TcAccess"); return(VbTcAccessOpenConversation().Invoke(pattern)); }
internal static bool XmlWrite(PerkinElmerConfig config) { _xml = new XmlDocument(); _xml.Load(XmlFileInfo.FullName); try { foreach (XmlNode firstLevelNode in _xml.LastChild.ChildNodes) { foreach (XmlNode e in firstLevelNode.ChildNodes) { switch (e.LocalName) { case "instrumentStopPeroid": e.InnerText = config.InstrumentStopPeroid.ToString(CultureInfo.CurrentCulture); break; case "userID": e.InnerText = config.UserId; break; case "password": e.InnerText = config.Password; break; case "instrumentKey": e.InnerText = config.InstrumentKey; break; case "ResultFile": e.InnerText = config.ResultPath.FullName; break; } } } _xml.Save(XmlFileInfo.FullName); return(true); } catch (Exception e) { Console.WriteLine(e.Message); } return(false); }
internal static IEnumerable <KeyValuePair <string, double> > ReadAllPeaksAreaFromRst(string path, PerkinElmerConfig config) { var handle = TcAccessInitial("RST", config); TcAccessSet(handle, "FILE_NAME", path); if (!int.TryParse(TcAccessGet(handle, "RST_NUM_PEAKS"), out var peaknums)) { return(null); } var list = new List <KeyValuePair <string, double> >(4); for (var i = 0; i < peaknums; i++) { TcAccessSet(handle, "RST_PEAK_INDEX", i.ToString()); var name = TcAccessGet(handle, "PK_NAME"); if (!double.TryParse(TcAccessGet(handle, "PK_AREA"), out var area)) { continue; } list.Add(new KeyValuePair <string, double>(name, area)); } TcAccessCloseConversation(handle); return(list); }