Ejemplo n.º 1
0
        public static void WriteIf(string key,
                                   ErrCategory category,
                                   ErrLevel level,
                                   string factoryID,
                                   string shopID,
                                   string lotID,
                                   string productID,
                                   string productVer,
                                   string processID,
                                   string eqpID,
                                   string stepID,
                                   string reason,
                                   string detail
                                   )
        {
            if (CheckList.ContainsKey(key))
            {
                return;
            }

            CheckList.Add(key, key);

            AddRow(category,
                   level,
                   factoryID,
                   shopID,
                   lotID,
                   productID,
                   productVer,
                   processID,
                   eqpID,
                   stepID,
                   reason,
                   detail);
        }
Ejemplo n.º 2
0
 public Err(ErrLevel ec, int code, string mess)
 {
     Level = ec;
     Code = code;
     Message = mess ?? String.Empty;
     MessageSplitter = Environment.NewLine;
 }
Ejemplo n.º 3
0
        // Write to Error Log and output message to user (Type 2: Does not use exceptions.)
        public static void Log(String Message, ErrLevel Level)
        {
            if (Level == ErrLevel.INTERNAL)
            {
                return;
            }

            // Append to the file
            StreamWriter OutputStream = new StreamWriter(Application.StartupPath + "/ErrorLog.txt", true);

            // Attempt to write to file and close it
            OutputStream.WriteLine("Site Configuration File: " + RunFileName);
            OutputStream.WriteLine("Input File line: " + iterationCount);
            OutputStream.WriteLine("Error Description: " + Level + ": " + Message);
            OutputStream.WriteLine("--------------------------------------------------------");
            OutputStream.Close();

            // Using switch statements to determine if the program should exit
            switch (Level)
            {
            case ErrLevel.FATAL:
                Console.WriteLine("CASSYS has stopped the simulation. Please check the end of the Error Log at " + Application.StartupPath + " for details.");
                Environment.Exit(1);
                break;

            case ErrLevel.WARNING:
                numWarnings++;
                break;
            }
        }
Ejemplo n.º 4
0
        private static void AddRow(ErrCategory category,
                                   ErrLevel level,
                                   string factoryID,
                                   string shopID,
                                   string lotID,
                                   string productID,
                                   string productVer,
                                   string processID,
                                   string eqpID,
                                   string stepID,
                                   string reason,
                                   string detail
                                   )
        {
            Outputs.ErrorHistory item = new ErrorHistory();

            item.VERSION_NO = ModelContext.Current.VersionNo;

            item.ERR_CATEGORY    = category.ToString();
            item.ERR_LEVEL       = level.ToString();
            item.FACTORY_ID      = factoryID;
            item.SHOP_ID         = shopID;
            item.LOT_ID          = lotID;
            item.PRODUCT_ID      = productID;
            item.PRODUCT_VERSION = productVer;
            item.PROCESS_ID      = processID;
            item.EQP_ID          = eqpID;
            item.STEP_ID         = stepID;
            item.ERR_REASON      = reason;
            item.REASON_DETAIL   = detail;

            OutputMart.Instance.ErrorHistory.Add(item);
        }
Ejemplo n.º 5
0
 public void Action_InsertMessage(int SourceLineIndex,CodeErrMessage errMessage,ErrLevel errorLevel,bool isInterrup)
 {
     MessageItem newItem = new MessageItem();
     newItem.SourceLineIndex = SourceLineIndex;
     newItem.ErrorMessage = errMessage;
     newItem.ErrorLevel = errorLevel;
     newItem.Interrup = isInterrup;
 }
Ejemplo n.º 6
0
 // Check assertion, and if not true, then write to error log.
 public static void Assert(String Message, bool check, ErrLevel Level)
 {
     if (check)
     {
         // Do nothing.
     }
     else
     {
         ErrorLogger.Log(Message, Level);
     }
 }
