Hello Ventuzians!
THE FORUMS ARE CLOSED!

Please join our discord server HERE!! << click me :D

We are shutting our Ventuz Forum, but don't worry, it will all be archived for you to search in if you have a query. From now on, please add all your comments, questions or observations into our Discord Server

Thanks for the great time - see you on discord!!
Dee, Karol, Daniel and the whoooole Product and Support team!

Remoting 4

Q and A about functionality and how to solve a special task for your application.

Moderator: Support

Post Reply
serourian
Posts: 54
Joined: 30 Jun 2015, 12:06
Location: Lebanon
Contact:

Remoting 4

Post by serourian » 30 Dec 2016, 01:44

Hi, I have been writing all my ventuz remoting applications using only Ventuz OSC (not using remoting 4) because I couldn't understand the remoting 4 demo programs posted in earlier posts...

All I need is a clear, well commented demo of a very simple program using c# winforms please (not console or wincp, xaml....), to discover the machines connected and list them in a listbox,load a scene (any static file) to the machine selected in the list, and send few data (2-3 textboxes will do).
The Remoting 4 demo is really very complicated for me to start with, even the small one.

Thank you very much.

serourian
Posts: 54
Joined: 30 Jun 2015, 12:06
Location: Lebanon
Contact:

Re: Remoting 4

Post by serourian » 03 Jan 2017, 12:33

Please I'm stuck, i really appreciate any help. Ventuz Runtime loads the project, but I don't know how to load the scene to it . . . i'm really frustrated .... here is the code I have so far... (and I don't want to use clusters if possible)

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Ventuz.Remoting4;
using Ventuz.Remoting4.MachineService;
using System.Net;

namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
Cluster servercluster;
Cluster cluster = null;
VMSClient theclients;
List<VMS> AllVMachines = new List<VMS>();
List<VMSClient> activeVMSClients = new List<VMSClient>();

public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
var theclient = new VMSDiscovery(5, 0, null);
label2.Text = VMSDiscovery.GetLocalSystemId();
label1.Text = theclient.ToString();

StartMachineDiscovery();
}

VMSDiscovery vmsDiscover = null;
private void StartMachineDiscovery()
{
if (this.vmsDiscover == null)
{
this.vmsDiscover = new VMSDiscovery(10);
this.vmsDiscover.PropertyChanged += VMSDiscovery_Changed;
this.vmsDiscover.Discover();
}
else
{
this.vmsDiscover.Discover();
}
}
private void VMSDiscovery_Changed(object sender, PropertyChangedEventArgs e)
{
// TODO: compare with existing?
// create list from discovered Ventuz machines
AllVMachines = new List<VMS>(vmsDiscover.Items);
}
private void button2_Click(object sender, EventArgs e)
{
this.cluster = new Cluster { Name = "Wall" };

foreach (VMS vms in this.AllVMachines)
{

var aa = vms.ID;
var bb = vms.IPAddress;
var cc = vms.IPEndPoint;
//this.cluster.AddMachine(new IPEndPoint(vms.IPAddress, Cluster.DEFAULT_PORT));
this.activeVMSClients.Add(new VMSClient(vms));
this.cluster.AddMachine(cc);
listBox1.Items.Add(aa+" "+ bb);
this.cluster.Start();
}

}

private void button3_Click(object sender, EventArgs e)
{

foreach (VMSClient client in this.activeVMSClients)
{

client.Start(@"C:\Weather\Weather 2016.vzp");

//error happens here :oops:
FlaggedIID iid = cluster.Load("0000", "Icons Test ", LoadFlags.New | LoadFlags.Existing, null).Result;
}
}
}
}

User avatar
Eric_RD
Posts: 103
Joined: 04 Jun 2014, 14:01
Contact:

Re: Remoting 4

Post by Eric_RD » 04 Jan 2017, 14:08

Code: Select all

client.Start(@"C:\Weather\Weather 2016.vzp");
VMSClient.Start only takes string Arrays
try something. like:

Code: Select all

client.Start(new string[] {@"C:\Weather\Weather 2016.vzp" });

Code: Select all

FlaggedIID iid = cluster.Load("0000", "Icons Test ", LoadFlags.New | LoadFlags.Existing, null).Result;
There is a whitespace at the end of the scene name, is that name correct?
Personally I dont use space in File names I always replayer them with _

Otherwise the way of starting a project and loading a scene is OK.
You should however always watch out for null-objects like the "cluster" object in your example.

Have you seen the VentuzAPISDK.chm which can be found in the start menu or the Ventuz program folder?
That in combination with the Ventuz help is an almot complete documentation of what you can do with Remoting 4.

Eric

serourian
Posts: 54
Joined: 30 Jun 2015, 12:06
Location: Lebanon
Contact:

Re: Remoting 4

Post by serourian » 05 Jan 2017, 12:08

Hi Eric, thank you very much for the reply, yes the space was there by mistake(I just couldn't re-edit the post to correct it.)

Here is the working code for anyone who want to try out (just replace the filenames with your desired ones..
Open c# and add label1,label2,listbox1,button1,button2,button3,button5,button6, then paste the code,
and add the reference libraries of Ventuz5.....
THIS IS NOT A FACNY CONTROLLER, just a start for a full beginner trying remoting4.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Ventuz.Remoting4;
using Ventuz.Remoting4.MachineService;
using System.Net;

namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
Cluster servercluster;
Cluster cluster = null;
VMSClient theclients;
List<VMS> AllVMachines = new List<VMS>();
List<VMSClient> activeVMSClients = new List<VMSClient>();
IID activeScene = IID.Invalid;
FlaggedIID iid;
FlaggedIID iid2;

public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
var theclient = new VMSDiscovery(5, 0, null);
label2.Text = VMSDiscovery.GetLocalSystemId();
label1.Text = theclient.ToString();

StartMachineDiscovery();
}

VMSDiscovery vmsDiscover = null;
private void StartMachineDiscovery()
{
if (this.vmsDiscover == null)
{
this.vmsDiscover = new VMSDiscovery(10);
this.vmsDiscover.PropertyChanged += VMSDiscovery_Changed;
this.vmsDiscover.Discover();
}
else
{
this.vmsDiscover.Discover();
}
}
private void VMSDiscovery_Changed(object sender, PropertyChangedEventArgs e)
{
// TODO: compare with existing?
// create list from discovered Ventuz machines
AllVMachines = new List<VMS>(vmsDiscover.Items);
}
private void button2_Click(object sender, EventArgs e)
{
this.cluster = new Cluster { Name = "Wall" };

foreach (VMS vms in this.AllVMachines)
{

var aa = vms.ID;
var bb = vms.IPAddress;
var cc = vms.IPEndPoint;
this.cluster.AddMachine(new IPEndPoint(vms.IPAddress, Cluster.DEFAULT_PORT));
this.activeVMSClients.Add(new VMSClient(vms));
// this.cluster.AddMachine(cc);
listBox1.Items.Add(aa + " " + bb);

}
this.cluster.Start();
}

private void button3_Click(object sender, EventArgs e)
{
foreach (VMSClient client in this.activeVMSClients)
{
client.Start(new string[] { @"C:\Weather\Weather 2016.vzp" });
}

}

private void button5_Click(object sender, EventArgs e)
{
iid = cluster.Load("0000", "Icons Test", LoadFlags.New | LoadFlags.Existing, null).Result;
activeScene = iid.IID.Value;
cluster.PortStatus("0000", 0, true, iid.IID.Value, null, null);
}

private void button6_Click(object sender, EventArgs e)
{
iid2 = cluster.Load("0000", "Weather Icon", LoadFlags.New | LoadFlags.Existing, null).Result;
activeScene = iid2.IID.Value;
cluster.PortStatus("0000", 0, true, iid2.IID.Value, null, null);
}
}
}

Post Reply