public SolderingStationObject getSolderingGlobalStatus()
        {
            SolderingStationObject tmpObj = new SolderingStationObject();

            tmpObj.success = true;

            try
            {
                Byte[] outputBuffer = new Byte[65];
                Byte[] inputBuffer = new Byte[65];

                string s = "";
                double f = 0;

                outputBuffer[0] = 0;
                outputBuffer[1] = 0x03;
                outputBuffer[2] = 0x20;

                bool success;
                success = writeRawReportToDevice(outputBuffer);

                if (success)
                {
                    // Perform the read
                    success = readSingleReportFromDevice(ref inputBuffer);


                    if (inputBuffer[3] == '1')
                    { // Iron 1 is switched on
                        tmpObj.Iron1_Running = true;
                    }
                    if (inputBuffer[3] == '0')
                    { // Iron 1 is switched on
                        tmpObj.Iron1_Running = false;
                    }
                    if (inputBuffer[5] == '1')
                    { // Iron 1 is switched on
                        tmpObj.Iron2_Running = true;
                    }
                    if (inputBuffer[5] == '0')
                    { // Iron 1 is switched on
                        tmpObj.Iron2_Running = false;
                    }

                    try
                    {

                        Byte[] SolderingIron1Temperature = new Byte[6];

                        SolderingIron1Temperature[0] = inputBuffer[7];
                        SolderingIron1Temperature[1] = inputBuffer[8];
                        SolderingIron1Temperature[2] = inputBuffer[9];
                        SolderingIron1Temperature[3] = inputBuffer[10];
                        SolderingIron1Temperature[4] = inputBuffer[11];
                        SolderingIron1Temperature[5] = inputBuffer[12];

                        s = Encoding.UTF8.GetString(SolderingIron1Temperature, 0, 6);
                        f = double.Parse(s, System.Globalization.CultureInfo.InvariantCulture.NumberFormat);

                        tmpObj.Iron1_Temperature = f;
                    }
                    catch
                    {
                        tmpObj.Iron1_Temperature = 666;
                        tmpObj.success = false;
                    }

                    try
                    {
                        Byte[] SolderingIron2Temperature = new Byte[6];

                        SolderingIron2Temperature[0] = inputBuffer[14];
                        SolderingIron2Temperature[1] = inputBuffer[15];
                        SolderingIron2Temperature[2] = inputBuffer[16];
                        SolderingIron2Temperature[3] = inputBuffer[17];
                        SolderingIron2Temperature[4] = inputBuffer[18];
                        SolderingIron2Temperature[5] = inputBuffer[19];

                        s = Encoding.UTF8.GetString(SolderingIron2Temperature, 0, 6);
                        f = double.Parse(s, System.Globalization.CultureInfo.InvariantCulture.NumberFormat);

                        tmpObj.Iron2_Temperature = f;
                    }
                    catch
                    {
                        tmpObj.Iron2_Temperature = 777;
                        tmpObj.success = false;
                    }

                    try
                    {

                        Byte[] SolderingIron1TargetTemperature = new Byte[6];

                        SolderingIron1TargetTemperature[0] = inputBuffer[21];
                        SolderingIron1TargetTemperature[1] = inputBuffer[22];
                        SolderingIron1TargetTemperature[2] = inputBuffer[23];
                        SolderingIron1TargetTemperature[3] = inputBuffer[24];
                        SolderingIron1TargetTemperature[4] = inputBuffer[25];
                        SolderingIron1TargetTemperature[5] = inputBuffer[26];

                        s = Encoding.UTF8.GetString(SolderingIron1TargetTemperature, 0, 6);
                        f = double.Parse(s, System.Globalization.CultureInfo.InvariantCulture.NumberFormat);

                        tmpObj.Iron1_Target_Temperature = f;
                    }
                    catch
                    {
                        tmpObj.Iron1_Target_Temperature = 888;
                        tmpObj.success = false;
                    }

                    try
                    {

                        Byte[] SolderingIron2TargetTemperature = new Byte[6];

                        SolderingIron2TargetTemperature[0] = inputBuffer[28];
                        SolderingIron2TargetTemperature[1] = inputBuffer[29];
                        SolderingIron2TargetTemperature[2] = inputBuffer[30];
                        SolderingIron2TargetTemperature[3] = inputBuffer[31];
                        SolderingIron2TargetTemperature[4] = inputBuffer[32];
                        SolderingIron2TargetTemperature[5] = inputBuffer[33];

                        s = Encoding.UTF8.GetString(SolderingIron2TargetTemperature, 0, 6);
                        f = double.Parse(s, System.Globalization.CultureInfo.InvariantCulture.NumberFormat);

                        tmpObj.Iron2_Target_Temperature = f;

                    }
                    catch
                    {
                        tmpObj.Iron2_Target_Temperature = 999;
                        tmpObj.success = false;
                    }

                    if (inputBuffer[35] == '1')
                    { // Iron 1 is switched on
                        tmpObj.Iron1_Activate = true;
                    }
                    if (inputBuffer[35] == '0')
                    { // Iron 1 is switched on
                        tmpObj.Iron1_Activate = false;
                    }
                    if (inputBuffer[36] == '1')
                    { // Iron 1 is switched on
                        tmpObj.Iron2_Activate = true;
                    }
                    if (inputBuffer[36] == '0')
                    { // Iron 1 is switched on
                        tmpObj.Iron2_Activate = false;
                    }

                }
                else
                {
                    tmpObj.Iron1_Activate = false;
                    tmpObj.Iron2_Activate = false;
                    tmpObj.Iron1_Running = false;
                    tmpObj.Iron2_Running = false;
                    tmpObj.Iron1_Temperature = 0;
                    tmpObj.Iron2_Temperature = 0;
                    tmpObj.Iron1_Target_Temperature = 0;
                    tmpObj.Iron2_Target_Temperature = 0;
                    tmpObj.success = false;
                }
            }
            catch
            {
                tmpObj.Iron1_Activate = false;
                tmpObj.Iron2_Activate = false;
                tmpObj.Iron1_Running = false;
                tmpObj.Iron2_Running = false;
                tmpObj.Iron1_Temperature = 0;
                tmpObj.Iron2_Temperature = 0;
                tmpObj.Iron1_Target_Temperature = 0;
                tmpObj.Iron2_Target_Temperature = 0;
                tmpObj.success = false;
            }


            return tmpObj;
        }
