Exemplo n.º 1
0
        public int readFromArray(List <sbyte> newData)
        {       //returns time of operation of -1 in case of failure
            DateTime start, end;

            start = DateTime.Now;

            if (isEnoughDisks() == 0)
            {
                return(-1);
            }

            int   mem     = 0;      //memory slot
            int   hdd     = 0;      //hdd number in array
            int   counter = 0;      //helps to find checksum block
            sbyte b       = 0;
            bool  cont    = true;

            do
            {
                if (counter != 2)
                {
                    if (array.getDisk(hdd).getState())
                    {
                        b = array.getDisk(hdd).readByte(mem);
                    }
                    else
                    {
                        b = xor(hdd + 2, hdd + 1, mem, mem);
                    }
                    counter++;
                }
                else
                {
                    counter = 0;
                }
                if (b == -128)                          //if there is no data to read readByter(...) returns -128
                {
                    cont = false;
                }

                hdd++;
                if (hdd >= array.Count)
                {
                    mem++;
                    hdd = 0;
                }
            } while (cont);

            end = DateTime.Now;
            TimeSpan resultTime = end - start;

            return(resultTime.Seconds * 1000 + resultTime.Milliseconds + Convert.ToInt32(array.getReadLatency(0)));
        }
Exemplo n.º 2
0
        public int readFromArray(List <sbyte> newData)
        {
            DateTime start, end;

            start = DateTime.Now;

            if (isEnoughDisks() == 0)
            {
                return(-1);
            }
            int   mem  = 0;  //memory slot on disk
            int   hdd  = 0;  //disk number in array
            bool  cont = true;
            sbyte b;

            do
            {
                if (array.getDiskState(hdd))
                {
                    b = array.readFromDisk(hdd, mem);
                    if (b == -128)
                    {
                        cont = false;
                    }
                    else
                    {
                        newData.Add(b);
                        hdd++;
                    }
                    if (hdd >= array.Count)
                    {
                        hdd = 0;
                        mem++;
                    }
                }
                else
                {
                    return(-1);
                }
            }while(cont);

            end = DateTime.Now;
            TimeSpan resultTime = end - start;

            return(resultTime.Seconds * 1000 + resultTime.Milliseconds + Convert.ToInt32(array.getReadLatency(0)));
        }
Exemplo n.º 3
0
        public int readFromArray(List <sbyte> newData)
        {       //returns time of operation of -1 in case of failure
            DateTime start, end;

            start = DateTime.Now;

            if (isEnoughDisks() == 0)
            {
                return(-1);
            }
            int   mem  = 0;                               //memory slot number
            int   hdd  = 0;                               //hard disk number in array
            bool  cont = true;                            //false when nothing to read from disk
            sbyte b;

            while (cont)                                 //while there is data in array to read
            {
                if (array.getDisk(hdd).getState())
                {
                    b = array.getDisk(hdd).readByte(mem);
                    if (b == -128)                          //if there is no data to read readByter(...) returns -128
                    {
                        cont = false;
                    }
                    else
                    {
                        mem++;
                        if (mem > array.getDisk(hdd).getFreeSpace())
                        {
                            if (hdd % 2 == 1)
                            {
                                hdd++;
                            }
                            else
                            {
                                hdd += 2;
                            }
                        }
                    }
                }
                else
                {
                    if (hdd % 2 == 1)
                    {
                        return(-1);
                    }
                    hdd++;
                }
            }

            end = DateTime.Now;
            TimeSpan resultTime = end - start;

            return(Convert.ToInt32((resultTime.Seconds * 1000 + resultTime.Milliseconds + Convert.ToInt32(array.getReadLatency(0))) * 3.5));
        }