예제 #1
0
        public void timerUpdateCounters_Tick(object sender, EventArgs e)
        {
            // la actualización del grid de los contadores se hace con un timer
            // porque la API no está grabando en memoria y las tramas de lectura posteriores
            // a la escritura tardan en ejecutarse. Se usa una transacción.
            CStation_SOLD instanceStn = jbc.Station(iStationIDTransact);

            if (instanceStn != null)
            {
                timerUpdateCounters.Stop();
                if (instanceStn.QueryEndedTransaction(uiTransact))
                {
                    Cursor = Cursors.Default;
                    showSelectedStationCounters();
                }
                else
                {
                    timerUpdateCounters.Start();
                }
            }
            else
            {
                Cursor = Cursors.Default;
                showSelectedStationCounters();
            }
        }
예제 #2
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();
            }
        }
예제 #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.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;
            }
        }
예제 #4
0
        public void gridStations_CellClick(System.Object sender, System.Windows.Forms.DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0)
            {
                return;
            }

            long stationID = System.Convert.ToInt64(System.Convert.ToUInt32(gridStations.Rows[e.RowIndex].Cells[tCol_ID].Value));

            if (gridStations.Columns[e.ColumnIndex].Name != tCol_But_All && gridStations.Columns[e.ColumnIndex].Name != tCol_But_Partial)
            {
                return;
            }

            CStation_SOLD instanceStn = jbc.Station(stationID);

            switch (gridStations.Columns[e.ColumnIndex].Name)
            {
            case tCol_But_All:
                if (instanceStn.CommandProtocol != CStationBase.Protocol.Protocol_01 | cbProtocol01.Checked)
                {
                    if (Interaction.MsgBox(Localization.getResStr("tConfirmAction"), MsgBoxStyle.YesNo, Localization.getResStr("tResetAllCounters")) == MsgBoxResult.Yes)
                    {
                        uiTransact         = resetCounters(stationID, true, true);
                        iStationIDTransact = (int)stationID;
                        // la actualización del grid de los contadores se hace con un timer
                        // porque la API no está grabando en memoria y las tramas de lectura posteriores
                        // a la escritura tardan en ejecutarse. Se usa una transacción.
                        Cursor = Cursors.WaitCursor;
                        timerUpdateCounters.Start();
                    }
                }
                break;

            case tCol_But_Partial:
                if (instanceStn.GetStationFeatures().PartialCounters)
                {
                    if (Interaction.MsgBox(Localization.getResStr("tConfirmAction"), MsgBoxStyle.YesNo, Localization.getResStr("tResetPartialCounters")) == MsgBoxResult.Yes)
                    {
                        uiTransact         = resetCounters(stationID, true, false);
                        iStationIDTransact = (int)stationID;
                        // la actualización del grid de los contadores se hace con un timer
                        // porque la API no está grabando en memoria y las tramas de lectura posteriores
                        // a la escritura tardan en ejecutarse. Se usa una transacción.
                        Cursor = Cursors.WaitCursor;
                        timerUpdateCounters.Start();
                    }
                }
                break;

            default:
                return;
            }
        }
예제 #5
0
        private void setParametersLocked(long stationID, bool bLocked)
        {
            CStation_SOLD instanceStn = jbc.Station(stationID);

            instanceStn.SetControlMode(ControlModeConnection.CONTROL);
            if (bLocked)
            {
                instanceStn.SetStationParametersLocked(OnOff._ON);
            }
            else
            {
                instanceStn.SetStationParametersLocked(OnOff._OFF);
            }
            instanceStn.SetControlMode(ControlModeConnection.MONITOR);
        }
예제 #6
0
        private uint resetCounters(long stationID, bool bPartial, bool bGlobal)
        {
            // devuelve el ID de transacción para saber cuando ha finalizado
            CStation_SOLD instanceStn = jbc.Station(stationID);
            uint          transact    = (uint)0;

            instanceStn.SetControlMode(ControlModeConnection.CONTROL);
            if (bPartial && instanceStn.GetStationFeatures().PartialCounters)
            {
                for (var i = 0; i <= instanceStn.NumPorts - 1; i++)
                {
                    instanceStn.ResetPortToolMinutesPartial((Port)i);
                }
            }
            if (bGlobal)
            {
                instanceStn.ResetPortToolMinutesGlobalPorts();
            }
            transact = instanceStn.SetTransaction();
            instanceStn.SetControlMode(ControlModeConnection.MONITOR);
            instanceStn = null;
            return(transact);
        }