The MDI-viewer

MDI

I created this software especially for the exposing machine (MDI by Schmoll company).

During exposing of panels the MDI-software writes some XML files to the drive.
The purpose of this project is to read these XML-files and displays the data in a readable form.
The data included in XML files are: job name, layer name, number of panel, scale factors and the date. Scale parameters are calculated on the fly to get an average value.

The technology

The software is written in C# language using the Visual Studio as IDE. The MDI Viewer is a pure dotNet project based on Windows Forms using the network functionality. The software has not any visible menu, functions are hidden behind function keys. (requirement)

All XML files included in a folder are read one by one to the memory and separated by their content. Having all values it is possible to calculate avarage values for scale factors. Finally all informations are displayed in a grid table.
To show the working status a BackgroundWorker was used as a separate thread. The settings are saved in a XML file as well.

readXML

private List<customPair> readXML(string myXMLFile)

{

    List<customPair> myList = new List<customPair>();

    if (string.IsNullOrEmpty(myXMLFile))

    {

        return myList;

    }


    XmlReaderSettings readerSettings = new XmlReaderSettings();

    readerSettings.IgnoreWhitespace = true;


    // Create a resolver with default credentials.

    XmlUrlResolver resolver = new XmlUrlResolver();

    resolver.Credentials = System.Net.CredentialCache.DefaultCredentials;

    readerSettings.XmlResolver = resolver;


    DateTime myMissingDate = DateTime.Parse("01-01-0001 00:00:00");


    XmlReader reader = null;

    XmlReader myPartSubtree = null;

    try

    {

        reader = XmlReader.Create(myXMLFile, readerSettings);

        string myTempName = "";

        do

        {

            if (reader.Name == "job_layer")

            {

                do

                {

                    customPair cp = new customPair();

                    if (reader.Name == "name")

                    {

                        reader.Read();

                        if (reader.Value != "")

                        {

                            myTempName = reader.Value;

                            cp.item_name = myTempName;

                        }

                        else

                        {

                            cp.item_name = "";

                        }

                    }

                    else if (reader.Name == "part")

                    {

                        cp.item_name = myTempName;


                        myPartSubtree = reader.ReadSubtree();

                        myPartSubtree.ReadToFollowing("index");

                        myPartSubtree.Read();

                        cp.part_index = Int32.Parse(myPartSubtree.Value);


                        myPartSubtree.ReadToFollowing("t_start");

                        myPartSubtree.Read();

                        cp.part_tstart = DateTime.Parse(myPartSubtree.Value);


                        myPartSubtree.ReadToFollowing("t_end");

                        myPartSubtree.Read();

                        cp.part_tend = DateTime.Parse(myPartSubtree.Value);


                        myPartSubtree.ReadToFollowing("process");

                        myPartSubtree.Read();

                        cp.part_process = Int32.Parse(myPartSubtree.Value);


                        myPartSubtree.ReadToFollowing("result");

                        myPartSubtree.Read();

                        cp.part_result = Int32.Parse(myPartSubtree.Value);


                        myPartSubtree.ReadToFollowing("alignment_scale");

                        cp.part_align_scale_x = float.Parse(reader.GetAttribute(0), CultureInfo.InvariantCulture);

                        cp.part_align_scale_y = float.Parse(reader.GetAttribute(1), CultureInfo.InvariantCulture);

                        cp.part_align_scale_z = float.Parse(reader.GetAttribute(2), CultureInfo.InvariantCulture);


                        myPartSubtree.ReadToFollowing("alignment_offset");

                        cp.part_align_offset_x = float.Parse(reader.GetAttribute(0), CultureInfo.InvariantCulture);

                        cp.part_align_offset_y = float.Parse(reader.GetAttribute(1), CultureInfo.InvariantCulture);

                        cp.part_align_offset_z = float.Parse(reader.GetAttribute(2), CultureInfo.InvariantCulture);


                        myPartSubtree.ReadToFollowing("alignment_angle_cw");

                        myPartSubtree.Read();

                        cp.part_align_angle = double.Parse(myPartSubtree.Value, CultureInfo.InvariantCulture);


                        myPartSubtree.Close();

                    }


                    if ((!String.IsNullOrEmpty(cp.item_name)) && (cp.part_tstart != myMissingDate) && (cp.part_tend != myMissingDate))

                    {

                        myList.Add(cp);

                    }

                } while (reader.Read());

            }

        } while (reader.Read());

    }

    catch (FileNotFoundException ex)

    {

        Console.WriteLine(ex.Message);

    }

    // specjalnie dla win2k

    catch (IOException ioex)

    {

        Console.WriteLine(ioex.Message);

    }

    finally

    {

        // close handle

        if (myPartSubtree != null)

        {

            myPartSubtree.Close();

        }

        if (reader != null)

        {

            // Console.WriteLine(reader.ReadState);

            reader.Close();

        }

    }

    return myList;

}


