Exemple #1
0
        public void timerStationListData_Tick(System.Object sender, System.EventArgs e)
        {
            // timer to update station list data

            ((Timer)sender).Stop();
            // activated when a new station is connected (addStation function)
            bool bAllWithData = true;

            foreach (long stnID in stationList.TableIDs)
            {
                tStation stn = stationList.GetStation(stnID);
                if (stn != null)
                {
                    if (stn.bStationShowed == false)
                    {
                        CStation_SOLD objStation = jbc.Station(stnID);
                        LogAdd(string.Format("Station {0} is initialized: {1} ", stnID.ToString(), objStation.IsInitialized.ToString()));

                        stn.sModel        = jbc.GetStationModel(stn.ID);
                        stn.sModelType    = jbc.GetStationModelType(stn.ID);
                        stn.iModelVersion = jbc.GetStationModelVersion(stn.ID);
                        stn.sName         = jbc.GetStationName(stn.ID);
                        stn.sSW           = jbc.GetStationSWversion(stn.ID);
                        stn.sHW           = jbc.GetStationHWversion(stn.ID);
                        stn.sStationCOM   = jbc.GetStationCOM(stn.ID);
                        stn.sProtocol     = jbc.GetStationProtocol(stn.ID);
                        stn.Features      = jbc.GetStationFeatures(stn.ID);

                        LogAdd(string.Format("Station {0} exists: {1} ", stn.ID.ToString(), jbc.StationExists(stn.ID).ToString()));
                        LogAdd(string.Format("Connected - Name:{0} - Model:{1} - Type:{2} - Version:{3}", stn.sName, stn.sModel, stn.sModelType, stn.iModelVersion.ToString()));
                        LogAdd(string.Format("            SW:{0} - HW:{1} - COM:{2} - Protocol:{3}", stn.sSW, stn.sHW, stn.sStationCOM, stn.sProtocol));

                        //If stn.sModel <> "" And stn.sSW <> "" Then
                        if (!string.IsNullOrEmpty(stn.sModel))
                        {
                            if (string.IsNullOrEmpty(stn.sName))
                            {
                                stn.sName = "No Name";
                            }
                            // show
                            LogAdd(string.Format("Connected - Name:{0} - Model:{1} - Type:{2} - Version:{3}", stn.sName, stn.sModel, stn.sModelType, stn.iModelVersion.ToString()));
                            LogAdd(string.Format("            SW:{0} - HW:{1} - COM:{2} - Protocol:{3}", stn.sSW, stn.sHW, stn.sStationCOM, stn.sProtocol));
                            stn.bStationShowed = true;

                            addUpdateGrid(stn);
                        }
                        else
                        {
                            bAllWithData = false;
                        }
                        stationList.SetStation(stnID, stn);
                    }
                }
            }
            if (!bAllWithData)
            {
                // continue with timer
                ((Timer)sender).Start();
            }
        }
        private void addUpdateGrid(tStation stn)
        {
            int iRow = -1;

            for (var i = 0; i <= gridStations.Rows.Count - 1; i++)
            {
                if ((int)(gridStations.Rows[i].Cells[tCol_ID].Value) == stn.ID)
                {
                    iRow = System.Convert.ToInt32(i);
                    break;
                }
            }
            if (iRow < 0)
            {
                iRow = gridStations.Rows.Add();
            }
            DataGridViewRow row = gridStations.Rows[iRow];

            row.Cells[tCol_ID].Value           = stn.ID;
            row.Cells["colName"].Value         = stn.sName;
            row.Cells["colModel"].Value        = stn.sModel;
            row.Cells["colModelType"].Value    = stn.sModelType;
            row.Cells["colModelVersion"].Value = stn.iModelVersion;
            row.Cells["colSW"].Value           = stn.sSW;
            row.Cells["colHW"].Value           = stn.sHW;
            row.Cells["colCOM"].Value          = stn.sStationCOM;
            row.Cells["colProtocol"].Value     = stn.sProtocol;

            if (stn.Features.ParamsLockedFrame)
            {
                row.Cells[tCol_But].ReadOnly = false;
                row.Cells[tCol_Sel].ReadOnly = true;

                CStation_SOLD instanceStn = jbc.Station(stn.ID);
                if (instanceStn.GetStationParametersLocked() == OnOff._ON)
                {
                    row.Cells[tCol_But].Value       = tUnlockParameters;
                    row.Cells[tCol_But].ToolTipText = tUnlockParametersHint;
                    row.Cells[tCol_Sel].Value       = tLockedParametersStatus;
                }
                else
                {
                    row.Cells[tCol_But].Value       = tLockParameters;
                    row.Cells[tCol_But].ToolTipText = tLockParametersHint;
                    row.Cells[tCol_Sel].Value       = tUnlockedParametersStatus;
                }
            }
            else
            {
                row.Cells[tCol_But].ReadOnly    = true;
                row.Cells[tCol_But].Value       = tNotAvailable;
                row.Cells[tCol_But].ToolTipText = tNotAvailableHint;


                row.Cells[tCol_Sel].ReadOnly = true;
                row.Cells[tCol_Sel].Value    = tUnlockedParametersStatus;
            }
        }
