Exemplo n.º 1
0
            public static stPLC_OBJ operator !(stPLC_OBJ b)
            {
                var _stPLC_OBJ = new stPLC_OBJ();

                var stT = (b.iClassType == 5) ? (stTimer)b : null;

                var stC = (b.iClassType == 6) ? (stCounter)b : null;

                switch (b.iClassType)
                {
                case IS_INPUT:
                case IS_OUTPUT:
                case IS_AUX:
                case IS_STATUS:
                    if (b.status)
                    {
                        _stPLC_OBJ.status = false;
                    }
                    else
                    {
                        _stPLC_OBJ.status = true;
                    }
                    break;

                case IS_TIMER:
                    if (b.status && stT.timeup)
                    {
                        _stPLC_OBJ.status = false;
                    }

                    else
                    {
                        _stPLC_OBJ.status = true;
                    }

                    break;

                case IS_COUNTER:
                    if (b.status && stC.fire)
                    {
                        _stPLC_OBJ.status = false;
                    }
                    else
                    {
                        _stPLC_OBJ.status = true;
                    }

                    break;
                }
                return(_stPLC_OBJ);
            }
Exemplo n.º 2
0
 public int TestIsKindOf(stPLC_OBJ a)
 {
     return(a.iClassType);
 }
Exemplo n.º 3
0
            public static stPLC_OBJ operator *(stPLC_OBJ a, stPLC_OBJ b)
            {
                var _stPLC_OBJ = new stPLC_OBJ();
                var stT        = (b.iClassType == 5) ? (stTimer)b : null;
                var stC        = (b.iClassType == 6) ? (stCounter)b : null;

                if ((a.iClassType != IS_TIMER) && (a.iClassType != IS_COUNTER))
                {
                    switch (a.iClassType)
                    {
                    case IS_INPUT:
                    case IS_OUTPUT:
                    case IS_AUX:
                    case IS_STATUS:
                        if (a.status && b.status)
                        {
                            _stPLC_OBJ.status = true;
                        }
                        else
                        {
                            _stPLC_OBJ.status = false;
                        }
                        break;

                    case IS_TIMER:
                        if (a.status && (b.status && stT.timeup))
                        {
                            _stPLC_OBJ.status = true;
                        }
                        else
                        {
                            _stPLC_OBJ.status = false;
                        }
                        break;

                    case IS_COUNTER:
                        if (a.status && (b.status && stC.fire))
                        {
                            _stPLC_OBJ.status = true;
                        }
                        else
                        {
                            _stPLC_OBJ.status = false;
                        }
                        break;
                    }
                }
                else
                {
                    if (a.iClassType == IS_TIMER)
                    {
                        var d = (stTimer)a;
                        if (a.iClassType == IS_TIMER)
                        {
                            if ((d.status && d.timeup) && (b.status && stT.timeup))
                            {
                                _stPLC_OBJ.status = true;
                            }
                            else
                            {
                                _stPLC_OBJ.status = false;
                            }
                        }
                        else
                        {
                            if ((d.status && d.timeup) && (b.status && stC.fire))
                            {
                                _stPLC_OBJ.status = true;
                            }
                            else
                            {
                                _stPLC_OBJ.status = false;
                            }
                        }
                    }
                    if (a.iClassType == IS_COUNTER)
                    {
                        var d = (stCounter)a;
                        if (a.iClassType == IS_TIMER)
                        {
                            if ((d.status && d.fire) && (b.status && stT.timeup))
                            {
                                _stPLC_OBJ.status = true;
                            }
                            else
                            {
                                _stPLC_OBJ.status = false;
                            }
                        }
                        else
                        {
                            if ((d.status && d.fire) && (b.status && stC.fire))
                            {
                                _stPLC_OBJ.status = true;
                            }
                            else
                            {
                                _stPLC_OBJ.status = false;
                            }
                        }
                    }
                }
                return(_stPLC_OBJ);
            }