/// <summary> /// Get robot safe range monitoring from sheet /// </summary> /// <param name="matrix"></param> /// <param name="lastCellRange"></param> /// <returns>List with the input properties[0] and output properties[1]</returns> public static List <List <RobotSafeRangeMonitoring> > GetRobotSafeRangeMonitoring(object[,] matrix, Range lastCellRange) { var SafeRangeMonitoring = new List <List <RobotSafeRangeMonitoring> >(); var RobotProperties = new List <RobotSafeRangeMonitoring>(); List <int> FirstTextCell = OpennessHelper.TextPosInRow(matrix, lastCellRange); int row = FirstTextCell[0]; int col = FirstTextCell[1]; int colSymbol = 0; int colDataType = 0; int colAddress = 0; int colComment = 0; #region Get outputs // Get column numbers for (int i = col; i <= lastCellRange.Column; i++) { string cellVal = Convert.ToString(matrix[row, i]); if (string.IsNullOrEmpty(cellVal)) { break; } else if (cellVal.ToLower() == "symbol") { colSymbol = i; } else if (cellVal.ToLower() == "datentyp") { colDataType = i; } else if (cellVal.ToLower() == "adresse") { colAddress = i; } else if (cellVal.ToLower() == "kommentar") { colComment = i; } } // Get robot properties for (int i = row + 1; i <= lastCellRange.Row; i++) { string cellVal = Convert.ToString(matrix[i, colSymbol]); if (!string.IsNullOrEmpty(cellVal)) { string symbol = matrix[i, colSymbol].ToString(); string dataType = matrix[i, colDataType].ToString(); string address = matrix[i, colAddress].ToString(); string comment = matrix[i, colComment].ToString(); RobotProperties.Add(new RobotSafeRangeMonitoring(symbol, dataType, address, comment)); } } #endregion region SafeRangeMonitoring.Add(RobotProperties); RobotProperties = new List <RobotSafeRangeMonitoring>(); // RESET LIST #region Get inputs // Get inputs start column for (int i = col; i <= lastCellRange.Column; i++) { if (string.IsNullOrEmpty(Convert.ToString(matrix[row, i]))) { col = i + 1; break; } } // Get column numbers for (int i = col; i <= lastCellRange.Column; i++) { string cellVal = Convert.ToString(matrix[row, i]); if (string.IsNullOrEmpty(cellVal)) { break; } else if (cellVal.ToLower() == "symbol") { colSymbol = i; } else if (cellVal.ToLower() == "datentyp") { colDataType = i; } else if (cellVal.ToLower() == "adresse") { colAddress = i; } else if (cellVal.ToLower() == "kommentar") { colComment = i; } } // Get robot properties for (int i = row + 1; i <= lastCellRange.Row; i++) { string cellVal = Convert.ToString(matrix[i, colSymbol]); if (!string.IsNullOrEmpty(cellVal)) { string symbol = matrix[i, colSymbol].ToString(); string dataType = matrix[i, colDataType].ToString(); string address = matrix[i, colAddress].ToString(); string comment = matrix[i, colComment].ToString(); RobotProperties.Add(new RobotSafeRangeMonitoring(symbol, dataType, address, comment)); } } #endregion SafeRangeMonitoring.Add(RobotProperties); return(SafeRangeMonitoring); }
/// <summary> /// Get robot teclonogies from sheet /// </summary> /// <param name="matrix"></param> /// <param name="lastCellRange"></param> /// <param name="type"></param> /// <returns>List with the input properties[0] and output properties[1]</returns> public static List <List <RobotTecnologie> > GetRobotTecnologies(object[,] matrix, Range lastCellRange, string type) { var Tecnologies = new List <List <RobotTecnologie> >(); var RobotTecnologieProperties = new List <RobotTecnologie>(); List <int> FirstTextCell = OpennessHelper.TextPosInRow(matrix, lastCellRange); int row = FirstTextCell[0]; int col = FirstTextCell[1]; int colSymbolInputs = 0; int colSymbolOutputs = 0; int colDataType = 0; int colAddress = 0; int colComment = 0; #region Get outputs // Get column numbers for (int i = col; i <= lastCellRange.Column; i++) { string cellVal = Convert.ToString(matrix[row, i]); if (string.IsNullOrEmpty(cellVal)) { break; } else if (cellVal.ToLower() == "symbolik") { colSymbolOutputs = i; } else if (cellVal.ToLower() == "datentyp") { colDataType = i; } else if (cellVal.ToLower() == "adresse") { colAddress = i; } else if (cellVal.ToLower() == "kommentar") { colComment = i; } } // Get tecnologie properties for (int i = row + 1; i <= lastCellRange.Row; i++) { string tecName = Convert.ToString(matrix[i, colSymbolOutputs]); if (!tecName.Contains("<<BMK>>") && !string.IsNullOrEmpty(tecName)) //If is a tecnologie name { var name = Convert.ToString(matrix[i, colSymbolOutputs]); var fbNr = Convert.ToString(matrix[i, lastCellRange.Column]); for (int x = i + 1; x <= lastCellRange.Row; x++) { string cellVal = Convert.ToString(matrix[x, colSymbolOutputs]); if (!string.IsNullOrEmpty(cellVal) && cellVal.Contains("<<BMK>>")) { string symbol = matrix[x, colSymbolOutputs].ToString(); string dataType = matrix[x, colDataType].ToString(); string address = matrix[x, colAddress].ToString(); string comment = matrix[x, colComment].ToString(); RobotTecnologieProperties.Add(new RobotTecnologie(fbNr, name, type, symbol, dataType, address, comment)); } else { break; } i++; } } } #endregion Tecnologies.Add(RobotTecnologieProperties); RobotTecnologieProperties = new List <RobotTecnologie>(); // RESET LIST #region Get inputs // Get inputs start column for (int i = col; i <= lastCellRange.Column; i++) { if (string.IsNullOrEmpty(Convert.ToString(matrix[row, i]))) { col = i + 1; break; } } // Get column numbers for (int i = col; i <= lastCellRange.Column; i++) { string cellVal = Convert.ToString(matrix[row, i]); if (string.IsNullOrEmpty(cellVal)) { break; } else if (cellVal.ToLower() == "symbolik") { colSymbolInputs = i; } else if (cellVal.ToLower() == "datentyp") { colDataType = i; } else if (cellVal.ToLower() == "adresse") { colAddress = i; } else if (cellVal.ToLower() == "kommentar") { colComment = i; } } // Get robot properties for (int i = row + 1; i <= lastCellRange.Row; i++) { string tecName = Convert.ToString(matrix[i, colSymbolOutputs]); if (!tecName.Contains("<<BMK>>") && !string.IsNullOrEmpty(tecName)) //If is a tecnologie name { var name = Convert.ToString(matrix[i, colSymbolOutputs]); var fbNr = Convert.ToString(matrix[i, lastCellRange.Column - 1]); for (int x = i + 1; x <= lastCellRange.Row; x++) { string cellVal = Convert.ToString(matrix[x, colSymbolInputs]); if (!string.IsNullOrEmpty(cellVal) && cellVal.Contains("<<BMK>>")) { string symbol = matrix[x, colSymbolInputs].ToString(); string dataType = matrix[x, colDataType].ToString(); string address = matrix[x, colAddress].ToString(); string comment = matrix[x, colComment].ToString(); RobotTecnologieProperties.Add(new RobotTecnologie(fbNr, name, type, symbol, dataType, address, comment)); } else { break; } i++; } } } #endregion Tecnologies.Add(RobotTecnologieProperties); return(Tecnologies); }