Esempio n. 1
0
        public uint getObjectQuantity() //
        {
            uint Ocount;

            if ((this.Qualifier.Qcode >= 0) && (this.Qualifier.Qcode <= 5)) //Start - Stop
            {
                Ocount = (this.Stop - this.Start) + 1;
            }
            else if ((this.Qualifier.Qcode >= 7) && (this.Qualifier.Qcode <= 9)) // Quantity
            {
                Ocount = this.Count;
            }
            else
            {
                Ocount = 0;
            }
            // ------------------- check if Object is bit -----------------------------//
            int Osize = Object_Library.getSize(this.ObjectGroup, this.ObjectVariation);

            if (Osize == 0x81)         // bit quantity
            {
                if ((Ocount % 8) == 0) // convert bit to byte
                {
                    Ocount = Ocount / 8;
                }
                else
                {
                    Ocount = (Ocount / 8) + 1;
                }
            }
            //--------------------------------------------------------------------------//
            return(Ocount);
        }
Esempio n. 2
0
        public int getDataSize()
        {
            int size = 0;

            size += Object_Library.getSize(this.ObjectGroup, this.ObjectVariation);
            return(size);
        }
Esempio n. 3
0
 public ObjectData(byte og, byte ov, uint index, uint address, byte [] data, bool hasIndex)
 {
     this.ObjectGroup     = og;
     this.ObjectVariation = ov;
     this.Index           = index;
     this.address         = address;
     this.Data            = data;
     this.hasIndex        = hasIndex;
     this.ObjData         = Object_Library.getObjectType(this.ObjectGroup, this.ObjectVariation, data);
 }
Esempio n. 4
0
        public int getObjectSize()
        {
            int size = 0;

            size += Qualifier.getIndexSize();
            size += Object_Library.getSize(this.ObjectGroup, this.ObjectVariation);
            if (size == 0x81)
            {
                size = 1;
            }
            return(size);
        }
Esempio n. 5
0
        public Object_Header(byte Object, byte Var, Qualifier qualifier, byte [] Range)
        {
            this.ObjectGroup     = Object;
            this.ObjectVariation = Var;
            this.ObjectName      = Object_Library.getName(this.ObjectGroup, this.ObjectVariation);

            this.Qualifier    = qualifier;
            this.rawrangedata = Range;
            // construct Range by array of byte due to Q-code
            switch (this.Qualifier.Qcode)
            {
            case 0:     //Q-code 8 bit Start Stop bit
                this.Start = Range[0];
                this.Stop  = Range[1];
                isQuantity = false;
                break;

            case 1:     //Q-code 16 bit Start Stop bit
                this.Start = (uint)(Range[1] << 8) + Range[0];
                this.Stop  = (uint)(Range[3] << 8) + Range[2];
                isQuantity = false;
                break;

            case 2:     //Q-code 32 bit Start Stop bit
                this.Start = (uint)(Range[3] << 24) + (uint)(Range[2] << 16)
                             + (uint)(Range[1] << 8) + Range[0];
                this.Stop = (uint)(Range[7] << 24) + (uint)(Range[6] << 16)
                            + (uint)(Range[5] << 8) + Range[4];
                isQuantity = false;
                break;

            case 3:     //Q-code 8 bit Start Stop bit absolute
                this.Start = Range[0];
                this.Stop  = Range[1];
                isQuantity = false;
                break;

            case 4:     //Q-code 16 bit Start Stop bit absolute
                this.Start = (uint)(Range[1] << 8) + Range[0];
                this.Stop  = (uint)(Range[3] << 8) + Range[2];
                isQuantity = false;
                break;

            case 5:     //Q-code 32 bit Start Stop bit absolute
                this.Start = (uint)(Range[3] << 24) + (uint)(Range[2] << 16)
                             + (uint)(Range[1] << 8) + Range[0];
                this.Stop = (uint)(Range[7] << 24) + (uint)(Range[6] << 16)
                            + (uint)(Range[5] << 8) + Range[4];
                isQuantity = false;
                break;

            case 6:     // Q-code = 6 all poll all Object in the class
                this.Start = 0;
                this.Stop  = 0;
                this.Count = 0;     // message end here
                break;

            case 7:     // range = 8 bit Quantity indicator
                this.Count = Range[0];
                isQuantity = true;
                break;

            case 8:     // range = 16 bit Quantity indicator
                this.Count = (uint)(Range[1] << 8) + Range[0];
                isQuantity = true;
                break;

            case 9:     // range = 16 bit Quantity indicator
                this.Count = (uint)(Range[3] << 24) + (uint)(Range[2] << 16)
                             + (uint)(Range[1] << 8) + Range[0];
                isQuantity = true;
                break;

            case 11:     // do not supported yet
                break;
            }
        }