// Copyright 🄫 2023 Elekta K.K. using Elekta.MonacoScripting.API; using Elekta.MonacoScripting.API.General; using Elekta.MonacoScripting.DataType; using Elekta.MonacoScripting.Log; using System; using System.Collections.Generic; using System.Configuration; using System.Windows.Forms; namespace MLCPositionSample { internal class Program { /* This is stating the variables to be used in this script. * These variables need to be added in App.config file before being used here. * * This is an example of how the variables can be used in a script. * You can change/add/delete variables in your own scirpt. * You can also use other approaches to use variables in your script. */ // Aquire settings from App.config. [STAThread] static void Main(string[] args) { try { // Optional: invoke DeactivateExitErrorHandler to deactivate terminating this application when any error information is logged. Logger.Instance.DeactivateExitErrorHandler(); // Optional: invoke ActivateScreenShot to activate screenshot capture when any error information is logged. Logger.Instance.DeactivateScreenShot(); // Monaco application instance. MonacoApplication app = MonacoApplication.Instance; // Get current patient. var pat = app.GetCurrentPatient(); // Get active plan. var plan = app.GetActivePlan(); // Ouput information Logger.Instance.Info("+---------+------------------------+"); Logger.Instance.Info($"|Clinic |{pat.Clinic,-24}|"); Logger.Instance.Info("+---------+------------------------+"); Logger.Instance.Info($"|PatientID|{pat.Id,-24}|"); Logger.Instance.Info("+---------+------------------------+"); Logger.Instance.Info($"|Name |{pat.Name,-24}|"); Logger.Instance.Info("+---------+------------------------+"); Logger.Instance.Info($"|PlanID |{plan,-24}|"); Logger.Instance.Info("+---------+------------------------+"); // Get mlc positions var mlcData = app.GetMLCPosition(); foreach (var beam in mlcData.Beams) { Logger.Instance.Info("+---------------------------+"); Logger.Instance.Info($"|Beam #{beam.Key, -4} |"); Logger.Instance.Info("+---------------------------+"); foreach (var seg in beam.Value.Segments) { Logger.Instance.Info($"|Segment #{seg.Key, -4} |"); Logger.Instance.Info("+--+--------+--------+------+"); Logger.Instance.Info($"|{"#", 2}|{"Pos1", 8}|{"Pos2", 8}|{"Parked", -6}|"); Logger.Instance.Info("+--+--------+--------+------+"); foreach (var mlc in seg.Value) { Logger.Instance.Info($"|{mlc.Key, 2}|{mlc.Value.Position1, 8:F2}|{mlc.Value.Position2, 8:F2}|{mlc.Value.Parked, -6}|"); } Logger.Instance.Info("+--+--------+--------+------+"); } } // Indicate user when the job is done. Logger.Instance.Info($"Done."); } catch (Exception ex) { // Display an error dialog if any exception is catched during script execution MessageBox.Show(ex.Message, "Exception occurred", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); } } } }