The build-up viewer

This program was very popular among CAM-worker as it helps with searching of a right build-up for multilayer board. Because of many different build-ups existing in the database, it is very time-consumed to find a proper build-up, which can be used immediately, instead of create a new one from scratch. The time savings was about 50% by using this viewer, so multiplying by the number of CAM workers we get a number of saved working hours.

Below you can see a constructor of myXALDB-class, which initializes the connection to the Oracle Database. The function getJobParameters() can read some data from the database and returns it in a List. Because of the used version of Oracle Database it is very important to use a proper client, as not any Oracle-client can create the connection.

myXALDB

public class myXALDB

{

    public bool isInitialized = false;

    OracleConnection myConnection;


    public myXALDB(string enc_user, string enc_password, string enc_dbService)

    {

        string[] myCredentials = decode(enc_user, enc_password, enc_dbService);

        bool rs = initDB(myCredentials);

        if (rs)

        {

            string connectionString = "DATA SOURCE = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = " +

                "(COMMUNITY = tcp)(PROTOCOL = TCP)(Host = 192.168.100.6)(" +

                "Port = 1521))) (CONNECT_DATA = (SID = xalora) (GLOBAL_NAME = xalora))); " +

                "PERSIST SECURITY INFO=True; USER ID=userID; PASSWORD=userPWD";

            try

            {

                this.myConnection = new OracleConnection(connectionString);

                myConnection.Open();

                Console.WriteLine("Connected to {0}", myConnection.ServerVersion);

                isInitialized = true;

                myConnection.Close();

            }

            catch (Exception ex)

            {

                MessageBox.Show(ex.Message, "myXALDB");

                isInitialized = false;

            }

        }

        else

        {

            isInitialized = false;

        }

    }


    // function returns a list of build-up components for a particular job number (vareNummer)

    internal List<BuildUpParameters> getJobParameters(string vareNummer)

    {

        List<BuildUpParameters> myLOP = new List<BuildUpParameters>();

        string cmdtxt =

             "select rpv.RXPLADE, rpv.PLADETYKKELSE, rpv.PLADENAVN, rpv.CUTYKSIDE1, rpv.CUTYKSIDE2, " +

             "rpv.LINIENR, lk.VARENAVN, pk.PRINTTYPE, pk.VARENUMMER, rpt.KUNDENAVN " +

             "from XAL_SUPERVISOR.DD_RXPLADEVALG rpv, XAL_SUPERVISOR.LAGERKART lk, " +

             "XAL_SUPERVISOR.DD_PRINTKART pk, XAL_SUPERVISOR.DD_RXPLADETYPER rpt " +

             "WHERE pk.VARENUMMER = :vareNummer " +

             "AND rpv.PRINTTYPE = rpt.TYPENAVN AND rpt.TYPENAVN = pk.TYPENAVN " +

             "AND lk.VARENUMMER = rpv.RXPLADE " + "ORDER BY rpv.LINIENR";

        try

        {

            myConnection.Open();

            OracleCommand cmd = new OracleCommand(cmdtxt, myConnection);

            cmd.Parameters.Clear();

            cmd.Parameters.Add("vareNummer", vareNummer);

            OracleDataReader odr = cmd.ExecuteReader();

            while (odr.Read())

            {

                myLOP.Add(new BuildUpParameters

                {

                    rxplade = odr.GetOracleString(0).Value,

                    pladetykkelse = odr.GetOracleDecimal(1).Value,

                    pladenavn = odr.GetOracleString(2).Value,

                    cutykside1 = odr.GetOracleDecimal(3).Value,

                    cutykside2 = odr.GetOracleDecimal(4).Value,

                    linienr = odr.GetOracleDecimal(5).Value,

                    varenavn = odr.GetOracleString(6).Value,

                    printtype = odr.GetOracleString(7).Value,

                    varenummer = odr.GetOracleString(8).Value,

                    kundenavn = odr.GetOracleString(9).Value

                });

            }

            odr.Close();

            cmd.Dispose();

        }

        catch (Exception e)

        {

            Console.WriteLine(e.Message);

        }

        finally

        {

            myConnection.Close();

        }

        return myLOP;

    }

}