Esempio n. 1
0
 public IActionResult Disarm()
 {
     /*This function calls the action Disarm on the device.
      * The function does not get a feedback*/
     DeviceMgr.CallDeviceAction(Configs.DEVICE_NAME, eDeviceAction.Disarm, serviceClient).Wait();
     return(Ok("Disarm Command was sent to Device Device!")); // TODO - change to logger
 }
Esempio n. 2
0
    public DeviceMgr GetDeviceMgr(DeviceType deviceType)
    {
        DeviceMgr mgr = null;

        m_deviceMgrDict.TryGetValue(deviceType, out mgr);
        return(mgr);
    }
Esempio n. 3
0
 public IActionResult AlarmOn()
 {
     /*This function calls the action ALARM on the device.
      * The function does not get a feedback*/
     this.alarm.status = eDeviceAction.Alarm;
     DeviceMgr.CallDeviceAction(Configs.DEVICE_NAME, eDeviceAction.Alarm, serviceClient).Wait();
     return(Ok("ALARM!! Command was sent to Device Device! BUZZZZZZ")); // TODO - change to logger
 }
Esempio n. 4
0
 public IActionResult Arm()
 {
     /*This function calls the action Arm on the device.
      * The function does not get a feedback*/
     DeviceMgr.CallDeviceAction(Configs.DEVICE_NAME, eDeviceAction.Arm, serviceClient).Wait();
     //Console.WriteLine("THIS IS A TEST!");
     return(Ok("Arm Command was sent to Device Device!")); // TODO - change to logger
 }
Esempio n. 5
0
    //同步指定类型的设备信息
    public void SyncDeviceInfoByDeviceType(DeviceType deviceType, PlayerActor playerActor)
    {
        DeviceMgr mgr = m_deviceMgrDict[deviceType];

        if (mgr != null)
        {
            mgr.SyncDeviceInfo(playerActor);
        }
    }
Esempio n. 6
0
    public Device GetDevice(DeviceType deviceType, int deviceId)
    {
        DeviceMgr mgr = GetDeviceMgr(deviceType);

        if (mgr == null)
        {
            return(null);
        }
        return(mgr.GetDevice(deviceId));
    }
Esempio n. 7
0
 public void AddDeviceMgr(DeviceMgr mgr)
 {
     if (mgr == null)
     {
         return;
     }
     if (m_deviceMgrDict.ContainsKey(mgr.DeviceType) == false)
     {
         m_deviceMgrDict.Add(mgr.DeviceType, mgr);
     }
 }
Esempio n. 8
0
	// Use this for initialization

    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(this);
        }
    }
Esempio n. 9
0
    //站台的下行屏蔽门状态设置为关闭
    public void CloseXiaXingPingBiMen(DeviceType deviceType)
    {
        DeviceMgr mgr = GetDeviceMgr(deviceType);

        if (mgr == null)
        {
            return;
        }
        PingBiMenMgr pingBiMenMgr = (PingBiMenMgr)mgr;

        pingBiMenMgr.XiaXingPingBiMenIsOpen = false;
    }
Esempio n. 10
0
    //站台的下行屏蔽门是否打开
    public bool IsOpenXiaXingPingBiMen(DeviceType deviceType)
    {
        DeviceMgr mgr = GetDeviceMgr(deviceType);

        if (mgr == null)
        {
            return(false);
        }
        PingBiMenMgr pingBiMenMgr = (PingBiMenMgr)mgr;

        return(pingBiMenMgr.XiaXingPingBiMenIsOpen);
    }
