using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FObjBase;
namespace FLY.Simulation.Flyad7.OBJProxy
{
    class FLYIO:FObj
    {
        FLYAD7 Data;
        public FLYIO(int objsys_idx, FLYAD7 data):base(objsys_idx)
        {
            ID = FLYAD7_OBJ_INTERFACE.FLYIO_OBJ_INTERFACE.ID;
            Data = data;
        }
        public override void GetValue(IFConn from, uint srcid, ushort memid, out byte[] infodata)
        {
            infodata = null;
            switch (memid) 
            {
                case FLYAD7_OBJ_INTERFACE.FLYIO_OBJ_INTERFACE.GET_IO:
                    {
                        FLYAD7_OBJ_INTERFACE.FLYIO_OBJ_INTERFACE.Pack_GetIO pack = new FLYAD7_OBJ_INTERFACE.FLYIO_OBJ_INTERFACE.Pack_GetIO();
                        pack.istatus = Data.IStatus;
                        pack.ostatus = Data.OStatus;
                        infodata = pack.ToBytes();

                    }break;
            }
        }
        public override void  CallFunction(IFConn from, uint srcid, uint magic, ushort funcid, byte[] infodata)
        {
            switch (funcid)
            {
                case FLYAD7_OBJ_INTERFACE.FLYIO_OBJ_INTERFACE.CALL_OUTPORT:
                    {
                        FLYAD7_OBJ_INTERFACE.FLYIO_OBJ_INTERFACE.Pack_CallOutPort pack = new FLYAD7_OBJ_INTERFACE.FLYIO_OBJ_INTERFACE.Pack_CallOutPort();
                        if (!pack.TryParse(infodata))
                            break;
                        Data.SetOutput(pack.mask, pack.port);
                    } break;
            }
        }
    }
}
