Exemple #1
0
 private static unsafe byte AttConvert_gui(runattinf *b1, runattinf *b2, byte lenth1, byte lenth2)
 {
     if ((b1->attlei != attshulei.Sstr.typevalue) && (b2->attlei == attshulei.Sstr.typevalue))
     {
         if (b2->datafrom != 0xfe)
         {
             myapp.errcode = 0x1b;
             return(0);
         }
         if (lenth1 == 0)
         {
             lenth1 = Strmake.Strmake_GetS32strlen(b1->val);
         }
         if (b2->att.merrylenth <= lenth1)
         {
             lenth1 = (byte)(b2->att.merrylenth - 1);
         }
         Strmake.Strmake_S32ToStr(b1->val, b2->Pz, lenth1, 1);
     }
     else
     {
         if ((b1->attlei == attshulei.Sstr.typevalue) && (b2->attlei != attshulei.Sstr.typevalue))
         {
             b2->val = Strmake.Strmake_StrToS32(b1->Pz, lenth1);
             return(Attmake_SetAtt(b2, b2, 0));
         }
         myapp.errcode = 0x1b;
         return(0);
     }
     return(1);
 }
Exemple #2
0
 private static unsafe byte Commake_Comyouxian(PosLaction *pos)
 {
     if (Strmake.Strmake_Makestr(Comstrbuf + pos->star, "runmod=", 7) == 1)
     {
         byte val = (byte)(Comstrbuf[pos->star + 7] - 0x30);
         switch (val)
         {
         case 0:
         case 1:
         case 2:
             Sysatt.Sysatt_SetXitongval(0x15, val);
             Commake_SendBacksuc();
             return(1);
         }
         return(0);
     }
     if (Strmake.Strmake_Makestr(Comstrbuf + pos->star, "com_st", 6) == 1)
     {
         if (Strmake.Strmake_Makestr(Comstrbuf + pos->star, "com_star", 8) == 1)
         {
             NorComSta.runmod = 1;
             return(1);
         }
         if (Strmake.Strmake_Makestr(Comstrbuf + pos->star, "com_stop", 8) == 1)
         {
             NorComSta.runmod = 0;
             return(1);
         }
     }
     return(0);
 }
Exemple #3
0
        private byte DoeventsComStr(string str, int chaotim)
        {
            byte[]     array      = new byte[1000];
            PosLaction posLaction = default(PosLaction);
            int        num        = 0;
            byte       result;

            while (chaotim > 0)
            {
                while (this.com1.BytesToRead > 0)
                {
                    array[num] = (byte)this.com1.ReadByte();
                    num++;
                    if (num > 999)
                    {
                        break;
                    }
                }
                if (num > 0)
                {
                    posLaction.star = 0;
                    posLaction.end  = (ushort)(num - 1);
                }
                if (Strmake.Strmake_StrSubstring(ref array, ref posLaction, str, 1) != 65535)
                {
                    result = 1;
                    return(result);
                }
                chaotim -= 10;
                this.Doyanshi(10);
            }
            result = 0;
            return(result);
        }
Exemple #4
0
 public static unsafe void Commake_PrintIntToStr(int val, byte isend)
 {
     byte[] buffer = new byte[13];
     fixed(byte *numRef = buffer)
     {
         Strmake.Strmake_S32ToStr(val, numRef, 0, 1);
         Commake_Prints(numRef, isend);
     }
 }
