Ejemplo n.º 1
0
        private SRMData SetDataThreeColumn(Object[,] dataCells, bool cumulative)
        {
            int dsize = dataCells.GetUpperBound(0) - dataCells.GetLowerBound(0) + 1;

            double[] time  = new double[dsize];
            int[]    fault = new int[dsize];
            int[]    type  = new int[dsize];
            double   prev  = 0;

            for (int i = 0, j = dataCells.GetLowerBound(0); i < dsize; i++, j++)
            {
                double tmp = System.Convert.ToDouble(dataCells[j, 1]);
                if (cumulative)
                {
                    time[i] = tmp - prev;
                    prev    = tmp;
                }
                else
                {
                    time[i] = tmp;
                }
                fault[i] = System.Convert.ToInt32(dataCells[j, 2]);
                type[i]  = System.Convert.ToInt32(dataCells[j, 3]);
            }
            SRMData fdat = new SRMData();

            fdat.SetData(time, fault, type);
            return(fdat);
        }
Ejemplo n.º 2
0
 ///<summary>
 ///Creates a XArrayHelper and copies the values from an object array.
 ///</summary>
 ///<param name="array">The source array to be copied.</param>
 public void LoadRows(Object[,] array)
 {
     this.RedimXArray(new int[] { array.GetUpperBound(0), array.GetUpperBound(1) }, new int[] { array.GetLowerBound(0), array.GetLowerBound(1) });
     for (int row = array.GetLowerBound(0); row <= array.GetUpperBound(0); row++)
     {
         for (int col = array.GetLowerBound(1); col <= array.GetUpperBound(1); col++)
         {
             this.SetValue(array[row, col], row, col);
         }
     }
 }
Ejemplo n.º 3
0
        private void importSheet(PipelineContext ctx, IDatasourceSink sink, IStreamProvider elt, Worksheet sheet)
        {
            Range used      = sheet.UsedRange;
            Range usedCells = used.Cells;

            if (usedCells == null)
            {
                return;
            }

            Object[,] c = (Object[, ])used.Cells.Value2;
            if (c == null)
            {
                return;
            }

            int lo1 = c.GetLowerBound(0);
            int hi1 = c.GetUpperBound(0);
            int lo2 = c.GetLowerBound(1);
            int hi2 = c.GetUpperBound(1);

            List <String> headers = new List <string>();

            if (headersAt >= 0)
            {
                int headersRow = lo1 + headersAt;
                if (headersRow <= hi1)
                {
                    int h = 0;
                    for (int j = lo2; j <= hi2; j++)
                    {
                        for (; h < j; h++)
                        {
                            headers.Add(null);
                        }
                        headers.Add(_toString(c[headersRow, j]));
                        h++;
                    }
                }
            }

            var keys = prepareEventKeys(sheet.Name, hi2 + 1, headers);

            for (int i = lo1 + startAt; i <= hi1; i++)
            {
                for (int j = lo2; j <= hi2; j++)
                {
                    sink.HandleValue(ctx, keys[j], c[i, j]);
                }
                sink.HandleValue(ctx, keys[0], null);
                ctx.IncrementEmitted();
            }
        }
Ejemplo n.º 4
0
        GetRowCount
        (
            Object [,] aoColumnValues
        )
        {
            Debug.Assert(aoColumnValues != null);
            AssertValid();

            return(aoColumnValues.GetUpperBound(0) -
                   aoColumnValues.GetLowerBound(0) + 1);
        }
Ejemplo n.º 5
0
        public static T[] myArray <T>(Object[,] O)
        {
            if ((O.GetLowerBound(1) == O.GetUpperBound(1)) & (O.GetUpperBound(0) != O.GetUpperBound(1)))
            {
                List <T> l = new List <T>();
                for (int i = O.GetLowerBound(0); i <= O.GetUpperBound(0); i++)
                {
                    int firstCol = O.GetLowerBound(1);
                    l.Add((T)O[i, firstCol]);
                }
                return(l.ToArray <T>());
            }

            if ((O.GetLowerBound(0) == O.GetUpperBound(0)) & (O.GetUpperBound(0) != O.GetUpperBound(1)))
            {
                List <T> l = new List <T>();
                for (int i = O.GetLowerBound(1); i <= O.GetUpperBound(1); i++)
                {
                    int firstCol = O.GetLowerBound(0);
                    l.Add((T)O[firstCol, i]);
                }
                return(l.ToArray <T>());
            }
            return(null);
        }