Esempio n. 11
0
    //同步所有设备信息
    public void SyncDeviceInfo(PlayerActor playerActor)
    {
        var enumerator = m_deviceMgrDict.GetEnumerator();

        while (enumerator.MoveNext())
        {
            DeviceMgr mgr = enumerator.Current.Value;
            if (mgr != null)
            {
                mgr.SyncDeviceInfo(playerActor);
            }
        }
        enumerator.Dispose();
    }
    private static void JJJ(StationMgr stationMgr, DeviceMgr deviceMgr, Transform deviceTypeTrans, System.UInt16 stationIndex, DeviceType deviceType)
    {
        int deviceCount = deviceTypeTrans.childCount;

        for (int i = 0; i < deviceCount; ++i)
        {
            Transform deviceTrans = deviceTypeTrans.GetChild(i);
            string    deviceName  = deviceTrans.gameObject.name;
            Device    deviceCom   = deviceTrans.GetComponent <Device> ();
            if (deviceCom == null)
            {
                continue;
            }
            deviceCom.DeviceId     = (int)deviceType + i + 1;
            deviceCom.StationIndex = stationIndex;
            deviceCom.DeviceType   = deviceType;
            deviceMgr.AddDevice(deviceCom);
            OneStation station = TDFramework.SingletonMgr.GameGlobalInfo.StationDeviceAndPointInfo.GetStation(stationIndex);
            // deviceType, deviceName
            PointBindInfoList list = station.GetPointBindInfoList(deviceType, deviceName);
            int pointCount         = list.m_pointBindInfoList.Count;
            for (int j = 0; j < pointCount; ++j)
            {
                PointBindInfo pointBindInfo = list.m_pointBindInfoList[j];
                int           pointStatus   = (int)System.Enum.Parse(typeof(PointStatus), pointBindInfo.m_name);
                int           queueIndex    = pointBindInfo.m_queueIndex;
                Point         point         = GetFirstPoint(stationMgr, stationIndex, pointStatus, queueIndex);
                point.m_device = deviceCom;
            }
            #region 设备是屏蔽门,需管理上行和下行屏蔽门
            if (deviceCom is PingBiMenDevice)
            {
                PingBiMenMgr    pingBiMenMgr = (PingBiMenMgr)deviceMgr;
                PingBiMenDevice device       = (PingBiMenDevice)deviceCom;
                if (device.PingBiMenType == PingBiMenType.Down)
                {
                    //下行屏蔽门
                    pingBiMenMgr.AddDevice2XiaXingPingBiMenList(deviceCom);
                }
                else if (device.PingBiMenType == PingBiMenType.Up)
                {
                    //上行屏蔽门
                    pingBiMenMgr.AddDevice2ShangXingPingBiMenList(deviceCom);
                }
            }
            #endregion
        }
    }
    private static void HHH(StationMgr stationMgr, Station station, Transform stationTrans, System.UInt16 stationIndex)
    {
        int deviceTypeCount = stationTrans.childCount;

        for (int i = 0; i < deviceTypeCount; ++i)
        {
            DeviceMgr  deviceMgr       = null;
            Transform  deviceTypeTrans = stationTrans.GetChild(i);
            DeviceType deviceType      = (DeviceType)System.Enum.Parse(typeof(DeviceType), deviceTypeTrans.gameObject.name);
            if (deviceType == DeviceType.ZhaJi)
            {
                deviceMgr = new ZhaJiMgr();
            }
            else if (deviceType == DeviceType.PingBiMen)
            {
                deviceMgr = new PingBiMenMgr();
            }
            //deviceTypeTrans是闸机父容器或者屏蔽门父容器
            JJJ(stationMgr, deviceMgr, deviceTypeTrans, stationIndex, deviceType);
            station.AddDeviceMgr(deviceMgr);
        }
    }
    public DTControl(double frequency, int[] analogChannels, Logger log, DoneSignalHandler callback)
    {
      try
      {
        m_deviceMgr = DeviceMgr.Get();

        if (!m_deviceMgr.HardwareAvailable())
          throw new Exception("No Devices Available.");

        // Get first available device
        m_device = m_deviceMgr.GetDevice(m_deviceMgr.GetDeviceNames()[0]);

        // Get subsystems
        m_ainSS = m_device.AnalogInputSubsystem(0);
        m_dinSS = m_device.DigitalInputSubsystem(0);
        m_doutSS = m_device.DigitalOutputSubsystem(0);

        /*
         * ANALOG SETUP
         */

        //Add event handlers
        m_ainSS.DriverRunTimeErrorEvent += HandleDriverRunTimeErrorEvent;
        m_ainSS.BufferDoneEvent += HandleBufferDone;
        m_ainSS.QueueDoneEvent += HandleQueueDone;
        m_ainSS.QueueStoppedEvent += HandleQueueStopped;

        // Set frequency
        m_frequency = (m_ainSS.Clock.MaxFrequency < frequency) ? m_ainSS.Clock.MaxFrequency : frequency;
        m_ainSS.Clock.Frequency = m_frequency;
        m_ainSS.VoltageRange = new Range(-10, 10);

        // Setup buffers
        m_ainSS.BufferQueue.FreeAllQueuedBuffers(); //just in case some are in the queue
        m_daqBuffers = new OlBuffer[MaxBuffers];
        for (int i = 0; i < MaxBuffers; i++)
        {
          // Allocate and place each buffer in queue
          m_daqBuffers[i] = new OlBuffer(SampleSize, m_ainSS);
          m_ainSS.BufferQueue.QueueBuffer(m_daqBuffers[i]);
        }

        // Set for continuous operation
        m_ainSS.DataFlow = DataFlow.Continuous;

        // Set channel list
        m_ainSS.ChannelList.Clear();
        m_physicalChannels = new List<int>();
        foreach (int channel in analogChannels)
        {
          ChannelListEntry channelListEntry = new ChannelListEntry(m_ainSS.SupportedChannels.GetChannelInfo(SubsystemType.AnalogInput, channel));
          channelListEntry.Gain = 1.0;
          m_ainSS.ChannelList.Add(channelListEntry);
          m_physicalChannels.Add(channel);
        }

        // Save configuration
        m_ainSS.Config();

        /*
         * DIGITAL SETUP
         */
        m_dinSS.DataFlow = DataFlow.SingleValue;
        m_doutSS.DataFlow = DataFlow.SingleValue;

        m_dinSS.Config();
        m_doutSS.Config();

        doneSignalHandler += callback;

        Log = log;

        Log("DT9816 and all subsystems initialized.");

        // Display actual hardware frequency set
        Log(String.Format("Actual Hardware Frequency = {0:0.000}", m_ainSS.Clock.Frequency));
      }
      catch (Exception ex)
      {
        throw ex;
      }
    }
