Ejemplo n.º 1
0
        public bool BuildConfig(IServerConfiguration clients, IChannelDataProvider channelDataProvider, List <CDevice> devices, List <CLight> lights)
        {
            Util.Log("building config");

            BuildClientsHandlerConfig(clients);

            List <CColor> colors = new List <CColor>();

            if (!BuildColorConfig(colors))
            {
                return(false);
            }

            if (!BuildDeviceConfig(devices, channelDataProvider))
            {
                return(false);
            }

            if (!BuildLightConfig(lights, devices, colors))
            {
                return(false);
            }

            Util.Log("built config successfully");

            return(true);
        }
Ejemplo n.º 2
0
        public CDeviceRS232(IChannelDataProvider clients)
            : base(clients)
        {
            m_type     = -1;
            m_buff     = null;
            m_max      = 255;
            m_buffsize = 0;

            m_timer = new CSignalTimer(false); //TODO: m_stop???
        }
Ejemplo n.º 3
0
        public CDevice(IChannelDataProvider clients)
            : base()
        {
            m_clients = clients;

            m_channels       = new List <CChannel>();
            m_allowsync      = true;
            m_debug          = false;
            m_delayafteropen = 0;
            m_threadpriority = -1;
            m_setpriority    = false;
            m_prefix         = new List <byte>();
            m_postfix        = new List <byte>();
        }
Ejemplo n.º 4
0
        private CDeviceRS232 CreateRS232Device(IChannelDataProvider clients)
        {
            bool result;

            result = config.LoadConfigFromFile(Path.Combine(_configFileFolderPath, "RS232.conf"));
            Assert.IsTrue(result);

            result = config.CheckConfig();
            Assert.IsTrue(result);

            result = config.BuildConfig(mockServer, clients, devices, lights);
            Assert.IsTrue(result);
            Assert.AreEqual(1, devices.Count);
            Assert.IsInstanceOf <CDeviceRS232>(devices[0]);

            return((CDeviceRS232)devices[0]);
        }
Ejemplo n.º 5
0
        protected override void OnTestSetUp()
        {
            base.OnTestSetUp();

            _channelDataProvider = DevKit.Container.Resolve <IWitsmlDataAdapter <ChannelSet> >() as IChannelDataProvider;
        }
Ejemplo n.º 6
0
        private bool BuildRS232(out CDevice device, int devicenr, IChannelDataProvider clients, string type)
        {
            CDeviceRS232 rs232device = new CDeviceRS232(clients);

            device = rs232device;

            if (!SetDeviceName(rs232device, devicenr))
            {
                return(false);
            }

            if (!SetDeviceOutput(rs232device, devicenr))
            {
                return(false);
            }

            if (!SetDeviceChannels(rs232device, devicenr))
            {
                return(false);
            }

            if (!SetDeviceRate(rs232device, devicenr))
            {
                return(false);
            }

            if (!SetDeviceInterval(rs232device, devicenr))
            {
                return(false);
            }

            SetDeviceAllowSync(device, devicenr);
            SetDeviceDebug(device, devicenr);
            SetDeviceDelayAfterOpen(device, devicenr);
            SetDeviceThreadPriority(device, devicenr);

            bool hasbits = SetDeviceBits(rs232device, devicenr);
            bool hasmax  = SetDeviceMax(rs232device, devicenr);

            if (hasbits && hasmax)
            {
                Util.LogError($"{m_filename}: device {rs232device.Name} has both bits and max set");
                return(false);
            }

            if (type == "momo")
            {
                device.Type = CDevice.MOMO;
                SetDevicePrefix(rs232device, devicenr);
                SetDevicePostfix(rs232device, devicenr);
            }
            else if (type == "atmo")
            {
                device.Type = CDevice.ATMO;
            }
            else if (type == "karate")
            {
                device.Type = CDevice.KARATE;
            }
            else if (type == "sedu")
            {
                device.Type = CDevice.SEDU;
            }

            return(true);
        }
