private void btnBroadCastData_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.cboLine.SelectedIndex < 0)
                {
                    throw new Exception("No line name selected from list");
                }
                if (this.cboMachine.SelectedIndex < 0)
                {
                    throw new Exception("No machine selected from list");
                }
                if (this.cboStatus.SelectedIndex < 0)
                {
                    throw new Exception("No machine status selected from list");
                }



                string        lineName    = this.cboLine.SelectedItem.ToString();
                string        machineName = this.cboMachine.SelectedItem.ToString();
                MachineStatus status      = (MachineStatus)this.cboStatus.SelectedItem;


                MachineStatusData data = new MachineStatusData(lineName, machineName, status);
                ALDSDataServer.GetInstance().DistributeData(data);
                this.lblSendStatus.Text = "Last Data sent OK";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                this.lblSendStatus.Text = "No data sent";
            }
        }
Beispiel #2
0
        private Boolean TryParse(SocketData data, out ALDSData ALDS_Data)
        {
            MachineStatusData machineStatus;

            if (MachineStatusData.TryParse(data, out machineStatus))
            {
                ALDS_Data = machineStatus;
                return(true);
            }
            else
            {
                try
                {
                    //creates an ALDS data using
                    ALDS_Data = new ALDSData(data.DataName);
                    CustomHashTable table = (CustomHashTable)data.Value;
                    foreach (System.Collections.DictionaryEntry dice in table)
                    {
                        ALDS_Data.AttachDataAttribute((string)dice.Key, (string)dice.Value);
                    }
                }
                catch (Exception ex)
                {
                    ALDS_Data = null;
                    return(false);
                }

                return(true);
            }
        }
        private void _client_DataReceived(ALDSDataClient sender, ALDSData dataReceived)
        {
            if (dataReceived is MachineStatusData)
            {
                MachineStatusData statusData = (MachineStatusData)dataReceived;

                if (statusData.Status != MachineStatus.failure)
                {
                    this._manager.HandleMachineStatus(statusData.MachineName, statusData.Status);
                }
                else
                {
                    if (MachineStopped != null)
                    {
                        MachineStopped(statusData.MachineName);
                    }


                    this.notifyMachineStatus(this._linenumber, statusData.MachineName);
                }
            }
        }