get cameralist

Hello,

I want to program a plugin and I want to get a camera list similar as in the carusel sample. But instead of in a treeview in a listview.

I use VisualStudio 2017 and have there create a plugin. Ok , the plugin is visible in Management client and Backroundplugin is working. In Admin UserControl I have the list. But filling of the list is not working and I see not why. The code looks similar to the sample..

I’ve no idea what is wrong.

internal void FillContent(Item item)

   {

       textBoxName.Text = [item.Name](https://item.Name);

       if (item.Properties.ContainsKey("IPAddress"))

       {

           IPAddress = item.Properties\["IPAddress"\];

       }

       if (item.Properties.ContainsKey("Port"))

       {

           Port = item.Properties\["Port"\];

       }

       if (item.Properties.ContainsKey("Enabled"))

       {

           EnabledCheck = item.Properties\["Enabled"\] == "Yes";

       }

       GetCameras();

   }

internal void GetCameras()

   {

       List<Item> list = Configuration.Instance.GetItemsByKind(Kind.Camera);

       EnvironmentManager.Instance.Log(false, "WingControlPluginUserControl", "GetCameras()");

       if (list != null)

       {

           camList.Items.Clear();

           EnvironmentManager.Instance.Log(false, "WingControlPluginUserControl", "GetCameras() start loop...");

           foreach (Item item in list)

           {

               EnvironmentManager.Instance.Log(false, "WingControlPluginUserControl",string.Format( "GetCameras() item kind={0}, Name={1}", item.FQID.Kind.ToString(),[item.Name](https://item.Name)));

               if (item.FQID.Kind == Kind.Camera)

               {

                   CameraList cam;

                   cam.Camera = item;

                   //KeyValuePair<string, string> prop = item.Properties.ElementAt(10); //Get shortcut

                   cam.Shortcut = Convert.ToInt16(item.Properties\["Shortcut"\]);// prop.Value);

                   WriteList(cam);

               }

           }

       }

   }

   private void WriteList(CameraList camera)

   {

       string\[\] arr = new string\[2\];

       arr\[0\] = [camera.Camera.Name](https://camera.Camera.Name);

       arr\[1\] = camera.Shortcut.ToString();

       ListViewItem lvItem = new ListViewItem(arr);

       if (camList.InvokeRequired)

           camList.BeginInvoke(new MethodInvoker(() => camList.Items.Add(lvItem)));

       else

       {

           camList.Items.Add(lvItem);

           Cameras.Add(camera);

       }

   }

The configuration have varying depth, groups in groups and similar. I recommend a recursive method, an example is in the CameraStreamResolution sample FindCamera method.

The configuration is not a list but a tree. Try to explore the ConfigAccessViaSDK sample or the ConfigDump tool plugin sample to see this illustrated.

Hi Bo,

many thanks. The first method is what I need. This works fine.

It looks like the camera item in the plug-in interation is different than in the component interation. In the componet integration I can read the ShortCut of the Camera, with the plug-in integration I can not. Where can I get the ShortCut?

When I use the ConfigDump sample in the Smart Client I do see the ShortCut.

Have you restarted the Smart Client after having assigned a value to ShortCut?

I suggest you make a breakpoint and debug to see if there might be something fishy in your pluigin..

I use this plugin for the Management Client and on the Eventserver. I will send the camera name and shortcut to an external controller.

And I have no idea how to make a breakpoint and debug on a server.

The debugging is described in Plug-in Development - Getting Started in the MIP Documentation.

I did this now using the ConfigDump tools sample. (Starting the Event Server with the -x and debugging.) I can see that the camera properties availble in the Event Server is very reduced compared to the other environments, and unfortunately the ShortCut property does not exist there.

Thinking of a workaround.. If you send the camera (id or name) perhaps you can have the other application (“external controller”) lookup the short cut value.