Exemple #5
0
    // Methods
    private static unsafe byte AttAdd_gui(byte *buf, runattinf *b1, runattinf *b2, runattinf *b3, byte yunsuan)
    {
        ushort index = 0;

        if ((((b1->attlei == attshulei.Sstr.typevalue) && (b2->attlei == attshulei.Sstr.typevalue)) && (b3->attlei == attshulei.Sstr.typevalue)) && (yunsuan == 0x2b))
        {
            if ((b1->datafrom == 0xfe) && (b1->Pz == b3->Pz))
            {
                if (Attmake_SetAtt(b2, b3, yunsuan) > 0)
                {
                    return(1);
                }
            }
            else if ((b2->datafrom == 0xfe) && (b2->Pz == b3->Pz))
            {
                if (Attmake_SetAtt(b1, b3, yunsuan) > 0)
                {
                    return(1);
                }
            }
            else
            {
                if (Attmake_SetAtt(b1, b3, 0) == 0)
                {
                    return(0);
                }
                if (Attmake_SetAtt(b2, b3, yunsuan) > 0)
                {
                    return(1);
                }
            }
        }
        else
        {
            if (((b2->attlei != attshulei.Sstr.typevalue) && (b3->attlei == attshulei.Sstr.typevalue)) && ((yunsuan == 0x2d) || ((yunsuan == 0x2b) && (b2->val < 0))))
            {
                index = Strmake.Strmake_GetStrlen_Encode(b3->Pz, b3->att.encodeh_star);
                if (b2->val >= index)
                {
                    b3->Pz[0] = 0;
                    return(1);
                }
                index         = Strmake.Strmake_GetStrlen_Encode_Lenth(b3->Pz, b3->att.encodeh_star, (byte)(index - b2->val));
                b3->Pz[index] = 0;
                return(1);
            }
            if (((b1->attlei != attshulei.Sstr.typevalue) && (b2->attlei != attshulei.Sstr.typevalue)) && (b3->attlei != attshulei.Sstr.typevalue))
            {
                if (yunsuan == 0x2b)
                {
                    b3->val = b1->val + b2->val;
                    return(Attmake_SetAtt(b3, b3, 0));
                }
                if (yunsuan == 0x2d)
                {
                    b3->val = b1->val - b2->val;
                    return(Attmake_SetAtt(b3, b3, 0));
                }
                if (yunsuan == 0x2a)
                {
                    b3->val = b1->val * b2->val;
                    return(Attmake_SetAtt(b3, b3, 0));
                }
                if (yunsuan == 0x2f)
                {
                    b3->val = (b2->val == 0) ? 0 : (b1->val / b2->val);
                    return(Attmake_SetAtt(b3, b3, 0));
                }
                if (yunsuan == 0x25)
                {
                    b3->val = b1->val % b2->val;
                    return(Attmake_SetAtt(b3, b3, 0));
                }
                if (yunsuan == 0x7c)
                {
                    b3->val = b1->val | b2->val;
                    return(Attmake_SetAtt(b3, b3, 0));
                }
                if (yunsuan == 0x26)
                {
                    b3->val = b1->val & b2->val;
                    return(Attmake_SetAtt(b3, b3, 0));
                }
                if (yunsuan == 60)
                {
                    b3->val = b1->val << b2->val;
                    return(Attmake_SetAtt(b3, b3, 0));
                }
                if (yunsuan == 0x3e)
                {
                    b3->val = b1->val >> b2->val;
                    return(Attmake_SetAtt(b3, b3, 0));
                }
            }
        }
        myapp.errcode = 0x1b;
        return(0);
    }
Exemple #6
0
    private static unsafe byte SetAtt_gui(runattinf *b1, runattinf *b2, byte yunsuan)
    {
        if (b2->isxiugai == 1)
        {
            if (((b2->attlei != attshulei.Sstr.typevalue) && (b1->attlei != attshulei.Sstr.typevalue)) && (yunsuan == 0))
            {
                if (b2->datafrom == 0xfd)
                {
                    b2->val = b2->val;
                    return(1);
                }
                if ((b1->val > b2->att.maxval) || (b1->val < b2->att.minval))
                {
                    myapp.errcode = 0x1c;
                    return(0);
                }
                if (b2->datafrom == 0xfe)
                {
                    if (b2->att.merrylenth == 2)
                    {
                        if (b1->attlei == attshulei.UU16.typevalue)
                        {
                            ushort val = (ushort)b1->val;
                            Kuozhan.memcpy(b2->Pz, (byte *)&val, b2->att.merrylenth);
                        }
                        else
                        {
                            short num4 = (short)b1->val;
                            Kuozhan.memcpy(b2->Pz, (byte *)&num4, b2->att.merrylenth);
                        }
                    }
                    else
                    {
                        Kuozhan.memcpy(b2->Pz, (byte *)&b1->val, b2->att.merrylenth);
                    }
                    return(1);
                }
                switch (Sysatt.Sysatt_SetXitongval(b2->datafrom, b1->val))
                {
                case 1:
                    return(1);

                case 2:
                    myapp.errcode = 0xff;
                    return(0);
                }
            }
            else if (((b2->attlei == attshulei.Sstr.typevalue) && (b1->attlei == attshulei.Sstr.typevalue)) && (b2->datafrom == 0xfe))
            {
                ushort num3;
                ushort num  = Strmake.Strmake_GetStrlen(b1->Pz);
                ushort num2 = Strmake.Strmake_GetStrlen(b2->Pz);
                byte * pz   = b2->Pz;
                if (yunsuan == 0x2b)
                {
                    pz  += num2;
                    num3 = (ushort)((b2->att.merrylenth - num2) - 1);
                }
                else
                {
                    num3 = (ushort)(b2->att.merrylenth - 1);
                }
                if (num3 > num)
                {
                    num3 = num;
                }
                Kuozhan.memcpy(pz, b1->Pz, num3);
                pz[num3] = 0;
                return(1);
            }
        }
        myapp.errcode = 0x1c;
        return(0);
    }
Exemple #7
0
 public static unsafe byte Attmake_Makeatt(byte *buf, runattinf *b1, runattinf *b2, byte yunsuan)
 {
     if ((b2->attlei != attshulei.Sstr.typevalue) && (b2->attlei != attshulei.Sstr.typevalue))
     {
         if (yunsuan == 1)
         {
             if (b1->val == b2->val)
             {
                 return(1);
             }
             return(0);
         }
         if (yunsuan == 2)
         {
             if (b1->val < b2->val)
             {
                 return(1);
             }
             return(0);
         }
         if (yunsuan == 3)
         {
             if (b1->val > b2->val)
             {
                 return(1);
             }
             return(0);
         }
         if (yunsuan == 4)
         {
             if (b1->val <= b2->val)
             {
                 return(1);
             }
             return(0);
         }
         if (yunsuan == 5)
         {
             if (b1->val >= b2->val)
             {
                 return(1);
             }
             return(0);
         }
         if (yunsuan == 6)
         {
             if (b1->val != b2->val)
             {
                 return(1);
             }
             return(0);
         }
     }
     else if (((b2->attlei == attshulei.Sstr.typevalue) && (b1->attlei == attshulei.Sstr.typevalue)) && ((yunsuan == 1) || (yunsuan == 6)))
     {
         if (Strmake.Strmake_Makestr(b1->Pz, b2->Pz, 0) == 1)
         {
             if (yunsuan == 1)
             {
                 return(1);
             }
             return(0);
         }
         if (yunsuan == 1)
         {
             return(0);
         }
         return(1);
     }
     return(0);
 }
Exemple #8
0
    public static unsafe ushort Attmake_GetstrAtt(byte *buf, PosLaction *bufpos, runattinf *att)
    {
        ushort     star    = bufpos->star;
        ushort     num3    = 0;
        ushort     index   = 0;
        PosLaction laction = new PosLaction();

        att->datafrom = 0xff;
        att->isref    = 0;
        if (bufpos->end < bufpos->star)
        {
            myapp.errcode = 0x1a;
            return(0xffff);
        }
        if (buf[star] != 0x22)
        {
            if ((((buf[star] >= 9) || (buf[star] <= 1)) && (buf[star] != 0x2d)) && ((buf[star] <= 0x2f) || (buf[star] >= 0x3a)))
            {
                laction.star = bufpos->star;
                if (Strmake.Strmake_IsAttendbyte(buf[star]) == 1)
                {
                    myapp.errcode = 0x1a;
                    return(0xffff);
                }
                int num = 0;
                while (star <= bufpos->end)
                {
                    num3 = 0;
                    while (star <= bufpos->end)
                    {
                        if (buf[star] < 9)
                        {
                            num3 = (ushort)(num3 + 5);
                            star = (ushort)(star + 5);
                        }
                        if ((num == 0) && (Strmake.Strmake_IsAttendbyte(buf[star]) == 1))
                        {
                            star = (ushort)(star - 1);
                            break;
                        }
                        if (buf[star] == 0x5b)
                        {
                            num++;
                        }
                        else if (buf[star] == 0x5d)
                        {
                            num--;
                        }
                        if (num3 == 0x31)
                        {
                            myapp.errcode = 0x23;
                            return(0xffff);
                        }
                        num3 = (ushort)(num3 + 1);
                        star = (ushort)(star + 1);
                    }
                    if (star > bufpos->end)
                    {
                        star = bufpos->end;
                    }
                    laction.end = star;
                    Attmake_GetAtt(buf, &laction, att);
                    if (att->datafrom == 0xff)
                    {
                        myapp.errcode = 0x1a;
                        return(0xffff);
                    }
                    return(star);
                }
                myapp.errcode = 0x1a;
                return(0xffff);
            }
            if (buf[star] < 9)
            {
                if (buf[star] == 3)
                {
                    Kuozhan.memcpy((byte *)&att->val, buf + (star + 1), 4);
                    att->datafrom       = 0xfd;
                    att->att.merrylenth = 4;
                    att->attlei         = attshulei.SS32.typevalue;
                    att->isxiugai       = 0;
                }
                else if (buf[bufpos->star] == 2)
                {
                    att->datafrom = 0xfc;
                    Kuozhan.memcpy((byte *)&att->att.pos, buf + (bufpos->star + 1), 4);
                    att->att.state = attshulei.Sstr.typevalue;
                    att->isxiugai  = 0;
                }
                else if (buf[bufpos->star] == 4)
                {
                    Sysatt.Sysatt_GetXitongval(buf[bufpos->star + 1], buf[bufpos->star + 2], att);
                }
                return((ushort)(star + 4));
            }
            if (buf[star] == 0x2d)
            {
                star = (ushort)(star + 1);
            }
            while (star <= bufpos->end)
            {
                if ((buf[star] < 0x30) || (buf[star] > 0x39))
                {
                    star = (ushort)(star - 1);
                    break;
                }
                if (star == bufpos->end)
                {
                    break;
                }
                star = (ushort)(star + 1);
            }
        }
        else
        {
            buf[star] = 0;
            star      = (ushort)(star + 1);
            num3      = 0xffff;
            index     = star;
            while (star <= bufpos->end)
            {
                if (buf[star] == 0x5c)
                {
                    if (star == bufpos->end)
                    {
                        myapp.errcode = 0x20;
                        return(0xffff);
                    }
                    star = (ushort)(star + 1);
                    if ((buf[star] == 0x5c) || (buf[star] == 0x22))
                    {
                        buf[index] = buf[star];
                    }
                    else if (buf[star] == 0x72)
                    {
                        buf[index] = 13;
                        index      = (ushort)(index + 1);
                        buf[index] = 10;
                    }
                    else
                    {
                        myapp.errcode = 0x20;
                        return(0xffff);
                    }
                    if (star == bufpos->end)
                    {
                        myapp.errcode = 0x20;
                        return(0xffff);
                    }
                    star  = (ushort)(star + 1);
                    index = (ushort)(index + 1);
                }
                else
                {
                    buf[index] = buf[star];
                    if (buf[star] == 0x22)
                    {
                        buf[index] = 0;
                        num3       = star;
                        break;
                    }
                    star  = (ushort)(star + 1);
                    index = (ushort)(index + 1);
                }
            }
            if (num3 != 0xffff)
            {
                att->att.pos          = (ushort)(bufpos->star + 1);
                att->attlei           = attshulei.Sstr.typevalue;
                att->att.merrylenth   = (ushort)(index - bufpos->star);
                att->datafrom         = 0xfd;
                att->isxiugai         = 0;
                att->Pz               = buf + att->att.pos;
                att->att.encodeh_star = myapp.encodeh_star;
                return(num3);
            }
            myapp.errcode = 0x1a;
            return(0xffff);
        }
        att->val            = Strmake.Strmake_StrToS32(buf + bufpos->star, (byte)((star - bufpos->star) + 1));
        att->datafrom       = 0xfd;
        att->att.merrylenth = 4;
        att->attlei         = attshulei.SS32.typevalue;
        att->isxiugai       = 0;
        return(star);
    }
