Beispiel #1
0
        public unsafe static byte Sysatt_GetXitongval(byte lei, byte id, runattinf *att)
        {
            int   val = 0;
            byte  mark;
            byte *ptr2;

            if (lei == 4)
            {
                fixed(byte *ptr = &Sysatt.xitong32[(int)id].res0)
                {
                    mark          = Sysatt.xitong32[(int)id].mark;
                    ptr2          = ptr;
                    att->datafrom = Sysatt.xitong32[(int)id].mark;
                }
            }
            else
            {
                fixed(byte *ptr = &Sysatt.xitong64[(int)id].res0)
                {
                    mark          = Sysatt.xitong64[(int)id].mark;
                    ptr2          = ptr;
                    att->datafrom = Sysatt.xitong64[(int)id].mark;
                }
            }
            att->attlei         = attshulei.SS32.typevalue;
            att->att.merrylenth = 4;
            att->att.maxval     = 2147483647;
            att->att.minval     = -2147483647;
            att->isxiugai       = 1;
            byte result;

            if (mark <= 4)
            {
                val = Sysatt.myapp.myxitong[(int)mark];
            }
            else if (mark >= 210 && mark <= 216)
            {
                if (Rtc.Rtc_GetTime((int)(mark - 210), &val) == 255)
                {
                    result = 0;
                    return(result);
                }
            }
            else if (mark < 220 || mark > 227)
            {
                if (mark < 240 || mark > 243)
                {
                    if (mark == 200)
                    {
                        val = (int)(*(ushort *)(ptr2 + 1));
                    }
                    else
                    {
                        byte b = mark;
                        switch (b)
                        {
                        case 5:
                            val = (int)Sysatt.myapp.USART.UsartBo;
                            break;

                        case 6:
                            val = 9600;
                            break;

                        case 7:
                            val = 100;
                            break;

                        case 8:
                            val = 100;
                            break;

                        case 9:
                            val = (int)Sysatt.myapp.sendfanhui;
                            break;

                        case 10:
                            val = (int)Sysatt.myapp.brush.hangjux;
                            break;

                        case 11:
                            val = (int)Sysatt.myapp.brush.hangjuy;
                            break;

                        case 12:
                            val = Sysatt.myapp.sys.ussp / 1000;
                            break;

                        case 13:
                            val = Sysatt.myapp.sys.thsp / 1000;
                            break;

                        case 14:
                            val = (int)Sysatt.myapp.sys.thsleepup;
                            break;

                        case 15:
                            val = (int)Sysatt.myapp.touchsendxy;
                            break;

                        case 16:
                            val = (int)Sysatt.myapp.dracolor;
                            break;

                        case 17:
                            val = (int)Sysatt.myapp.dra;
                            break;

                        case 18:
                            break;

                        case 19:
                            val = Sys.rand(Sysatt.myapp.SysRandMin, Sysatt.myapp.SysRandMax);
                            break;

                        case 20:
                            if (Sysatt.myapp.comcrc > 0)
                            {
                                val = 1;
                            }
                            else
                            {
                                val = 0;
                            }
                            break;

                        case 21:
                            val = (int)Sysatt.myapp.runmod;
                            break;

                        case 22:
                            val = (int)Sysatt.myapp.dpage;
                            break;

                        case 23:
                            val = (int)Sysatt.myapp.upapp.lcddev.wup;
                            break;

                        default:
                            if (b != 120)
                            {
                                if (b != 244)
                                {
                                    att->datafrom = 255;
                                    result        = 0;
                                    return(result);
                                }
                            }
                            else
                            {
                                val = 0;
                            }
                            break;
                        }
                    }
                }
            }
            att->val = val;
            result   = 1;
            return(result);
        }
Beispiel #2
0
        public unsafe static byte Rtc_GetTime(int index, int *val)
        {
            DateTime now = DateTime.Now;

            switch (index)
            {
            case 0:
                if (!Rtc.DatetimeSpan_val)
                {
                    *val = now.Year;
                }
                else
                {
                    *val = now.Subtract(Rtc.DatetimeSpan).Year;
                }
                break;

            case 1:
                if (!Rtc.DatetimeSpan_val)
                {
                    *val = now.Month;
                }
                else
                {
                    *val = now.Subtract(Rtc.DatetimeSpan).Month;
                }
                break;

            case 2:
                if (!Rtc.DatetimeSpan_val)
                {
                    *val = now.Day;
                }
                else
                {
                    *val = now.Subtract(Rtc.DatetimeSpan).Day;
                }
                break;

            case 3:
                if (!Rtc.DatetimeSpan_val)
                {
                    *val = now.Hour;
                }
                else
                {
                    *val = now.Subtract(Rtc.DatetimeSpan).Hour;
                }
                break;

            case 4:
                if (!Rtc.DatetimeSpan_val)
                {
                    *val = now.Minute;
                }
                else
                {
                    *val = now.Subtract(Rtc.DatetimeSpan).Minute;
                }
                break;

            case 5:
                if (!Rtc.DatetimeSpan_val)
                {
                    *val = now.Second;
                }
                else
                {
                    *val = now.Subtract(Rtc.DatetimeSpan).Second;
                }
                break;

            case 6:
            {
                ushort y   = (ushort)now.Subtract(Rtc.DatetimeSpan).Year;
                ushort m   = (ushort)now.Subtract(Rtc.DatetimeSpan).Month;
                ushort d   = (ushort)now.Subtract(Rtc.DatetimeSpan).Day;
                *      val = (int)Rtc.Rtc_ProcessWeek(y, m, d);
                break;
            }
            }
            return(1);
        }
