Esempio n. 1
0
        public Screen(XmlNode node, Project parentProject)
        {
            string nodeName = node.Attributes["name"].Value;
            string nodeFileName = node.Attributes["filename"].Value;
            string nodeStringType = node.Attributes["type"].Value;
            string stringServerScriptLanguage = node.Attributes["serverscriptlanguage"].Value;
            string stringClientScriptLanguage = node.Attributes["clientscriptlanguage"].Value;

            ScreenType nodeType = convertScreenTypeFromString(nodeStringType);
            ScreenServerScriptLanguage nodeServerScriptLanguage = ConvertStringToScreenServerScriptLanguage(stringServerScriptLanguage);
            ScreenClientScriptLanguage nodeClientScriptLanguage = ConvertStringToScreenClientScriptLanguage(stringClientScriptLanguage);

            this.Name = nodeName;
            this.FileName = nodeFileName;
            this.FilePath = parentProject.FilePath + "screens" + Path.DirectorySeparatorChar;
            this.FilePath += nodeFileName;
            this.Project = parentProject;
            this.Type = nodeType;
            this.ServerScriptLanguage = nodeServerScriptLanguage;
            this.ClientScriptLanguage = nodeClientScriptLanguage;
        }
Esempio n. 2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="xmlScadaFile">
        /// A <see cref="XmlDocument"/> containing a Scadafile
        /// </param>
        private void LoadProjectSettings(XmlDocument xmlScadaFile)
        {
            XmlNodeList nodesList = xmlScadaFile.GetElementsByTagName("Project");

            foreach(XmlNode node in nodesList)
            {
                string projectName = node.Attributes["name"].Value;

                log.Info("Loading project: " + projectName);

                Project projectToAdd = new Project(node, this.rootPath);

                log.Info(projectName + " loaded.");

                Projects.Add(projectToAdd);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Start listening with the socket configuration
        /// </summary>
        /// /// <param name="parent">
        /// A <see cref="Project"/> that contains this new instance
        /// </param>
        public static void Start(Project parent)
        {
            parentProject = parent;

            System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();

            try
            {

                IPAddress localAddress = IPAddress.Any;

                // Define the kind of socket we want: Internet, Stream, TCP
                Socket listenSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

                // Define the address we want to claim: the first IP address found earlier, at port 2200
                IPEndPoint ipEndpoint = new IPEndPoint(localAddress, 2200);

                // Bind the socket to the end point
                listenSocket.Bind(ipEndpoint);

                // Start listening, only allow 1 connection to queue at the same time
                listenSocket.Listen(1);
                listenSocket.BeginAccept(new AsyncCallback(AcceptCallback), listenSocket);
                log.Info("Server is waiting on socket " + listenSocket.LocalEndPoint);

            }
            catch (Exception e)
            {
                log.Error("Caught Exception: " + e.ToString());
            }
        }