Exemple #3
0
        private void addUpdateGrid(tStation stn)
        {
            int iRow = -1;

            for (var i = 0; i <= gridStations.Rows.Count - 1; i++)
            {
                if ((int)(gridStations.Rows[i].Cells[tCol_ID].Value) == stn.ID)
                {
                    iRow = System.Convert.ToInt32(i);
                    break;
                }
            }
            if (iRow < 0)
            {
                iRow = gridStations.Rows.Add();
            }
            DataGridViewRow row = gridStations.Rows[iRow];

            row.Cells[tCol_ID].Value           = stn.ID;
            row.Cells["colName"].Value         = stn.sName;
            row.Cells["colModel"].Value        = stn.sModel;
            row.Cells["colModelType"].Value    = stn.sModelType;
            row.Cells["colModelVersion"].Value = stn.iModelVersion;
            row.Cells["colSW"].Value           = stn.sSW;
            row.Cells["colHW"].Value           = stn.sHW;
            row.Cells["colCOM"].Value          = stn.sStationCOM;
            row.Cells["colProtocol"].Value     = stn.sProtocol;

            if (stn.Features.PartialCounters)
            {
                row.Cells[tCol_But_Partial].Value       = Localization.getResStr("tResetPartialCountersHint");
                row.Cells[tCol_But_Partial].ToolTipText = Localization.getResStr("tResetPartialCountersHint");
                row.Cells[tCol_But_Partial].ReadOnly    = false;

                row.Cells[tCol_But_All].Value       = Localization.getResStr("tResetAllCounters");
                row.Cells[tCol_But_All].ToolTipText = Localization.getResStr("tResetGlobalAndPartialCountersHint");
                row.Cells[tCol_But_All].ReadOnly    = false;
            }
            else
            {
                row.Cells[tCol_But_Partial].Value       = Localization.getResStr("tNotAvailable");
                row.Cells[tCol_But_Partial].ToolTipText = Localization.getResStr("tNotAvailableHint");
                row.Cells[tCol_But_Partial].ReadOnly    = true;

                if (stn.sProtocol == "01")
                {
                    row.Cells[tCol_But_All].Value       = Localization.getResStr("tNotAvailable");
                    row.Cells[tCol_But_All].ToolTipText = Localization.getResStr("tNotProtocol01Hint");
                    row.Cells[tCol_But_All].ReadOnly    = true;
                }
                else
                {
                    row.Cells[tCol_But_All].Value       = Localization.getResStr("tResetAllCounter");
                    row.Cells[tCol_But_All].ToolTipText = Localization.getResStr("tResetGlobalCountersHint");
                    row.Cells[tCol_But_All].ReadOnly    = false;
                }
            }
        }
        //Add station to the list
        private tStation addStation(long stationID)
        {
            //Creating the station structure
            tStation dataStation = new tStation(stationID);

            //adding the structure to the list
            stationList.AddStation(stationID, dataStation);

            //returning the new added station object
            return(dataStation);
        }
 // modifica una estación
 public bool SetStation(long stationID, tStation ChangedStation)
 {
     if (ExistsStation(stationID))
     {
         StationsTableInt[stationID] = ChangedStation;
         return(true);
     }
     else
     {
         return(false);
     }
 }
 // Añade una estación
 public void AddStation(long stationID, tStation NewStation)
 {
     if (stationID >= 0)
     {
         if (ReferenceEquals(NewStation, null))
         {
             NewStation = new tStation(stationID);
         }
         NewStation.ID = stationID;
         StationsTableInt.Add(stationID, NewStation);
     }
 }
        private void jbc_NewStationConnected(long stationID)
        {
            //required as long as this method is called from a diferent thread
            if (this.InvokeRequired)
            {
                this.Invoke(new JBC_API.NewStationConnectedEventHandler(jbc_NewStationConnected), new object[] { stationID });
                return;
            }

            //new station connected, adding it
            tStation newStation = addStation(stationID);

            // #edu# activate timer to see if data is available to fill the grid for this station
            timerStationListData.Start();
        }
        private void jbc_StationDisconnected(long stationID)
        {
            //required as long as this method is called from a diferent thread
            if (this.InvokeRequired)
            {
                this.Invoke(new JBC_API.StationDisconnectedEventHandler(jbc_StationDisconnected), new object[] { stationID });
                return;
            }

            tStation stn = stationList.GetStation(stationID);

            LogAdd(string.Format("Disconnected - Name:{0} - Model:{1} - Type:{2} - Version:{3}", stn.sName, stn.sModel, stn.sModelType, stn.iModelVersion.ToString()));

            rmvStation(stationID);

            removeGrid(stationID);
        }