/// <summary>機能の実行を記録する。</summary> /// <param name="target">対象の機能(Screen/Dialog)</param> /// <param name="funcKeyNo">Fキー番号</param> /// <param name="action">機能の本処理</param> internal static void FunctionCalled(this ILoggable target, int funcKeyNo, Action action) { if (action == null) { return; } bool logging = (target.ApplicationControl?.UseOperationLogging ?? 0) == 1; ILogin login = target.Login; string viewCaption = target.Caption; MeasurementHelper.ProcessStart(); if (logging) { var attribute = action.Method .GetCustomAttributes(false) .OfType <OperationLogAttribute>() .FirstOrDefault(); if (attribute != null) { LogAsync(login, null, viewCaption, $"F{funcKeyNo}:{attribute.FunctionName}"); } } action(); if (!string.IsNullOrEmpty(viewCaption) && funcKeyNo != 10) { MeasurementHelper.ProcessEnd($"{viewCaption} F{funcKeyNo}"); } }
public void SetUserMeasurementUnits(DistanceUnitType measurementUnit) { MeasurementUnit = measurementUnit; bool isMetric = MeasurementHelper.IsMetric(MeasurementUnit); var elevationDistanceUnitType = MeasurementHelper.GetElevationUnitType(isMetric); var distanceUnitType = MeasurementHelper.GetDistanceUnitType(isMetric); TotalDistanceUserMeasurementUnit = new UserMeasurementUnitMetric((float)Distance, DistanceUnitType.Metres, distanceUnitType); ElevationGainUserMeasurementUnit = new UserMeasurementUnitMetric((float)ElevationGain, DistanceUnitType.Metres, elevationDistanceUnitType); }
/// <summary> /// draw rectangle /// </summary> /// <param name="laser"></param> /// <param name="rtc"></param> /// <param name="width"></param> /// <param name="height"></param> private static bool DrawRectangle(ILaser laser, IRtc rtc, float width, float height) { if (rtc.CtlGetStatus(RtcStatus.Busy)) { return(false); } var rtcMeasurement = rtc as IRtcMeasurement; Debug.Assert(rtcMeasurement != null); Console.WriteLine("WARNING !!! LASER IS BUSY ... Draw Rectangle"); timer = Stopwatch.StartNew(); MeasurementChannel[] channels = new MeasurementChannel[4] { MeasurementChannel.SampleX, //X MeasurementChannel.SampleY, //Y MeasurementChannel.LaserOn, //Gate MeasurementChannel.OutputPeriod, //KHz }; float hz = 10000; //10 KHz bool success = true; success &= rtc.ListBegin(laser); success &= rtcMeasurement.ListMeasurementBegin(hz, channels); //10 Khz, 4개 채널 success &= rtc.ListFrequency(50 * 1000, 2); // 주파수 50KHz, 펄스폭 2usec success &= rtc.ListSpeed(500, 500); // 점프, 마크 속도 500mm/s success &= rtc.ListDelay(10, 100, 200, 200, 0); // 스캐너/레이저 지연값 success &= rtc.ListJump(new Vector2(-width / 2, height / 2)); success &= rtc.ListMark(new Vector2(width / 2, height / 2)); success &= rtc.ListMark(new Vector2(width / 2, -height / 2)); success &= rtc.ListMark(new Vector2(-width / 2, -height / 2)); success &= rtc.ListMark(new Vector2(-width / 2, height / 2)); success &= rtcMeasurement.ListMeasurementEnd(); success &= rtc.ListEnd(); if (success) { success &= rtc.ListExecute(true); } var measurementFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "plot", "measurement_rectangle.txt"); success &= MeasurementHelper.Save(measurementFile, rtcMeasurement, hz, channels, false); if (success) { Console.WriteLine($"Processing time = {timer.ElapsedMilliseconds / 1000.0:F3}s. plot to file = {measurementFile}"); } return(success); }
/// <summary>機能の実行を記録する。</summary> /// <param name="target">対象の機能(Screen/Dialog)</param> /// <param name="funcKeyNo">Fキー番号</param> /// <param name="button">ボタン</param> internal static void FunctionCalled(this ILoggable target, int funcKeyNo, Button button) { bool logging = (target.ApplicationControl?.UseOperationLogging ?? 0) == 1; ILogin login = target.Login; string viewCaption = target.Caption; MeasurementHelper.ProcessStart(); if (logging && button != null) { LogAsync(login, null, viewCaption, button.Text); } if (!string.IsNullOrEmpty(viewCaption) && funcKeyNo != 10) { MeasurementHelper.ProcessEnd($"{viewCaption} F{funcKeyNo}"); } }
public void OverwriteAllSeriesTimeWith(int seriesIndex) { //check if index is in config bounds if (seriesIndex >= 0 && seriesIndex < mLinePlotConfig.SeriesConfigs.Count) { // check if seriesIndex is in the display series List item bounds if (seriesIndex <= SeriesConfigListItems.Count) { StartEndVarTime time = MeasurementHelper.GetStartEndTimes(mLinePlotConfig.SeriesConfigs[seriesIndex].Measurement); // check if we got valid times for overwriting from the measurement if (time != null) { VariableTime fromTime = time.StartTime; VariableTime toTime = time.EndTime; for (int configIter = 0; configIter < mLinePlotConfig.SeriesConfigs.Count; configIter++) { IMeasurement seriesMeas = mLinePlotConfig.SeriesConfigs[configIter].Measurement; if (seriesMeas is RandomTimeSeriesMeasurement randomMeas) { randomMeas.FromTime = fromTime.Clone(); randomMeas.ToTime = toTime.Clone(); } else if (seriesMeas is ScadaMeasurement scadaMeas) { scadaMeas.StartTime = fromTime.Clone(); scadaMeas.EndTime = toTime.Clone(); } else if (seriesMeas is PMUMeasurement pmuMeas) { pmuMeas.StartTime = fromTime.Clone(); pmuMeas.EndTime = toTime.Clone(); } else if (seriesMeas is PspMeasurement pspMeas) { pspMeas.StartTime = fromTime.Clone(); pspMeas.EndTime = toTime.Clone(); } } } } SyncSeriesConfigListItemsWithConfig(); } }
/// <summary> /// Sets the image properties. /// </summary> /// <param name="image">The image.</param> /// <param name="graphic">The graphic.</param> /// <returns>The pdf image with the converted odf graphic properties.</returns> private iTextSharp.text.Image SetImageProperties(iTextSharp.text.Image image, Frame frame) { try { if (frame.Style is FrameStyle) { if (((FrameStyle)frame.Style).GraphicProperties != null) { if (((FrameStyle)frame.Style).GraphicProperties.HorizontalPosition != null) { string pos = ((FrameStyle)frame.Style).GraphicProperties.HorizontalPosition; switch (pos) { case "center": image.Alignment = iTextSharp.text.Image.TEXTWRAP | iTextSharp.text.Image.ALIGN_CENTER; break; case "left": image.Alignment = iTextSharp.text.Image.TEXTWRAP | iTextSharp.text.Image.ALIGN_LEFT; break; case "right": image.Alignment = iTextSharp.text.Image.TEXTWRAP | iTextSharp.text.Image.ALIGN_RIGHT; break; default: break; } } if (((FrameStyle)frame.Style).GraphicProperties.MarginLeft != null) { string marginLeft = ((FrameStyle)frame.Style).GraphicProperties.MarginLeft; if (marginLeft != null) { double mLeft = AODL.Document.Helper.SizeConverter.GetDoubleFromAnOfficeSizeValue(marginLeft); if (AODL.Document.Helper.SizeConverter.IsCm(marginLeft)) { int pLeft = MeasurementHelper.CmToPoints(mLeft); image.IndentationLeft = (float)pLeft; } else { int pLeft = MeasurementHelper.CmToPoints(mLeft); image.IndentationLeft = (float)pLeft; } } } if (((FrameStyle)frame.Style).GraphicProperties.MarginRight != null) { string marginRight = ((FrameStyle)frame.Style).GraphicProperties.MarginRight; if (marginRight != null) { double mRight = AODL.Document.Helper.SizeConverter.GetDoubleFromAnOfficeSizeValue(marginRight); if (AODL.Document.Helper.SizeConverter.IsCm(marginRight)) { int pRight = MeasurementHelper.CmToPoints(mRight); image.IndentationRight = (float)pRight; } else { int pRight = MeasurementHelper.InchToPoints(mRight); image.IndentationRight = (float)pRight; } } } } } return(image); } catch (Exception) { throw; } }
static void Main(string[] args) { SpiralLab.Core.Initialize(); //initializing spirallab.sirius library engine (시리우스 라이브러리 초기화) #region initialize RTC //var rtc = new RtcVirtual(0); //create Rtc for dummy (가상 RTC 카드) var rtc = new Rtc5(0); //create Rtc5 controller //var rtc = new Rtc6(0); //create Rtc6 controller //var rtc = new Rtc6Ethernet(0, "192.168.0.100", "255.255.255.0"); //Rtc6 Ethernet //var rtc = new Rtc6SyncAxis(0, Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "syncAxis", "syncAXISConfig.xml")); //Scanlab XLSCAN float fov = 60.0f; // scanner field of view : 60mm float kfactor = (float)Math.Pow(2, 20) / fov; // k factor (bits/mm) = 2^20 / fov var correctionFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "correction", "cor_1to1.ct5"); rtc.Initialize(kfactor, LaserMode.Yag1, correctionFile); // correction file (스캐너 보정 파일) #endregion #region initialize Laser (virtual) var laser = new LaserVirtual(0, "virtual", 20); // virtual laser source with max 20W power (최대 출력 20W 의 가상 레이저 소스 생성) //var laser = new IPGYLP(0, "IPG YLP", 1, 20); //var laser = new JPTTypeE(0, "JPT Type E", 1, 20); //var laser = new SPIG4(0, "SPI G3/4", 1, 20); //var laser = new PhotonicsIndustryDX(0, "PI", 1, 20); //var laser = new AdvancedOptoWaveFotia(0, "Fotia", 1, 20); //var laser = new CoherentAviaLX(0, "Avia LX", 1, 20); laser.Rtc = rtc; laser.Initialize(); laser.CtlPower(2); #endregion ConsoleKeyInfo key; do { Console.WriteLine($"{Environment.NewLine}"); Console.WriteLine("Testcase for spirallab.sirius. powered by [email protected] (http://spirallab.co.kr)"); Console.WriteLine($"----------------------------------------------------------------------------------------"); Console.WriteLine("'C' : draw circle with measurement"); Console.WriteLine("'R' : draw rectangle with measurement"); Console.WriteLine("'O' : open and plot measurement file"); Console.WriteLine("'Q' : quit"); Console.Write("Select your target : "); key = Console.ReadKey(false); Console.WriteLine($"{Environment.NewLine}"); if (key.Key == ConsoleKey.Q) { break; } switch (key.Key) { case ConsoleKey.C: // draw circle (원 모양 가공) DrawCircle(laser, rtc, 10); break; case ConsoleKey.R: // draw rectangle (사각형 모양 가공) DrawRectangle(laser, rtc, 10, 10); break; case ConsoleKey.O: // open file var dlg = new OpenFileDialog(); dlg.Filter = "measurement data files (*.txt)|*.txt|All Files (*.*)|*.*"; dlg.Title = "Open Measurement File"; dlg.InitialDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "plot"); DialogResult result = dlg.ShowDialog(); if (result != DialogResult.OK) { return; } MeasurementHelper.Plot(dlg.FileName); break; } } while (true); if (rtc.CtlGetStatus(RtcStatus.Busy)) { rtc.CtlAbort(); rtc.CtlBusyWait(); } rtc.Dispose(); }