Ejemplo n.º 7
0
        private bool BuildDeviceConfig(List <CDevice> devices, IChannelDataProvider clients)
        {
            for (int i = 0; i < m_devicelines.Count; i++)
            {
                string line;
                int    linenr = GetLineWithKey("type", m_devicelines[i].lines, out line);
                string type;

                Util.GetWord(ref line, out type);

                if (type == "popen")
                {
                    throw new NotImplementedException("'popen' devices not supported yet");
                    //CDevice device = null;
                    //if (!BuildPopen(device, i, clients))
                    //{
                    //    if (device)
                    //        delete device;
                    //    return false;
                    //}
                    //devices.push_back(device);
                }
                else if (type == "momo" || type == "atmo" || type == "karate" || type == "sedu")
                {
                    CDevice device = null;
                    if (!BuildRS232(out device, i, clients, type))
                    {
                        if (device != null)
                        {
                            device = null; //TODO: Call dispose instead???
                        }
                        return(false);
                    }
                    devices.Add(device);
                }
                else if (type == "ltbl")
                {
                    throw new NotImplementedException("'ltbl' devices not supported yet");

                    //CDevice* device = NULL;
                    //if (!BuildLtbl(device, i, clients))
                    //{
                    //    if (device)
                    //        delete device;
                    //    return false;
                    //}
                    //devices.push_back(device);
                }
                else if (type == "ola")
                {
                    throw new NotImplementedException("'ola' devices not supported yet");

                    //# ifdef HAVE_OLA
                    //                    CDevice* device = NULL;
                    //                    if (!BuildOla(device, i, clients))
                    //                    {
                    //                        if (device)
                    //                            delete device;
                    //                        return false;
                    //                    }
                    //                    devices.push_back(device);
                    //#else
                    //                    LogError("%s line %i: boblightd was built without ola, recompile with enabled ola support",
                    //                             m_filename.c_str(), linenr);
                    //                    return false;
                    //#endif
                }
                else if (type == "sound")
                {
                    throw new NotImplementedException("'sound' devices not supported yet");

                    //# ifdef HAVE_LIBPORTAUDIO
                    //                    CDevice* device = NULL;
                    //                    if (!BuildSound(device, i, clients))
                    //                    {
                    //                        if (device)
                    //                            delete device;
                    //                        return false;
                    //                    }
                    //                    devices.push_back(device);
                    //#else
                    //                    LogError("%s line %i: boblightd was built without portaudio, no support for sound devices",
                    //                             m_filename.c_str(), linenr);
                    //                    return false;
                    //#endif
                }
                else if (type == "dioder")
                {
                    throw new NotImplementedException("'dioder' devices not supported yet");

                    //CDevice* device = NULL;
                    //if (!BuildDioder(device, i, clients))
                    //{
                    //    if (device)
                    //        delete device;
                    //    return false;
                    //}
                    //devices.push_back(device);
                }
                else if (type == "ambioder")
                {
                    throw new NotImplementedException("'ambioder' devices not supported yet");

                    //CDevice* device = NULL;
                    //if (!BuildAmbioder(device, i, clients))
                    //{
                    //    if (device)
                    //        delete device;
                    //    return false;
                    //}
                    //devices.push_back(device);
                }
                else if (type == "ibelight")
                {
                    throw new NotImplementedException("'ibelight' devices not supported yet");

                    //# ifdef HAVE_LIBUSB
                    //                    CDevice* device = NULL;
                    //                    if (!BuildiBeLight(device, i, clients))
                    //                    {
                    //                        if (device)
                    //                            delete device;
                    //                        return false;
                    //                    }
                    //                    devices.push_back(device);
                    //#else
                    //                    LogError("%s line %i: boblightd was built without libusb, no support for ibelight devices",
                    //                             m_filename.c_str(), linenr);
                    //                    return false;
                    //#endif
                }
                else if (type == "lightpack")
                {
                    throw new NotImplementedException("'lightpack' devices not supported yet");

                    //# ifdef HAVE_LIBUSB
                    //                    CDevice* device = NULL;
                    //                    if (!BuildLightpack(device, i, clients))
                    //                    {
                    //                        if (device)
                    //                            delete device;
                    //                        return false;
                    //                    }
                    //                    devices.push_back(device);
                    //#else
                    //                    LogError("%s line %i: boblightd was built without libusb, no support for lightpack devices",
                    //                             m_filename.c_str(), linenr);
                    //                    return false;
                    //#endif
                }
                else if (type == "lpd8806" || type == "ws2801")
                {
                    throw new NotImplementedException("'lpd8806' and 'ws2801' devices are not supported yet");

                    //# ifdef HAVE_LINUX_SPI_SPIDEV_H
                    //                    CDevice* device = NULL;
                    //                    if (!BuildSPI(device, i, clients, type))
                    //                    {
                    //                        if (device)
                    //                            delete device;
                    //                        return false;
                    //                    }
                    //                    devices.push_back(device);
                    //#else
                    //                    LogError("%s line %i: boblightd was built without spi, no support for lpd8806 devices",
                    //                             m_filename.c_str(), linenr);
                    //                    return false;
                    //#endif
                }
                else
                {
                    Util.LogError($"{m_filename} line {linenr}: unknown type {type}");
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 8
0
 protected override void OnTestSetUp()
 {
     _channelDataProvider = DevKit.Container.Resolve <IChannelDataProvider>(ObjectNames.Log131);
 }