Ejemplo n.º 7
0
        public NTF(int modnr, string id, string issuer, ErrLevel level, string errortext, string options, string desc) : base(modnr, id, desc)
        {
            ModNr       = modnr;
            _Issuer     = issuer;
            _ErrorLevel = level;
            _ErrorText  = errortext;
            _addedtext  = " "; //should not be null

            _Options      = options;
            _userReply    = 0;
            _Acknowledged = false;
            _isRaised     = false;
        }
Ejemplo n.º 8
0
        internal static void WriteLoadWipError(string key, Wip item, ErrLevel errLevel, string reason, string detail)
        {
            key = string.Format("Load Wip:{0}", key);

            WriteIf(key,
                    ErrCategory.PERSIST,
                    errLevel,
                    item.FACTORY_ID,
                    item.SHOP_ID,
                    item.LOT_ID,
                    item.PRODUCT_ID,
                    item.PRODUCT_VERSION,
                    item.PROCESS_ID,
                    item.EQP_ID,
                    item.STEP_ID,
                    reason,
                    detail);
        }
Ejemplo n.º 9
0
        public static int iterationCount;                              // Number of iterations [#]

        // Write to Error Log and output message to user (Type 1: Uses exceptions.)
        public static void Log(Exception err, ErrLevel Level)
        {
            if (Level == ErrLevel.INTERNAL)
            {
                return;
            }

            try
            {
                // Append to the file
                StreamWriter OutputStream = new StreamWriter(Application.StartupPath + "/ErrorLog.txt", true);

                // Attempt to write to file and close it
                OutputStream.WriteLine("Site Configuration File: " + RunFileName);
                OutputStream.WriteLine("Input line: " + iterationCount);
                OutputStream.WriteLine("Error Description: " + Level + ": " + err.Message);
                OutputStream.WriteLine("--------------------------------------------------------");
                OutputStream.Close();
            }
            catch (Exception e)
            {
                // If there was a problem tell the user
                Console.WriteLine("The Error Log is not accessible!" + e.ToString());
                Level = ErrLevel.FATAL;
            }

            // Using switch statements to determine if the program should exit
            switch (Level)
            {
            case ErrLevel.FATAL:
                Console.WriteLine("An error occurred while running CASSYS. Please check the Error Log at " + Application.StartupPath + " for details.");
                Environment.Exit(1);
                break;

            case ErrLevel.WARNING:
                numWarnings++;
                break;
            }
        }
Ejemplo n.º 10
0
        private void add_error(ErrLevel lvl, int code, string msg)
        {
            if (lvl > this.Level) {
                this.Level = lvl;
                if (code > 0) this.Code = Code;
            }

            //Сообщения все равно складываются, независимо от наличия ошибок

            if (!String.IsNullOrEmpty(msg)) {
                if (this.Message.Length > 0) this.Message += this.MessageSplitter;
                this.Message += msg;
            }
        }