Beispiel #3
0
        public static byte Sysatt_SetXitongval(byte index, int val)
        {
            byte result;

            if (index <= 4)
            {
                Sysatt.myapp.myxitong[(int)index] = val;
            }
            else
            {
                if (index >= 210 && index <= 216)
                {
                    result = Rtc.Rtc_SetTime((int)(index - 210), val);
                    return(result);
                }
                if (index >= 220 && index <= 227)
                {
                    result = 1;
                    return(result);
                }
                if (index >= 240 && index <= 243)
                {
                    result = 1;
                    return(result);
                }
                if (index == 200)
                {
                    result = 0;
                    return(result);
                }
                switch (index)
                {
                case 5:
                    result = 1;
                    return(result);

                case 6:
                    result = 1;
                    return(result);

                case 7:
                    if (val > 100)
                    {
                        result = 0;
                        return(result);
                    }
                    result = 1;
                    return(result);

                case 8:
                    if (val > 100)
                    {
                        result = 0;
                        return(result);
                    }
                    result = 1;
                    return(result);

                case 9:
                    if (val > 3)
                    {
                        result = 0;
                        return(result);
                    }
                    Sysatt.myapp.sendfanhui = (byte)val;
                    break;

                case 10:
                    Sysatt.myapp.brush.hangjux = (byte)val;
                    break;

                case 11:
                    Sysatt.myapp.brush.hangjuy = (byte)val;
                    break;

                case 12:
                    Sysatt.myapp.sys.ussp = val * 1000;
                    if (Sysatt.myapp.sys.ussp > 0 && Sysatt.myapp.sys.ussp < 3000)
                    {
                        Sysatt.myapp.sys.ussp = 3000;
                    }
                    Sysatt.myapp.systime.sptime = Sysatt.myapp.systime.systemruntime;
                    break;

                case 13:
                    Sysatt.myapp.sys.thsp = val * 1000;
                    if (Sysatt.myapp.sys.thsp > 0 && Sysatt.myapp.sys.thsp < 3000)
                    {
                        Sysatt.myapp.sys.thsp = 3000;
                    }
                    Sysatt.myapp.systime.sptime = Sysatt.myapp.systime.systemruntime;
                    break;

                case 14:
                    Sysatt.myapp.sys.thsleepup = (byte)val;
                    break;

                case 15:
                    Sysatt.myapp.touchsendxy = (byte)val;
                    break;

                case 16:
                    Sysatt.myapp.dracolor = (ushort)((byte)val);
                    break;

                case 17:
                    if (val > 1)
                    {
                        result = 0;
                        return(result);
                    }
                    Sysatt.myapp.dra = (byte)val;
                    break;

                case 18:
                    result = 1;
                    return(result);

                case 19:
                    result = 0;
                    return(result);

                case 20:
                    if (val > 0)
                    {
                        Sysatt.myapp.comcrc = 1;
                    }
                    else
                    {
                        Sysatt.myapp.comcrc = 0;
                    }
                    result = 1;
                    return(result);

                case 21:
                    if (val >= 0 && val < 3)
                    {
                        Sysatt.myapp.runmod = (byte)val;
                    }
                    result = 1;
                    return(result);

                case 22:
                    if (val >= (int)Sysatt.myapp.app.pageqyt)
                    {
                        result = 0;
                        return(result);
                    }
                    Hmi.Hmi_RefPage((ushort)val);
                    result = 1;
                    return(result);

                case 23:
                    if ((val >= 0 && val < (int)Sysatt.myapp.app.pageqyt) || val == 255)
                    {
                        Sysatt.myapp.upapp.lcddev.wup = (byte)val;
                        result = 1;
                        return(result);
                    }
                    Sysatt.myapp.errcode = 3;
                    result = 0;
                    return(result);

                default:
                    if (index == 120)
                    {
                        if (Sysatt.myapp.delay != 0 || Hmi.Hmi_GuiObjectRef() == 0)
                        {
                            Sys.delay_ms((ushort)val);
                        }
                        else
                        {
                            Sysatt.myapp.delay = (ushort)val;
                        }
                        if (Sysatt.myapp.upapp.Lcdshouxian > 0)
                        {
                            Sysatt.myapp.upapp.ScreenRef(0);
                        }
                        result = 1;
                        return(result);
                    }
                    if (index != 244)
                    {
                        result = 0;
                        return(result);
                    }
                    result = 1;
                    return(result);
                }
            }
            result = 1;
            return(result);
        }