Exemple #1
0
        //------------------------------------------------------------------------------------------------------------------------
        #endregion

        #region Functions
        //------------------------------------------------------------------------------------------------------------------------
        public void Init()
        {
            //load config
            XmlSerializer ser = new XmlSerializer(typeof(NodeDescriptor));

            if (!File.Exists("config.xml"))
            {
                DebugEx.TraceLog("Could not find config.xml");
                return;
            }
            else
            {
                using (var fs = new FileStream("config.xml", FileMode.Open))
                    ActiveCfg = ser.Deserialize(fs) as NodeDescriptor;
            }

            //first check/validation in config.xml
            if (ActiveCfg?.AWSInfo?.AWSBrokerHostName == null || ActiveCfg?.AWSInfo?.PFXClientCertPath == null || ActiveCfg?.AWSInfo?.RootCertPath == null || ActiveCfg?.AWSInfo?.DeviceName == null || ActiveCfg?.AWSInfo?.ApplicationName == null)
            {
                DebugEx.TraceLog("Not Valid Configuration in IBMInfo");
                return;
            }
            if (ActiveCfg?.YodiwoInfo?.YodiwoApiServer == null || ActiveCfg?.YodiwoInfo?.YodiwoNodeKey == null || ActiveCfg?.YodiwoInfo?.YodiwoRestUrl == null || ActiveCfg?.YodiwoInfo?.YodiwoSecretKey == null || ActiveCfg?.YodiwoInfo?.YPChannelPort == null)
            {
                DebugEx.TraceLog("Not Valid Configuration in YodiwoInfo");
                return;
            }
            if (ActiveCfg.ThingsDescription.ThingDescriptor.Count == 0)
            {
                DebugEx.TraceLog("List of Things is empty");
                return;
            }
            else
            {
                foreach (var thdesc in ActiveCfg.ThingsDescription.ThingDescriptor)
                {
                    if (thdesc?.Name == null || thdesc?.IO == null || thdesc?.Type == null)
                    {
                        DebugEx.TraceError("Check thing configurations!!! " + ((thdesc.Name != null) ? thdesc.Name : String.Empty));
                        return;
                    }
                    else
                    {
                        //reconstruct thing from thing config description
                        var th = ReconstructThing(thdesc);
                        if (th != null)
                        {
                            Things.Add(th);
                        }
                    }
                }
            }
            InitAWSConnection();
            InitYodiwoConnection();
        }
Exemple #2
0
        //------------------------------------------------------------------------------------------------------------------------
        #endregion

        #region Functions
        //------------------------------------------------------------------------------------------------------------------------
        public void Init()
        {
            //load config
            XmlSerializer ser = new XmlSerializer(typeof(NodeDescriptor));
            if (!File.Exists("config.xml"))
            {
                DebugEx.TraceLog("Could not find config.xml");
                return;
            }
            else {
                using (var fs = new FileStream("config.xml", FileMode.Open))
                    ActiveCfg = ser.Deserialize(fs) as NodeDescriptor;
            }

            //first check/validation in config.xml
            if (ActiveCfg?.AWSInfo?.AWSBrokerHostName == null || ActiveCfg?.AWSInfo?.PFXClientCertPath == null || ActiveCfg?.AWSInfo?.RootCertPath == null || ActiveCfg?.AWSInfo?.DeviceName == null || ActiveCfg?.AWSInfo?.ApplicationName == null)
            {
                DebugEx.TraceLog("Not Valid Configuration in IBMInfo");
                return;
            }
            if (ActiveCfg?.YodiwoInfo?.YodiwoApiServer == null || ActiveCfg?.YodiwoInfo?.YodiwoNodeKey == null || ActiveCfg?.YodiwoInfo?.YodiwoRestUrl == null || ActiveCfg?.YodiwoInfo?.YodiwoSecretKey == null || ActiveCfg?.YodiwoInfo?.YPChannelPort == null)
            {
                DebugEx.TraceLog("Not Valid Configuration in YodiwoInfo");
                return;
            }
            if (ActiveCfg.ThingsDescription.ThingDescriptor.Count == 0)
            {
                DebugEx.TraceLog("List of Things is empty");
                return;
            }
            else
            {
                foreach (var thdesc in ActiveCfg.ThingsDescription.ThingDescriptor)
                {
                    if (thdesc?.Name == null || thdesc?.IO == null || thdesc?.Type == null)
                    {
                        DebugEx.TraceError("Check thing configurations!!! " + ((thdesc.Name != null) ? thdesc.Name : String.Empty));
                        return;
                    }
                    else
                    {
                        //reconstruct thing from thing config description
                        var th = ReconstructThing(thdesc);
                        if (th != null)
                            Things.Add(th);
                    }
                }
            }
            InitAWSConnection();
            InitYodiwoConnection();
        }