Esempio n. 15
0
        public DTControl(double frequency, int[] analogChannels, Logger log, DoneSignalHandler callback)
        {
            try
            {
                m_deviceMgr = DeviceMgr.Get();

                if (!m_deviceMgr.HardwareAvailable())
                {
                    throw new Exception("No Devices Available.");
                }

                // Get first available device
                m_device = m_deviceMgr.GetDevice(m_deviceMgr.GetDeviceNames()[0]);

                // Get subsystems
                m_ainSS  = m_device.AnalogInputSubsystem(0);
                m_dinSS  = m_device.DigitalInputSubsystem(0);
                m_doutSS = m_device.DigitalOutputSubsystem(0);

                /*
                 * ANALOG SETUP
                 */

                //Add event handlers
                m_ainSS.DriverRunTimeErrorEvent += HandleDriverRunTimeErrorEvent;
                m_ainSS.BufferDoneEvent         += HandleBufferDone;
                m_ainSS.QueueDoneEvent          += HandleQueueDone;
                m_ainSS.QueueStoppedEvent       += HandleQueueStopped;

                // Set frequency
                m_frequency             = (m_ainSS.Clock.MaxFrequency < frequency) ? m_ainSS.Clock.MaxFrequency : frequency;
                m_ainSS.Clock.Frequency = m_frequency;
                m_ainSS.VoltageRange    = new Range(-10, 10);

                // Setup buffers
                m_ainSS.BufferQueue.FreeAllQueuedBuffers(); //just in case some are in the queue
                m_daqBuffers = new OlBuffer[MaxBuffers];
                for (int i = 0; i < MaxBuffers; i++)
                {
                    // Allocate and place each buffer in queue
                    m_daqBuffers[i] = new OlBuffer(SampleSize, m_ainSS);
                    m_ainSS.BufferQueue.QueueBuffer(m_daqBuffers[i]);
                }

                // Set for continuous operation
                m_ainSS.DataFlow = DataFlow.Continuous;

                // Set channel list
                m_ainSS.ChannelList.Clear();
                m_physicalChannels = new List <int>();
                foreach (int channel in analogChannels)
                {
                    ChannelListEntry channelListEntry = new ChannelListEntry(m_ainSS.SupportedChannels.GetChannelInfo(SubsystemType.AnalogInput, channel));
                    channelListEntry.Gain = 1.0;
                    m_ainSS.ChannelList.Add(channelListEntry);
                    m_physicalChannels.Add(channel);
                }

                // Save configuration
                m_ainSS.Config();

                /*
                 * DIGITAL SETUP
                 */
                m_dinSS.DataFlow  = DataFlow.SingleValue;
                m_doutSS.DataFlow = DataFlow.SingleValue;

                m_dinSS.Config();
                m_doutSS.Config();

                doneSignalHandler += callback;

                Log = log;

                Log("DT9816 and all subsystems initialized.");

                // Display actual hardware frequency set
                Log(String.Format("Actual Hardware Frequency = {0:0.000}", m_ainSS.Clock.Frequency));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }