public T ReadTag <T>(string command)
        {
            StartOPcServerIfStopped();
            T result = default(T);

            ItemProperties[] item = null;
            //get value of command.
            item = opcServer.GetProperties(new string[1] {
                command
            }, true, new int[] { 2 });

            bool bOk = false;

            bOk  = item != null && item.Length > 0;
            bOk &= bOk &&
                   item[0].Properties != null && item[0].Properties.Length > 0;

            if (item[0].Properties == null)
            {
                return(result);
            }
            Property property = item[0].Properties[0];

            if (property.Value != null)
            {
                result = (T)property.Value;
            }

            return(result);
        }
        public bool IsCameraHealthy(string command)
        {
            bool result = false;

            //qualityBits machineQuality = qualityBits.bad;

            try
            {
                camOpcServer = OpcConnection.GetOPCServerConnection();
                ItemProperties[] item = null;


                //get value of command.
                item = objOpcServer.GetProperties(new string[1] {
                    command
                }, true, new int[] { 3 });

                Property property = item[0].Properties[0];
                result = ((OPCDA.OPCQuality)property.Value).QualityField == OPCDA.qualityBits.good;
            }
            catch (Exception errMsg)
            {
                result = false;
                Console.WriteLine(errMsg.Message);
            }

            finally
            {
                //Console.WriteLine(command);
            }


            return(result);
        }
        public T PhotoReadTag <T>(string command)
        {
            T    result    = default(T);
            int  counter   = 1;
            bool loopValue = true;

            while (loopValue == true)
            {
                if (counter == 20)
                {
                    loopValue = false;
                }
                counter += 1;

                try
                {
                    ItemProperties[] item = null;
                    item = camOPCServer.GetProperties(new string[1] {
                        command
                    }, true, new int[] { 2 });
                    Property property = item[0].Properties[0];
                    result = (T)property.Value;
                }

                catch (Exception errMsg)
                {
                }
                finally
                {
                }
            }
            return(result);
        }
        public T ReadTag <T>(string channel, string machine, string tagName)
        {
            T result = default(T);

            string command = channel + "." + machine + "." + tagName;

            objOpcServer = OpcConnection.GetOPCServerConnection();


            try
            {
                if (IsMachineHealthy(command))
                {
                    ItemProperties[] item = null;

                    //get value of command.
                    item = objOpcServer.GetProperties(new string[1] {
                        command
                    }, true, new int[] { 2 });
                    Property property = item[0].Properties[0];
                    result = (T)Convert.ChangeType(property.Value, typeof(T));
                }
                else
                {
                    //MethodDebug("OPC READ = MACHINE IS NOT HEALTHY, COMMAND =" + command);
                }
            }

            catch (Exception errMsg)
            {
                Console.WriteLine(errMsg.Message);
            }
            finally
            {
            }


            return(result);
        }