Example #2
0
        public SolderingStationObject getSolderingGlobalStatus()
        {
            SolderingStationObject tmpObj = new SolderingStationObject();

            tmpObj.success = true;

            try
            {
                Byte[] outputBuffer = new Byte[65];
                Byte[] inputBuffer  = new Byte[65];

                string s = "";
                double f = 0;

                outputBuffer[0] = 0;
                outputBuffer[1] = 0x03;
                outputBuffer[2] = 0x20;

                bool success;
                success = writeRawReportToDevice(outputBuffer);

                if (success)
                {
                    // Perform the read
                    success = readSingleReportFromDevice(ref inputBuffer);


                    if (inputBuffer[3] == '1')
                    { // Iron 1 is switched on
                        tmpObj.Iron1_Running = true;
                    }
                    if (inputBuffer[3] == '0')
                    { // Iron 1 is switched on
                        tmpObj.Iron1_Running = false;
                    }
                    if (inputBuffer[5] == '1')
                    { // Iron 1 is switched on
                        tmpObj.Iron2_Running = true;
                    }
                    if (inputBuffer[5] == '0')
                    { // Iron 1 is switched on
                        tmpObj.Iron2_Running = false;
                    }

                    try
                    {
                        Byte[] SolderingIron1Temperature = new Byte[6];

                        SolderingIron1Temperature[0] = inputBuffer[7];
                        SolderingIron1Temperature[1] = inputBuffer[8];
                        SolderingIron1Temperature[2] = inputBuffer[9];
                        SolderingIron1Temperature[3] = inputBuffer[10];
                        SolderingIron1Temperature[4] = inputBuffer[11];
                        SolderingIron1Temperature[5] = inputBuffer[12];

                        s = Encoding.UTF8.GetString(SolderingIron1Temperature, 0, 6);
                        f = double.Parse(s, System.Globalization.CultureInfo.InvariantCulture.NumberFormat);

                        tmpObj.Iron1_Temperature = f;
                    }
                    catch
                    {
                        tmpObj.Iron1_Temperature = 666;
                        tmpObj.success           = false;
                    }

                    try
                    {
                        Byte[] SolderingIron2Temperature = new Byte[6];

                        SolderingIron2Temperature[0] = inputBuffer[14];
                        SolderingIron2Temperature[1] = inputBuffer[15];
                        SolderingIron2Temperature[2] = inputBuffer[16];
                        SolderingIron2Temperature[3] = inputBuffer[17];
                        SolderingIron2Temperature[4] = inputBuffer[18];
                        SolderingIron2Temperature[5] = inputBuffer[19];

                        s = Encoding.UTF8.GetString(SolderingIron2Temperature, 0, 6);
                        f = double.Parse(s, System.Globalization.CultureInfo.InvariantCulture.NumberFormat);

                        tmpObj.Iron2_Temperature = f;
                    }
                    catch
                    {
                        tmpObj.Iron2_Temperature = 777;
                        tmpObj.success           = false;
                    }

                    try
                    {
                        Byte[] SolderingIron1TargetTemperature = new Byte[6];

                        SolderingIron1TargetTemperature[0] = inputBuffer[21];
                        SolderingIron1TargetTemperature[1] = inputBuffer[22];
                        SolderingIron1TargetTemperature[2] = inputBuffer[23];
                        SolderingIron1TargetTemperature[3] = inputBuffer[24];
                        SolderingIron1TargetTemperature[4] = inputBuffer[25];
                        SolderingIron1TargetTemperature[5] = inputBuffer[26];

                        s = Encoding.UTF8.GetString(SolderingIron1TargetTemperature, 0, 6);
                        f = double.Parse(s, System.Globalization.CultureInfo.InvariantCulture.NumberFormat);

                        tmpObj.Iron1_Target_Temperature = f;
                    }
                    catch
                    {
                        tmpObj.Iron1_Target_Temperature = 888;
                        tmpObj.success = false;
                    }

                    try
                    {
                        Byte[] SolderingIron2TargetTemperature = new Byte[6];

                        SolderingIron2TargetTemperature[0] = inputBuffer[28];
                        SolderingIron2TargetTemperature[1] = inputBuffer[29];
                        SolderingIron2TargetTemperature[2] = inputBuffer[30];
                        SolderingIron2TargetTemperature[3] = inputBuffer[31];
                        SolderingIron2TargetTemperature[4] = inputBuffer[32];
                        SolderingIron2TargetTemperature[5] = inputBuffer[33];

                        s = Encoding.UTF8.GetString(SolderingIron2TargetTemperature, 0, 6);
                        f = double.Parse(s, System.Globalization.CultureInfo.InvariantCulture.NumberFormat);

                        tmpObj.Iron2_Target_Temperature = f;
                    }
                    catch
                    {
                        tmpObj.Iron2_Target_Temperature = 999;
                        tmpObj.success = false;
                    }

                    if (inputBuffer[35] == '1')
                    { // Iron 1 is switched on
                        tmpObj.Iron1_Activate = true;
                    }
                    if (inputBuffer[35] == '0')
                    { // Iron 1 is switched on
                        tmpObj.Iron1_Activate = false;
                    }
                    if (inputBuffer[36] == '1')
                    { // Iron 1 is switched on
                        tmpObj.Iron2_Activate = true;
                    }
                    if (inputBuffer[36] == '0')
                    { // Iron 1 is switched on
                        tmpObj.Iron2_Activate = false;
                    }
                }
                else
                {
                    tmpObj.Iron1_Activate           = false;
                    tmpObj.Iron2_Activate           = false;
                    tmpObj.Iron1_Running            = false;
                    tmpObj.Iron2_Running            = false;
                    tmpObj.Iron1_Temperature        = 0;
                    tmpObj.Iron2_Temperature        = 0;
                    tmpObj.Iron1_Target_Temperature = 0;
                    tmpObj.Iron2_Target_Temperature = 0;
                    tmpObj.success = false;
                }
            }
            catch
            {
                tmpObj.Iron1_Activate           = false;
                tmpObj.Iron2_Activate           = false;
                tmpObj.Iron1_Running            = false;
                tmpObj.Iron2_Running            = false;
                tmpObj.Iron1_Temperature        = 0;
                tmpObj.Iron2_Temperature        = 0;
                tmpObj.Iron1_Target_Temperature = 0;
                tmpObj.Iron2_Target_Temperature = 0;
                tmpObj.success = false;
            }


            return(tmpObj);
        }