Пример #1
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            if (HoloConnect.deviceFinder == null)
            {
                HoloConnect.deviceFinder = new FindServer();
                HoloConnect.deviceFinder.StartScanning();
            }
            // Get inputs.
            string remoteIP = this.defaultIP;

            if (!DA.GetData(0, ref remoteIP))
            {
                return;
            }
            //////////////////////////////////////////////////////
            if (this.connect == null)             // New Connection.
            {
                this.connect = new Connection(remoteIP);
            }
            else if (this.connect.remoteIP != remoteIP)
            {
                // If IP Changed first Disconnect the old one.
                this.connect.Disconnect();
                this.connect = new Connection(remoteIP);
            }

            this.connect.status = this.status;
            if (this.status)
            {
                // Start connections
                bool success = this.connect.Connect();
                if (success)
                {
                    this.connect.TransmitIP();
                }
                string message = (success) ? "Connection established." : "Connection failed, please check your network connection and try again.";
                UniversalDebug(message, (success) ? GH_RuntimeMessageLevel.Remark : GH_RuntimeMessageLevel.Error);
            }
            else
            {
                this.connect.Disconnect();
            }
            //////////////////////////////////////////////////////
            // Output.
            DA.SetData(0, this.connect);
                        #if DEBUG
            DA.SetData(1, this.debugMessages[this.debugMessages.Count - 1]);
                        #endif

            //	// Expire Solution.
            //	if ((connect.status) && (connect.PendingMessages)) {
            //		GH_Document document = this.OnPingDocument();
            //		if (document != null)
            //			document.ScheduleSolution(HoloConnect.expireDelay, ScheduleCallback);
            //	}
            //}
            //private void ScheduleCallback(GH_Document document) {
            //	ExpireSolution(false);
        }
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            if (HoloConnect.deviceFinder == null)
            {
                HoloConnect.deviceFinder = new FindServer();
                HoloConnect.deviceFinder.StartScanning();
            }
            HoloConnect.deviceFinder.RefreshList();
            // Get inputs.
            string remoteIP = this.defaultIP;

            if (!DA.GetData(0, ref remoteIP))
            {
                return;
            }
            //////////////////////////////////////////////////////
            if (this.connect == null)
            {
                this.connect = new Connection(remoteIP);
            }

            this.connect.status = this.status;
            if (this.status)
            {
                // Start connections
                bool   success = this.connect.Connect();
                string message = (success) ? "Connection established." : "Connection failed, please check your network connection and try again.";
                UniversalDebug(message, (success) ? GH_RuntimeMessageLevel.Remark : GH_RuntimeMessageLevel.Error);
            }
            else
            {
                this.connect.Disconnect();
            }
            //////////////////////////////////////////////////////
            // Output.
            DA.SetData(0, this.connect);
                        #if DEBUG
            DA.SetData(1, this.debugMessages[this.debugMessages.Count - 1]);
                        #endif
        }