Exemple #9
0
        public int Getcomstr()
        {
            int num = 0;

            byte[]     array      = new byte[500];
            PosLaction posLaction = default(PosLaction);

            PosLaction[] array2 = new PosLaction[30];
            int          result;

            try
            {
                while (this.com1.BytesToRead > 0)
                {
                    array[num] = (byte)this.com1.ReadByte();
                    num++;
                    if (num > 499)
                    {
                        break;
                    }
                }
                num -= 4;
                if (num < 1)
                {
                    result = 0;
                    return(result);
                }
                posLaction.star = 0;
                posLaction.end  = (ushort)num;
                int num2 = (int)Strmake.Strmake_StrSubstring(ref array, ref posLaction, "comok ", 1);
                this.FlashSize = 0;
                if (num2 != 65535)
                {
                    posLaction.star = (ushort)(num2 + 1);
                    if (Strmake.Strmake_StrGetcanshu(ref array, ref posLaction, ref array2, 7) == 1)
                    {
                        this.touch         = array2[0].PosByteGetstring(array).Getint();
                        this.Lcdid         = array2[1].PosByteGetstring(array).Getint();
                        this.xinghao       = array2[2].PosByteGetstring(array);
                        this.gujianver     = (ushort)((byte)array2[3].PosByteGetstring(array).Getint());
                        this.cpuchip       = (ushort)array2[4].PosByteGetstring(array).Getint();
                        this.FlashIDstring = array2[5].PosByteGetstring(array);
                        this.FlashSize     = array2[6].PosByteGetstring(array).Getint();
                        string     text = this.xinghao.Trim();
                        modelxinxi modelxinxi;
                        if (text.Length > 1)
                        {
                            string a = text.Substring(text.Length - 1, 1);
                            if (a == "R" || a == "N" || a == "C")
                            {
                                text = text.Substring(0, text.Length - 1);
                            }
                            else
                            {
                                this.xilie = 0;
                                modelxinxi = datasize.Getmodelxinxi("123", this.xilie);
                                if (this.islaodmessage)
                                {
                                    MessageOpen.Show("非法型号".Language() + this.xinghao);
                                    result = 3;
                                    return(result);
                                }
                                result = 1;
                                return(result);
                            }
                        }
                        this.xilie = 0;
                        modelxinxi = datasize.Getmodelxinxi(text, this.xilie);
                        if (modelxinxi.Modelstring == "")
                        {
                            this.xilie = 1;
                            modelxinxi = datasize.Getmodelxinxi(text, this.xilie);
                        }
                        if (!(modelxinxi.Modelstring == ""))
                        {
                            result = 1;
                            return(result);
                        }
                        if (this.islaodmessage)
                        {
                            MessageOpen.Show("非法型号".Language() + this.xinghao);
                            result = 3;
                            return(result);
                        }
                        result = 1;
                        return(result);
                    }
                    else if (Strmake.Strmake_StrGetcanshu(ref array, ref posLaction, ref array2, 6) == 1)
                    {
                        this.touch         = array2[0].PosByteGetstring(array).Getint();
                        this.Lcdid         = array2[1].PosByteGetstring(array).Getint();
                        this.xinghao       = array2[2].PosByteGetstring(array);
                        this.gujianver     = (ushort)((byte)array2[4].PosByteGetstring(array).Getint());
                        this.gujianver    *= 256;
                        this.gujianver    += (ushort)((byte)array2[3].PosByteGetstring(array).Getint());
                        this.FlashIDstring = array2[5].PosByteGetstring(array);
                        string     text = this.xinghao.Trim();
                        modelxinxi modelxinxi;
                        if (text.Length > 1)
                        {
                            string a = text.Substring(text.Length - 1, 1);
                            if (a == "R" || a == "N" || a == "C")
                            {
                                text = text.Substring(0, text.Length - 1);
                            }
                            else
                            {
                                this.xilie = 0;
                                modelxinxi = datasize.Getmodelxinxi("123", this.xilie);
                                if (this.islaodmessage)
                                {
                                    MessageOpen.Show("非法型号".Language() + this.xinghao);
                                    result = 3;
                                    return(result);
                                }
                                result = 1;
                                return(result);
                            }
                        }
                        this.xilie = 0;
                        modelxinxi = datasize.Getmodelxinxi(text, this.xilie);
                        if (modelxinxi.Modelstring == "")
                        {
                            this.xilie = 1;
                            modelxinxi = datasize.Getmodelxinxi(text, this.xilie);
                        }
                        if (!(modelxinxi.Modelstring == ""))
                        {
                            result = 1;
                            return(result);
                        }
                        if (this.islaodmessage)
                        {
                            MessageOpen.Show("非法型号".Language() + this.xinghao);
                            result = 3;
                            return(result);
                        }
                        result = 1;
                        return(result);
                    }
                }
                else
                {
                    num2 = (int)Strmake.Strmake_StrSubstring(ref array, ref posLaction, "downbin", 1);
                    if (num2 != 65535)
                    {
                        result = 2;
                        return(result);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageOpen.Show(ex.Message);
                result = 0;
                return(result);
            }
            result = 0;
            return(result);
        }