Ejemplo n.º 6
0
        public int mWriteRecordSet(RecordSetMD inRecordSetMD
                                   , Object[,] r
                                   , Boolean bIncludesHeaderRow
                                   )
        {
            try {
                if (this.RecordSet.Buffer == null)
                {
                    throw new com.WDataSci.WDS.WDSException("Error, RecordSet buffer not set before WriteSet!");
                }

                DBB buf = this.RecordSet.Buffer;

                int rowstartindex = r.GetLowerBound(0);
                int nRows         = r.GetUpperBound(0) - rowstartindex + 1;
                if (bIncludesHeaderRow)
                {
                    nRows         -= 1;
                    rowstartindex += 1;
                }
                int nColumns = r.GetUpperBound(1) - r.GetLowerBound(1) + 1;

                if (nColumns != inRecordSetMD.nColumns())
                {
                    throw new com.WDataSci.WDS.WDSException("Error, Excel ListObject #columns does not match RecordSetMD #columns");
                }

                this.mWritePrepFor(inRecordSetMD, nRows);

                buf.position(0, 0, 0);


                //write leading data
                buf.PutLayerFLenString(0, "WDSD", 8, 0);
                buf.PutLayerLong(0, buf.nDBBRequiredBytes);
                buf.PutLayerLong(0, buf.nDBBLeadingBytes);
                buf.PutLayerLong(0, buf.nDBBFLenBytes);
                buf.PutLayerLong(0, buf.nDBBVLenBytes);
                buf.PutLayerLong(0, buf.nRecords);
                buf.PutLayerLong(0, buf.nRecordFLenBytes);
                buf.PutLayerLong(0, buf.nRecordVLenBytes);

                int bptr = 0;
                //bptr = (int) buf.nDBBLeadingBytes;



                int nInputColumns = inRecordSetMD.nColumns();



                for (int i = 0, ii = rowstartindex; i < nRows; i++, ii++)
                {
                    if (i > 0)
                    {
                        bptr += (int)this.RecordSet.Buffer.nRecordFLenBytes;
                    }
                    long lbptr = bptr;
                    buf.position(buf.ptr, (int)bptr, buf.vlenptr);

                    for (int j = 0, jj = r.GetLowerBound(1); j < nColumns; j++, jj++)
                    {
                        Object obj = r [ii, jj];
                        switch (inRecordSetMD.Column [j].DTyp)
                        {
                        case FieldMDEnums.eDTyp.Dbl:
                            buf.PutLayerDouble(1, obj);
                            break;

                        case FieldMDEnums.eDTyp.Lng:
                            buf.PutLayerLong(1, obj);
                            break;

                        case FieldMDEnums.eDTyp.Dte:
                            buf.PutLayerDouble(1, obj);
                            break;

                        case FieldMDEnums.eDTyp.DTm:
                            buf.PutLayerDouble(1, obj);
                            break;

                        case FieldMDEnums.eDTyp.Int:
                            buf.PutLayerInt(1, obj);
                            break;

                        case FieldMDEnums.eDTyp.Str:
                            buf.PutLayerFLenString(1, Convert.ToString(obj), (int)inRecordSetMD.Column [j].ByteMaxLength, 2);
                            break;

                        case FieldMDEnums.eDTyp.VLS:
                            buf.PutLayerVLenString(1, Convert.ToString(obj), (int)inRecordSetMD.Column [j].ByteMaxLength, 2);
                            break;

                        default:
                            throw new Exception("Hey");
                        }
                    }
                }

                return(0);
            }
            catch (Exception e) {
                throw new com.WDataSci.WDS.WDSException("Error in writing output map to DBB", e);
            }
        }