Exemplo n.º 1
0
        /// <summary>
        /// Add given item to OPC items group
        /// </summary>
        /// <param name="itemName"></param>
        private void AddItemToGroup(string itemName)
        {
            try
            {
                int rtc;
                rtc = AsyncRefrGroup.Add(itemName);

                if (HRESULTS.Failed(rtc))
                {
                    DBLogging.InsertLogs("Exception: AddItemToGroup", false, "ReadWriteGroup.GetErrorString(rtc)    " + itemName, _connStr);
                }
            }
            catch (Exception ex)
            {
                DBLogging.InsertLogs("Exception: AddItemToGroup", false, "ReadWriteGroup.GetErrorString(rtc)    " + ex.Message, _connStr);
            }
        }
Exemplo n.º 2
0
        private string AddMyRefreshGroup1(OpcServer OpcSrv)
        {
            float deadBand = 90.0F;

            try
            {      // create group with 2 sec update rate
                oGrp = OpcSrv.AddGroup("Line1", true, UpdateRate, ref deadBand, 0, 0);
            }
            catch
            {
                DBLogging.InsertLogs("Exception: AddMyRefreshGroup1", false, "Group could not be added", _connStr);
                return("Group could not be added");
            }

            oGrp.DataChanged += new DataChangeEventHandler(DataChangedHandler);
            oGrp.AdviseIOPCDataCallback();


            //client handle as item index
            items1[0] = new OPCItemDef(TagLPG_Bay01_RFID_Puched, true, 0, VarEnum.VT_BOOL);
            items1[1] = new OPCItemDef(TagLPG_WB_RFIDPunched, true, 1, VarEnum.VT_BOOL);
            items1[2] = new OPCItemDef(TagLPG_Bay01_LPGBatchComplete, true, 2, VarEnum.VT_BOOL);

            int rtc;

            rtc = oGrp.AddItems(items1, out addRslt1);

            if (HRESULTS.Failed(rtc))
            {
                return("Error at AddItem");
            }
            for (int i = 0; i < addRslt1.Length; ++i)
            {
                ItemValues1[i] = new OPCItemState();
            }

            return("");
        }