B&r pvi

knuppel

Level-1
Beiträge
189
Reaktionspunkte
1
Zuviel Werbung?
-> Hier kostenlos registrieren
Ich versuche mich gerade mit B&R, PVI und C#. Mein SPS Programm läuft über Arwin. Die Simulation ist Online und der PVI-Manager laüft auch.
Wenn ich folgendes Programm laufen lasse:
Code:
using System;using System.Windows.Forms;
using BR.AN.PviServices;


namespace ConsoleApplication
{


    /// <summary>
    /// Summary description for Class1.
    /// </summary>
    class Class1
    {


        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main(string[] args)
        {
            Console.WriteLine("Connecting Service, Cpu, Variable ...");
            service = new Service("Service");
            service.Error += new PviEventHandler(Error);
            service.Connect();


            cpu = new Cpu(service, "Cpu");
           
            cpu.Connect();
            cpu.Connection.DeviceType = DeviceType.TcpIp;
cpu.Connection.TcpIp.DestinationIpAddress = "127.0.0.1";
cpu.Connection.TcpIp.SourceStation = 98;
cpu.Connection.TcpIp.SourcePort = 11160;
cpu.Connection.TcpIp.DestinationPort = 11160;
cpu.Connect();
            variable = new Variable(cpu, "variable1");
            variable.Connect();
            variable.Active = true;
            variable.ValueChanged += new VariableEventHandler(ValueChanged);


            // Start the message loop of the Application
            Application.Run();
        }


        static void Error(object sender, PviEventArgs e)
        {
            Console.WriteLine(String.Format("Error:{0}", e.ErrorText));


            // Error -> Exit the Application
            Application.Exit();
        }




        static void ValueChanged(object sender, VariableEventArgs e)
        {
            Variable var = (Variable)sender;
            Console.WriteLine("Value={0}", var.Value.ToString());


            // Exit the Application
            Application.Exit();
        }


        static Service service;
        static Cpu cpu;
        static Variable variable;


    }


}

Kommt in der Console leider der Fehler:
Error: Access Type not supported.

Weiß jemand Rat?
 
Hallo knuppel,

auch wenn deine Frage schon etwas älter ist habe ich folgende Tipps:
Ich glaube du musst mit den Cpu.Connect() Befehle nach den Cpu.Connection.TcpIp... Befehle aufrufen.
Außerdem darfst du den Cpu.Connect() Befehl erst aufrufen wenn der Service verbunden ist (Service.Connected event). Genauso mit Variable.Connect(), hier würde ich auf das Cpu.Connected event warten.

Mich würde auch deine sonstige Erfahrung mit PVI interessieren. Ich habe nämlich derzeit selbst ein kleines Problem: B&R PVIServices Fehlernummer 12058

Grüße
Consultant
 
Zuletzt bearbeitet:
Zuviel Werbung?
-> Hier kostenlos registrieren
Hallo,
leider muss ich dich entäuschen, ich musste den Job wechseln und hab leider nichts mehr mit B&R zu tun.

Warum nutzt du nicht OPC anstatt PVI, da hat sich doch ne Menge getan.
 
Zurück
Oben