Ejemplo n.º 11
0
 public Err Add(ErrLevel level, string message)
 {
     return Add(level, 0, message);
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Взамен err += new Err(...) можно писать err.Add(...);
 /// </summary>
 /// <param name="message"></param>
 /// <returns></returns>
 public Err Add(ErrLevel level, int code, string message)
 {
     add_error(level, code, message);
     return this;
 }
Ejemplo n.º 13
0
        public void Action_InsertMessage(int SourceLineIndex, CodeErrMessage errMessage, ErrLevel errorLevel, bool isInterrup)
        {
            MessageItem newItem = new MessageItem();

            newItem.SourceLineIndex = SourceLineIndex;
            newItem.ErrorMessage    = errMessage;
            newItem.ErrorLevel      = errorLevel;
            newItem.Interrup        = isInterrup;
        }
Ejemplo n.º 14
0
        // Returns the attribute of the node, if the node and an attribute exist
        public static String GetAttribute(String Path, String AttributeName, ErrLevel _Error = ErrLevel.WARNING, String _VersionNum = "0.9", String _Adder = null, int _ArrayNum = 0)
        {
            try
            {
                if (String.Compare(EngineVersion, _VersionNum) >= 0)
                {
                    switch (Path)
                    {
                    case "Site":
                        Path = (String.Compare(CASSYSCSYXVersion, "1.5.2") < 0 ? "/Site" : "/SiteDef") + _Adder;
                        break;

                    case "Albedo":
                        Path = (String.Compare(CASSYSCSYXVersion, "1.5.2") < 0 ? "/Site/Albedo" : "/Site/SiteDef/Albedo") + _Adder;
                        break;

                    case "O&S":
                        Path = "/Site/Orientation_and_Shading" + _Adder;
                        break;

                    case "Bifacial":
                        Path = "/Site/Bifacial" + _Adder;
                        break;

                    case "BifAlbedo":
                        Path = "/Site/Bifacial/BifAlbedo" + _Adder;
                        break;

                    case "System":
                        Path = "/Site/System" + _Adder;
                        break;

                    case "PV":
                        Path = "/Site/System/" + "SubArray" + _ArrayNum + "/PVModule" + _Adder;
                        break;

                    case "Inverter":
                        Path = "/Site/System/" + "SubArray" + _ArrayNum + "/Inverter" + _Adder;
                        break;

                    case "Losses":
                        Path = (String.Compare(CASSYSCSYXVersion, "1.5.2") < 0 ? "/Site/System/Losses" : "/Site/Losses") + _Adder;
                        break;

                    case "SoilingLosses":
                        Path = (String.Compare(CASSYSCSYXVersion, "1.5.2") < 0 ? "/Site/System/Losses/SoilingLosses" : "/Site/SoilingLosses") + _Adder;
                        break;

                    case "Spectral":
                        Path = "/Site/Spectral" + _Adder;
                        break;

                    case "InputFile":
                        Path = "/Site/InputFileStyle" + _Adder;
                        break;

                    case "OutputFile":
                        Path = "/Site/OutputFileStyle" + _Adder;
                        break;

                    case "Iteration1":
                        Path = "/Site/Iterations/Iteration1" + _Adder;
                        break;
                    }

                    return(doc.SelectSingleNode(Path).Attributes[AttributeName].Value);
                }
                else
                {
                    ErrorLogger.Log(AttributeName + " is not available in this version of CASSYS. Please update to the latest version available at https://github.com/CanadianSolar/CASSYS", ErrLevel.WARNING);
                    return(null);
                }
            }
            catch (NullReferenceException)
            {
                if (_Error == ErrLevel.FATAL)
                {
                    ErrorLogger.Log(AttributeName + " in " + Path + " is not defined. CASSYS requires this value to run.", ErrLevel.FATAL);
                    return("N/A");
                }
                else
                {
                    ErrorLogger.Log(AttributeName + " in " + Path + " is not defined. CASSYS assigned 0 for this value.", ErrLevel.WARNING);
                    return("0");
                }
            }
        }
Ejemplo n.º 15
0
 public FxErrArgs(ErrLevel level, Exception ex)
     : this(level, string.Empty, ex)
 {
 }
Ejemplo n.º 16
0
 public FxErrArgs(ErrLevel level, string summary, Exception ex)
 {
     this.level   = level;
     this.summary = summary;
     this.ex      = ex;
 }
Ejemplo n.º 17
0
        // Returns the value of the node, if the node exists
        public static String GetInnerText(String Path, String NodeName, ErrLevel _Error = ErrLevel.WARNING, String _VersionNum = "0.9", int _ArrayNum = 0, String _default = "0")
        {
            try
            {
                if (String.Compare(EngineVersion, _VersionNum) >= 0)
                {
                    // Determine the Path of the .CSYX requested
                    switch (Path)
                    {
                    case "Site":
                        Path = "/Site/" + NodeName;
                        break;

                    case "SiteDef":
                        Path = (String.Compare(CASSYSCSYXVersion, "1.5.2") < 0 ? "/Site/" : "/Site/SiteDef/") + NodeName;
                        break;

                    case "ASTM":
                        Path = "/Site/ASTMRegress/" + NodeName;
                        break;

                    case "ASTM/Coeffs":
                        Path = "/Site/ASTMRegress/ASTMCoeffs/" + NodeName;
                        break;

                    case "ASTM/EAF":
                        Path = "/Site/ASTMRegress/EAF/" + NodeName;
                        break;

                    case "Albedo":
                        Path = (String.Compare(CASSYSCSYXVersion, "1.5.2") < 0 ? "/Site/Albedo/" : "/Site/SiteDef/Albedo/") + NodeName;
                        break;

                    case "O&S":
                        Path = "/Site/Orientation_and_Shading/" + NodeName;
                        break;

                    case "Bifacial":
                        Path = "/Site/Bifacial/" + NodeName;
                        break;

                    case "BifAlbedo":
                        Path = "/Site/Bifacial/BifAlbedo/" + NodeName;
                        break;

                    case "System":
                        Path = "/Site/System/" + NodeName;
                        break;

                    case "PV":
                        Path = "/Site/System/" + "SubArray" + _ArrayNum + "/PVModule/" + NodeName;
                        break;

                    case "Inverter":
                        Path = "/Site/System/" + "SubArray" + _ArrayNum + "/Inverter/" + NodeName;
                        break;

                    case "Transformer":
                        Path = (String.Compare(CASSYSCSYXVersion, "1.5.2") < 0 ? "/Site/System/Transformer/" : "/Site/Transformer/") + NodeName;
                        break;

                    case "Losses":
                        Path = (String.Compare(CASSYSCSYXVersion, "1.5.2") < 0 ? "/Site/System/Losses/" : "/Site/Losses/") + NodeName;
                        break;

                    case "SoilingLosses":
                        Path = (String.Compare(CASSYSCSYXVersion, "1.5.2") < 0 ? "/Site/System/Losses/SoilingLosses/" : "/Site/SoilingLosses/") + NodeName;
                        break;

                    case "Spectral":
                        Path = "/Site/Spectral/" + NodeName;
                        break;

                    case "InputFile":
                        Path = "/Site/InputFileStyle/" + NodeName;
                        break;

                    case "OutputFile":
                        Path = "/Site/OutputFileStyle/" + NodeName;
                        break;

                    case "Iterations":
                        Path = "/Site/Iterations/" + NodeName;
                        break;
                    }
                    // Check if the .CSYX Blank, if it is, return the default value
                    if (doc.SelectSingleNode(Path).InnerText == "")
                    {
                        if (_Error == ErrLevel.FATAL)
                        {
                            ErrorLogger.Log(NodeName + " is not defined. CASSYS requires this value to run.", ErrLevel.FATAL);
                            return("N/A");
                        }
                        else if (_Error == ErrLevel.WARNING)
                        {
                            ErrorLogger.Log("Warning: " + NodeName + " is not defined for this file. CASSYS assigned " + _default + " for this value.", ErrLevel.WARNING);
                            return(_default);
                        }
                        else
                        {
                            return(_default);
                        }
                    }
                    else
                    {
                        return(doc.SelectSingleNode(Path).InnerText);
                    }
                }
                else
                {
                    ErrorLogger.Log(NodeName + " is not supported in this version of CASSYS. Please update your CASSYS Site file using the latest version available at https://github.com/CanadianSolar/CASSYS", ErrLevel.WARNING);
                    return(null);
                }
            }
            catch (NullReferenceException)
            {
                if (_Error == ErrLevel.WARNING || _Error == ErrLevel.INTERNAL)
                {
                    return(_default);
                }
                else
                {
                    ErrorLogger.Log(NodeName + " is not defined. CASSYS requires this value to run.", ErrLevel.FATAL);
                    return("N/A");
                }
            }
        }