Example #1
0
        public async Task <bool> getSleepStatus(int port)
        {
            bool isSleeping = false;

            try
            {
                // devuelve si el modo continuo está activado
                // y si está en sleep, que sirve para empezar el gráfico en las modalidades Auto y Single
                CContinuousModeStatus cmStatus = await jbc.GetContinuousModeAsync((long)ID);

                if (cmStatus.speed == SpeedContinuousMode.OFF)
                {
                    // si el modo continuo está desactivado, obtener el sleep del estado del puerto
                    // get remote WCF data
                    await jbc.UpdatePortStatusAsync((long)ID, (Port)(port - 1));

                    // check port status
                    if (StationType == eStationType.SOLD)
                    {
                        if (jbc.GetPortToolSleepStatus((long)ID, (Port)(port - 1)) == OnOff._ON ||
                            jbc.GetPortToolHibernationStatus((long)ID, (Port)(port - 1)) == OnOff._ON ||
                            jbc.GetPortToolStandStatus((long)ID, (Port)(port - 1)) == OnOff._ON)
                        {
                            isSleeping = true;
                        }
                        else
                        {
                            isSleeping = false;
                        }
                    }
                    if (StationType == eStationType.HA)
                    {
                        if (jbc.GetPortToolHeaterStatus((long)ID, (Port)(port - 1)) == OnOff._ON)
                        {
                            isSleeping = false;
                        }
                        else
                        {
                            isSleeping = true;
                        }
                    }
                    //Debug.Print("isSleeping cont mode OFF: {0}", isSleeping.ToString)
                }
                else
                {
                    // si el modo continuo está activado, se obtiene el sleep de los datos del modo continuo
                    //getting the required data
                    await updatePortsAsync();

                    //retunring the data
                    if (StationType == eStationType.SOLD)
                    {
                        //isSleeping = (portList(port - 1).status = JBC_API.ToolStatus.SLEEP)
                        if (portList[port - 1].status == ToolStatus.SLEEP |
                            portList[port - 1].status == ToolStatus.HIBERNATION |
                            portList[port - 1].status == ToolStatus.STAND)
                        {
                            isSleeping = true;
                        }
                        else
                        {
                            isSleeping = false;
                        }
                    }
                    if (StationType == eStationType.HA)
                    {
                        if (portList[port - 1].status_HA == ToolStatus_HA.HEATER | portList[port - 1].status_HA == ToolStatus_HA.HEATER_REQUESTED)
                        {
                            isSleeping = false;
                        }
                        else
                        {
                            isSleeping = true;
                        }
                    }
                    //Debug.Print("isSleeping cont mode ON: {0}", isSleeping.ToString)
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Cstation::getSleepStatus . error:" + ex.Message);
                isSleeping = false;
            }

            return(isSleeping);
        }
Example #2
0
        private void updatePortInstance(int port, PictureBox pcb, Label lbl)
        {
            // Required var's
            bool sleep               = false;
            bool hiber               = false;
            bool extractor           = false;
            bool desolder            = false;
            GenericStationTools tool = default(GenericStationTools);
            string status            = "";

            // If the port exists
            if (port < nPorts)
            {
                // Setting the tool image
                tool = jbc.GetPortToolID(myID, (Port)port);
                pcb.BackgroundImage = (Image)My.Resources.Resources.ResourceManager.GetObject(tool.ToString() + "_mini");

                // Determinating the tool status
                sleep     = jbc.GetPortToolSleepStatus(myID, (Port)port) == OnOff._ON;
                hiber     = jbc.GetPortToolHibernationStatus(myID, (Port)port) == OnOff._ON;
                extractor = jbc.GetPortToolExtractorStatus(myID, (Port)port) == OnOff._ON;
                desolder  = jbc.GetPortToolDesolderStatus(myID, (Port)port) == OnOff._ON;
                if (sleep)
                {
                    status = Localization.getResStr(Configuration.PortsSleepId);
                }
                else if (hiber)
                {
                    status = Localization.getResStr(Configuration.PortsHiberId);
                }
                else if (extractor)
                {
                    status = Localization.getResStr(Configuration.PortsExtractorId);
                }
                else if (desolder)
                {
                    status = Localization.getResStr(Configuration.PortsDesolderId);
                }
                else if (tool == GenericStationTools.NO_TOOL)
                {
                    status = Localization.getResStr(Configuration.PortsNoToolId);
                }
                else
                {
                    status = Localization.getResStr(Configuration.PortsWorkId);
                }

                // Getting the temperature string
                string       tempStr = "";
                CTemperature temp    = jbc.GetPortToolActualTemp(myID, (Port)port);
                if (!Equals(temp, null))
                {
                    if (temp.isValid())
                    {
                        if (Configuration.Tunits == Configuration.CELSIUS_STR)
                        {
                            tempStr = temp.ToCelsius().ToString() + Configuration.Tunits;
                        }
                        if (Configuration.Tunits == Configuration.FAHRENHEIT_STR)
                        {
                            tempStr = temp.ToFahrenheit().ToString() + Configuration.Tunits;
                        }
                    }
                }

                // Showing the port data depending on the status
                int    textW   = System.Convert.ToInt32(lbl.CreateGraphics().MeasureString(Localization.getResStr(Configuration.PortsPortTitleId) + " " + (port + 1).ToString(), Configuration.PortsFont).Width);
                int    spaceW  = System.Convert.ToInt32(lbl.CreateGraphics().MeasureString(" ", Configuration.PortsFont).Width);
                int    nSpaces = System.Convert.ToInt32((lbl.Width - textW) / spaceW);
                string sTool   = tool.ToString();
                if (tool == GenericStationTools.NO_TOOL)
                {
                    sTool = " ";
                }
                lbl.Text = new string(' ', nSpaces);
                lbl.Text = lbl.Text + Localization.getResStr(Configuration.PortsPortTitleId) + " " + (port + 1).ToString() + "\r\n";
                lbl.Text = lbl.Text + sTool + "\r\n";
                if (status == Localization.getResStr(Configuration.PortsWorkId))
                {
                    lbl.Text = lbl.Text + tempStr;
                }
                else
                {
                    lbl.Text = lbl.Text + status;
                }
            }
        }