public static string CompilePlcSoftware(PlcSoftware plcSoftware)
        {
            string         message    = null;
            ICompilable    compilePLC = plcSoftware.GetService <ICompilable>();
            CompilerResult result     = compilePLC.Compile();

            message = WriteCompilerResults(result);
            return(message);
        }
Example #2
0
        private void Compile(object sender, EventArgs e)
        {
            btn_CompileHW.Enabled = false;

            string devname = txt_Device.Text;
            bool   found   = false;

            foreach (Device device in MyProject.Devices)
            {
                DeviceItemComposition deviceItemAggregation = device.DeviceItems;
                foreach (DeviceItem deviceItem in deviceItemAggregation)
                {
                    if (deviceItem.Name == devname || device.Name == devname)
                    {
                        SoftwareContainer softwareContainer = deviceItem.GetService <SoftwareContainer>();
                        if (softwareContainer != null)
                        {
                            if (softwareContainer.Software is PlcSoftware)
                            {
                                PlcSoftware controllerTarget = softwareContainer.Software as PlcSoftware;
                                if (controllerTarget != null)
                                {
                                    found = true;
                                    ICompilable compiler = controllerTarget.GetService <ICompilable>();

                                    CompilerResult result = compiler.Compile();
                                    txt_Status.Text = "Compiling of " + controllerTarget.Name + ": State: " + result.State + " / Warning Count: " + result.WarningCount + " / Error Count: " + result.ErrorCount;
                                }
                            }
                            if (softwareContainer.Software is HmiTarget)
                            {
                                HmiTarget hmitarget = softwareContainer.Software as HmiTarget;
                                if (hmitarget != null)
                                {
                                    found = true;
                                    ICompilable    compiler = hmitarget.GetService <ICompilable>();
                                    CompilerResult result   = compiler.Compile();
                                    txt_Status.Text = "Compiling of " + hmitarget.Name + ": State: " + result.State + " / Warning Count: " + result.WarningCount + " / Error Count: " + result.ErrorCount;
                                }
                            }
                        }
                    }
                }
            }
            if (found == false)
            {
                txt_Status.Text = "Found no device with name " + txt_Device.Text;
            }

            btn_CompileHW.Enabled = true;
        }
        private void CompileProject()
        {
            if (software != null)
            {
                ICompilable    compileService = software.GetService <ICompilable>();
                CompilerResult result         = compileService.Compile();

                this.BringToFront();
                Application.DoEvents();

                // result messages is array
                MessageOK("Result : " + result.State.ToString() + "\n" +
                          "Errors: " + result.ErrorCount.ToString() + "\n" +
                          "Warnings: " + result.WarningCount.ToString() + "\n",
                          "Compiler");

                IterateThroughDevices(project);
            }
        }
 protected override void DoWork()
 {
     lock (portal)
     {
         try
         {
             ICompilable    compileService = plc.GetService <ICompilable>();
             CompilerResult res            = compileService.Compile();
             if (res.State != CompilerResultState.Success)
             {
                 LogCompilerMessages(res.Messages);
             }
         }
         catch (Exception ex)
         {
             LogMessage(MessageLog.Severity.Error, "Failed to compile:\n" + ex.Message);
             return;
         }
     }
 }
Example #5
0
        // Compile plc programs
        private void BtnCompile_Click(object sender, EventArgs e)
        {
            // Determine if there are any devices checked.
            if (devicesCheckList.CheckedItems.Count != 0)
            {
                statusBox.AppendText("Systems selected: " + devicesCheckList.CheckedItems.Count);
                statusBox.AppendText(Environment.NewLine);

                // If so loop through all devices checking if they have been selected
                foreach (var device in MyProject.Devices)
                {
                    if (devicesCheckList.CheckedItems.Contains(device.Name))
                    {
                        statusBox.AppendText("Compiling system " + device.Name);
                        statusBox.AppendText(Environment.NewLine);

                        foreach (var deviceItem in device.DeviceItems)
                        {
                            PlcSoftware software = BlockManagement.GetSoftwareFrom(deviceItem);
                            if (software != null)
                            {
                                ICompilable    compileService = software.GetService <ICompilable>();
                                CompilerResult result         = compileService.Compile();

                                statusBox.AppendText(
                                    result.State + ": Compiling finished for system " +
                                    device.Name + ", " +
                                    result.WarningCount + " warnings and " +
                                    result.ErrorCount + " errors"
                                    );
                                statusBox.AppendText(Environment.NewLine);
                            }
                        }
                    }
                }
            }
        }
Example #6
0
 private static void Compile()
 {
     Console.WriteLine("Compile...");
     _hmiTarget.GetService <ICompilable>().Compile();
     _plcSoftware.GetService <ICompilable>().Compile();
 }