Esempio n. 1
0
        private static object syncRoot = SyncRoot_PPG_ED.Get_SyncRoot_PPG_ED();//used for thread synchronization

        public override bool Initialize(TestModeEquipmentParameters[] Inno_25GBert_EDStruct)
        {
            lock (syncRoot)
            {
                int i = 0;
                try
                {
                    if (Algorithm.FindFileName(Inno_25GBert_EDStruct, "Addr", out i))
                    {
                        Addr = Convert.ToByte(Inno_25GBert_EDStruct[i].DefaultValue);

                        switch (Addr)
                        {
                        case 0:
                            pDevice = LVEnum_1.Device_0;
                            break;

                        case 1:
                            pDevice = LVEnum_1.Device_1;
                            break;

                        case 2:
                            pDevice = LVEnum_1.Device_2;
                            break;

                        case 3:
                            pDevice = LVEnum_1.Device_3;
                            break;

                        default:
                            pDevice = LVEnum_1.Device_1;
                            break;
                        }
                    }
                    else
                    {
                        Log.SaveLogToTxt("there is no Addr");
                        return(false);
                    }

                    if (Algorithm.FindFileName(Inno_25GBert_EDStruct, "IOTYPE", out i))
                    {
                        IOType = Inno_25GBert_EDStruct[i].DefaultValue;
                    }
                    else
                    {
                        Log.SaveLogToTxt("there is no IOTYPE");
                        return(false);
                    }

                    if (Algorithm.FindFileName(Inno_25GBert_EDStruct, "DATARATE", out i))
                    {
                        dataRate = Inno_25GBert_EDStruct[i].DefaultValue;
                        //* */ Switch()
                        switch (dataRate)
                        {
                        case "25.78":
                            pDataRate = DataRate.Rate25;
                            break;

                        case "28":
                            pDataRate = DataRate.Rate28;
                            break;

                        default:
                            pDataRate = DataRate.Rate25;
                            break;
                        }

                        //pDataRate
                    }
                    else
                    {
                        Log.SaveLogToTxt("there is no DATARATE");
                        return(false);
                    }

                    if (Algorithm.FindFileName(Inno_25GBert_EDStruct, "EDGATINGTIME", out i))
                    {
                        edGatingTime = Convert.ToInt16(Inno_25GBert_EDStruct[i].DefaultValue);
                    }
                    else
                    {
                        Log.SaveLogToTxt("there is no EDGATINGTIME");
                        return(false);
                    }

                    if (Algorithm.FindFileName(Inno_25GBert_EDStruct, "RESET", out i))
                    {
                        Reset = Convert.ToBoolean(Inno_25GBert_EDStruct[i].DefaultValue);
                    }
                    else
                    {
                        Log.SaveLogToTxt("there is no RESET");
                        return(false);
                    }

                    if (Algorithm.FindFileName(Inno_25GBert_EDStruct, "NAME", out i))
                    {
                        Name = Inno_25GBert_EDStruct[i].DefaultValue;
                    }
                    else
                    {
                        Log.SaveLogToTxt("there is no NAME");
                        return(false);
                    }

                    if (Algorithm.FindFileName(Inno_25GBert_EDStruct, "EDPattern", out i))
                    {
                        EDPattern = (PrbsType)Convert.ToByte(Inno_25GBert_EDStruct[i].DefaultValue);
                    }
                    else
                    {
                        Log.SaveLogToTxt("there is no EDPattern");
                        return(false);
                    }

                    if (Algorithm.FindFileName(Inno_25GBert_EDStruct, "EDInvert", out i))
                    {
                        EDInvert = (ED_Inverted)Convert.ToByte(Inno_25GBert_EDStruct[i].DefaultValue);
                    }
                    else
                    {
                        Log.SaveLogToTxt("there is no EDInvert");
                        return(false);
                    }

                    DeviceIndex = Convert.ToByte(Addr);

                    if (Algorithm.FindFileName(Inno_25GBert_EDStruct, "TriggerOutputList".ToUpper(), out i))
                    {
                        TriggerOutputList = Inno_25GBert_EDStruct[i].DefaultValue.Split(',');
                    }
                    else
                    {
                        Log.SaveLogToTxt("there is no TriggerOutputList");
                        return(false);
                    }

                    //if (Algorithm.FindFileName(Inno_25GBert_EDStruct, "deviceIndex", out i))
                    //{
                    //    DeviceIndex = Convert.ToByte(Inno_25GBert_EDStruct[i].DefaultValue);
                    //}
                    //else
                    //{
                    //    Log.SaveLogToTxt("there is no deviceIndex");
                    //    return false;
                    //}

                    //if (Algorithm.FindFileName(Inno_25GBert_EDStruct, "FCK", out i))
                    //{
                    //    FCK = (IOPort.CFKType)Convert.ToByte(Inno_25GBert_EDStruct[i].DefaultValue);
                    //}
                    //else
                    //{
                    //    Log.SaveLogToTxt("there is no FCK");
                    //    return false;
                    //}

                    if (!Connect())
                    {
                        return(false);
                    }
                }
                catch (InnoExCeption error)
                {
                    Log.SaveLogToTxt("ErrorCode=" + ExceptionDictionary.Code._Funtion_Fatal_0x05002 + "Reason=" + error.TargetSite.Name + "Fail");
                    throw error;
                }

                catch (Exception error)
                {
                    Log.SaveLogToTxt("ErrorCode=" + ExceptionDictionary.Code._Funtion_Fatal_0x05002 + "Reason=" + error.TargetSite.Name + "Fail");
                    throw new InnoExCeption(ExceptionDictionary.Code._Funtion_Fatal_0x05002, error.StackTrace);
                    // throw new InnoExCeption(ex);
                }
                return(true);
            }
        }
        public override bool Initialize(TestModeEquipmentParameters[] inPara)
        {
            lock (syncRoot)
            {
                int i = 0;

                if (Algorithm.FindFileName(inPara, "Addr", out i))
                {
                    Addr = Convert.ToByte(inPara[i].DefaultValue);

                    switch (Addr)
                    {
                    case 0:
                        device = LVEnum_1.Device_0;
                        break;

                    case 1:
                        device = LVEnum_1.Device_1;
                        break;

                    case 2:
                        device = LVEnum_1.Device_2;
                        break;

                    case 3:
                        device = LVEnum_1.Device_3;
                        break;

                    default:
                        device = LVEnum_1.Device_1;
                        break;
                    }
                }
                else
                {
                    Log.SaveLogToTxt("there is no Addr");
                    return(false);
                }

                if (Algorithm.FindFileName(inPara, "IOTYPE", out i))
                {
                    IOType = inPara[i].DefaultValue;
                }
                else
                {
                    Log.SaveLogToTxt("there is no IOTYPE");
                    return(false);
                }

                if (Algorithm.FindFileName(inPara, "EDGATINGTIME", out i))
                {
                    edGatingTime = Convert.ToInt16(inPara[i].DefaultValue);
                }
                else
                {
                    Log.SaveLogToTxt("there is no EDGATINGTIME");
                    return(false);
                }

                if (Algorithm.FindFileName(inPara, "RESET", out i))
                {
                    Reset = Convert.ToBoolean(inPara[i].DefaultValue);
                }
                else
                {
                    Log.SaveLogToTxt("there is no RESET");
                    return(false);
                }

                if (Algorithm.FindFileName(inPara, "TriggerOutputList".ToUpper(), out i))
                {
                    outChannel = inPara[i].DefaultValue.Split(',');
                }
                else
                {
                    Log.SaveLogToTxt("there is no TriggerOutputList");
                    return(false);
                }

                if (Algorithm.FindFileName(inPara, "NAME", out i))
                {
                    Name = inPara[i].DefaultValue;
                }
                else
                {
                    Log.SaveLogToTxt("there is no NAME");
                    return(false);
                }

                if (Algorithm.FindFileName(inPara, "EDPattern", out i))
                {
                    rxPRBS = (RxPRBS)Convert.ToByte(inPara[i].DefaultValue);
                }
                else
                {
                    Log.SaveLogToTxt("there is no EDPattern");
                    return(false);
                }

                if (Algorithm.FindFileName(inPara, "DATARATE", out i))
                {
                    string dataRate = inPara[i].DefaultValue;
                    switch (dataRate)
                    {
                    case "10.3125":
                        rate = DataRate.Rate103125;
                        break;

                    case "14":
                        rate = DataRate.Rate14;
                        break;

                    default:
                        break;
                    }
                }
                else
                {
                    Log.SaveLogToTxt("there is no DATARATE");
                    return(false);
                }

                if (Algorithm.FindFileName(inPara, "EDInvert", out i))
                {
                    invent = (ED_Inverted)Convert.ToByte(inPara[i].DefaultValue);
                }
                else
                {
                    Log.SaveLogToTxt("there is no EDInvert");
                    return(false);
                }

                if (Algorithm.FindFileName(inPara, "TotalChannel".ToUpper(), out i))
                {
                    totalChannels = Convert.ToByte(inPara[i].DefaultValue);
                }
                else
                {
                    Log.SaveLogToTxt("there is no TotalChannel");
                    return(false);
                }

                if (!Connect())
                {
                    return(false);
                }

                return(true);
            }
        }