Exemplo n.º 1
0
        static IEnumerable <VariableDefinition <object> > loadVariableDefintions()
        {
            var dir  = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            var repo = new VariableConfigRepository(dir);

            return(repo.GetVariables());
        }
Exemplo n.º 2
0
        public void Main()
        {
            string VAR_CONFIG_DIR = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            VariableConfigRepository variableRepo = new VariableConfigRepository(VAR_CONFIG_DIR);

            var variableDefinitions = variableRepo.GetVariables();
            var supported_variables = variableDefinitions.Where(obj => obj.IsPlcValueConvertable() && obj.Path == "Kran").OrderBy(obj => obj.Name).ToArray();
            var plcReader           = new PlcReader(address: "192.168.20.2");

            plcReader.Connect();
            plcReader.SetVariablesToWatch(supported_variables.ToList());
            while (true)
            {
                Console.Clear();
                Console.WriteLine("____Reading Values____");
                plcReader.Update();
                foreach (var item in supported_variables)
                {
                    Console.WriteLine($"{item.Name}:      {item.Value} ({item.DataType})");
                }

                Thread.Sleep(1 * 1000);
            }
        }