Ejemplo n.º 1
0
            static string patch(BoardTypes board_type, int voltage_gain, int current_gain)
            {
                Ember ember = new Ember();
                ember.EmberBinPath = @"C:\Program Files (x86)\Ember\ISA3 Utilities\bin";
                ember.BatchFilePath = @"C:\Users\victormartin\.calibration\patchit.bat";
                string msg;
                switch (board_type)
                {
                    case (powercal.BoardTypes.humpback):
                        ember.VAdress = 0x08080980;
                        ember.IAdress = 0x08080984;
                        ember.RefereceAdress = 0x08080988;
                        ember.ACOffsetAdress = 0x080809CC;

                        ember.VRefereceValue = 0xF0; // 240 V
                        ember.IRefereceValue = 0x0F; // 15 A

                        break;
                    case (powercal.BoardTypes.zebrashark):
                    case (powercal.BoardTypes.hooktooth):
                    case (powercal.BoardTypes.milkshark):
                        ember.VAdress = 0x08040980;
                        ember.IAdress = 0x08040984;
                        ember.ACOffsetAdress = 0x080409CC;

                        ember.VRefereceValue = 0x78; // 120 V
                        ember.IRefereceValue = 0x0F; // 15 A

                        break;
                }
                ember.CreateCalibrationPatchBath(voltage_gain, current_gain);

                bool patchit_fail = false;
                string exception_msg = "";
                string coding_output = "";
                // Retry patch loop if fail
                while (true)
                {
                    patchit_fail = false;
                    exception_msg = "";
                    coding_output = "";
                    try
                    {
                        string output = ember.RunCalibrationPatchBatch();
                        if (output.Contains("ERROR:"))
                        {
                            patchit_fail = true;
                            exception_msg = "Patching error detected:\r\n";
                            exception_msg += output;
                        }
                        coding_output = output;
                    }
                    catch (Exception e)
                    {
                        patchit_fail = true;
                        exception_msg = "Patching exception detected:\r\n";
                        exception_msg += e.Message;
                    }

                    if (patchit_fail)
                    {
                        string retry_err_msg = exception_msg;
                        int max_len = 1000;
                        if (retry_err_msg.Length > max_len)
                            retry_err_msg = retry_err_msg.Substring(0, max_len) + "...";

                        msg = "Patching fail";
                        Console.WriteLine(msg);
                        Debug.WriteLine(msg);
                    }
                    else
                    {
                        break;
                    }

                }

                return coding_output;
            }
Ejemplo n.º 2
0
            static string patch(BoardTypes board_type, int voltage_gain, int current_gain)
            {
                Ember ember = new Ember();

                ember.EmberBinPath  = @"C:\Program Files (x86)\Ember\ISA3 Utilities\bin";
                ember.BatchFilePath = @"C:\Users\victormartin\.calibration\patchit.bat";
                string msg;

                switch (board_type)
                {
                case (powercal.BoardTypes.humpback):
                    ember.VAdress        = 0x08080980;
                    ember.IAdress        = 0x08080984;
                    ember.RefereceAdress = 0x08080988;
                    ember.ACOffsetAdress = 0x080809CC;

                    ember.VRefereceValue = 0xF0;     // 240 V
                    ember.IRefereceValue = 0x0F;     // 15 A

                    break;

                case (powercal.BoardTypes.zebrashark):
                case (powercal.BoardTypes.hooktooth):
                case (powercal.BoardTypes.milkshark):
                    ember.VAdress        = 0x08040980;
                    ember.IAdress        = 0x08040984;
                    ember.ACOffsetAdress = 0x080409CC;

                    ember.VRefereceValue = 0x78;     // 120 V
                    ember.IRefereceValue = 0x0F;     // 15 A

                    break;
                }
                ember.CreateCalibrationPatchBath(voltage_gain, current_gain);

                bool   patchit_fail  = false;
                string exception_msg = "";
                string coding_output = "";

                // Retry patch loop if fail
                while (true)
                {
                    patchit_fail  = false;
                    exception_msg = "";
                    coding_output = "";
                    try
                    {
                        string output = ember.RunCalibrationPatchBatch();
                        if (output.Contains("ERROR:"))
                        {
                            patchit_fail   = true;
                            exception_msg  = "Patching error detected:\r\n";
                            exception_msg += output;
                        }
                        coding_output = output;
                    }
                    catch (Exception e)
                    {
                        patchit_fail   = true;
                        exception_msg  = "Patching exception detected:\r\n";
                        exception_msg += e.Message;
                    }

                    if (patchit_fail)
                    {
                        string retry_err_msg = exception_msg;
                        int    max_len       = 1000;
                        if (retry_err_msg.Length > max_len)
                        {
                            retry_err_msg = retry_err_msg.Substring(0, max_len) + "...";
                        }

                        msg = "Patching fail";
                        Console.WriteLine(msg);
                        Debug.WriteLine(msg);
                    }
                    else
                    {
                        break;
                    }
                }

                return(coding_output);
            }