Exemplo n.º 1
0
        public ErrorCode setAdapter(int id)
        {
            int errmsg = CppConnect.setNicId(id);

            if (errmsg < 0)
            {
                return(ErrorCode.ADAPTER_SELECT_FAIL);
            }
            else if (errmsg == 0)
            {
                return(ErrorCode.NO_SLAVE_CONNECTED);
            }
            else
            {
                deviceNum = errmsg;
                return(ErrorCode.NO_ERROR);
            }
        }
Exemplo n.º 2
0
        public IOdevice[] getDevice()
        {
            int slaveNum = CppConnect.getSlaveNum();

            deviceNum = slaveNum;
            for (int i = 0; i < slaveNum; i++)
            {
                IOdevice tmpSlave = new IOdevice();
                int      err      = CppConnect.getSlaveInfo(ref tmpSlave, i);
                if (err == SAFECODE)
                {
                    devices[i] = tmpSlave;
                }
                else//有错误
                {
                    throw new Exception();
                }
            }
            return(devices);
        }
Exemplo n.º 3
0
        public Adapter[] getAdapter()
        {
            adapterNum = CppConnect.getAdapterNum();
            adapters   = new Adapter[adapterNum];

            StringBuilder tmpAdapterName = new StringBuilder();

            tmpAdapterName.Capacity = 128;
            for (int i = 0; i < adapterNum; i++)
            {
                int err = CppConnect.getContextInfo(tmpAdapterName);
                if (err != 0)//有错误
                {
                }
                adapters[i]      = new Adapter();
                adapters[i].name = tmpAdapterName.ToString();
                tmpAdapterName.Clear();
            }
            return(adapters);
        }
Exemplo n.º 4
0
 public int WriteDigital(int deviceId, int channel, bool value)
 {
     return(CppConnect.setDigitalValue(deviceId, channel, value));
 }
Exemplo n.º 5
0
 public int WriteAnalog(int deviceId, int channel, int value)
 {
     return(CppConnect.setIntergerValue(deviceId, channel, value));
 }