public void GetSentData(EventData data)
        {
            if (data != null)
            {
                if (data.Id == "MTCONNECT_PROBE")
                {
                    if (data.Data02 != null)
                    {
                        var infos = StatusInfo.GetList((MTConnect.Application.Components.ReturnData)data.Data02);
                        if (infos.Count > 0)
                        {
                            statusInfos = infos;
                        }
                    }
                    else
                    {
                        SendStatusData(null);
                    }
                }
                else if (data.Id == "MTCONNECT_CURRENT" && data.Data02 != null)
                {
                    StatusInfo.ProcessList((MTConnect.Application.Streams.ReturnData)data.Data02, statusInfos);

                    SendStatusData(statusInfos);
                }
            }
        }
        public void GetSentData(EventData data)
        {
            if (data != null && data.Id != null && configuration != null)
            {
                if (data.Id == "CURRENT_INSTANCE")
                {
                    if (data.Data02 != null)
                    {
                        var sdc = Configuration.Get(configuration);
                        if (sdc != null)
                        {
                            var currentInstance = (CurrentInstance)data.Data02;

                            var info = new Snapshot.ProcessInfo();
                            info.CurrentData = currentInstance.CurrentData;
                            info.CurrentInstance = currentInstance.Instance;

                            Snapshot.Process(configuration, info);

                            // Send List of SnapShotItems to other Plugins
                            SendSnapShotItems(sdc.Snapshots);
                        }
                    }
                    else
                    {
                        SendSnapShotItems(null);
                    }
                }
            }
        }
 private void Row_Clicked(Controls.Row row)
 {
     var data = new EventData(this);
     data.Id = "OPEN_DEVICE_DETAILS";
     data.Data01 = row.Device;
     SendData?.Invoke(data);
 }
        public void GetSentData(EventData data)
        {
            if (data != null && data.Id != null)
            {
                switch (data.Id)
                {
                    case "MTCONNECT_PROBE":

                        if (data.Data02 == null)
                        {
                            SendInstanceData(configuration, null);
                            SendCurrentInstanceData(configuration, null);
                        }

                        break;

                    case "MTCONNECT_CURRENT":

                        if (data.Data02 != null) Update_Current((MTConnect.Application.Streams.ReturnData)data.Data02);

                        break;

                    case "MTCONNECT_SAMPLE":

                        if (data.Data02 != null) Update_Sample((MTConnect.Application.Streams.ReturnData)data.Data02);

                        break;
                }
            }
        }
 void SendGeneratedEvents(List<GeneratedEvent> events)
 {
     var data = new EventData(this);
     data.Id = "GENERATED_EVENTS";
     data.Data01 = configuration;
     data.Data02 = events.ToList();
     SendData?.Invoke(data);
 }
Beispiel #6
0
        public void GetSentData(EventData data)
        {
            if (data != null)
            {
                bool found = false;

                if (data.Id == "OVERRIDE_INSTANCES")
                {
                    if (data.Data02.GetType() == typeof(List<OverrideInstance>))
                    {
                        var instances = (List<OverrideInstance>)data.Data02;
                        if (instances != null)
                        {
                            lock (_lock)
                            {
                                overrideInstancesQueue.AddRange(instances);
                            }
                            found = true;
                        }
                    }
                }

                if (data.Id == "GENERATED_EVENTS")
                {
                    if (data.Data02.GetType() == typeof(List<GeneratedEvent>))
                    {
                        var gEvents = (List<GeneratedEvent>)data.Data02;
                        if (gEvents != null)
                        {
                            var oc = Configuration.Get(configuration);
                            if (oc != null)
                            {
                                var operatingEvents = gEvents.FindAll(o => o.EventName == oc.OperatingEventName && o.CurrentValue != null);
                                if (operatingEvents != null)
                                {
                                    lock (_lock)
                                    {
                                        gEventsQueue.AddRange(operatingEvents);
                                    }
                                    found = true;
                                }
                            }
                        }
                    }
                }

                if (found)
                {
                    lock (_lock)
                    {
                        ProcessQueue();
                    }
                }
            }
        }
        public void GetSentData(EventData data)
        {
            if (data != null)
            {
                if (data.Id == "MTCONNECT_AGENT_RESET")
                {
                    lastSequence = 0;
                    SaveStoredSequence(configuration, lastSequence);
                }

                if (data.Id == "GENERATED_EVENTS") { ProcessGeneratedEvents(data); }
            }
        }
        public void GetSentData(EventData data)
        {
            if (data != null && data.Id != null && configuration != null)
            {
                var gec = Configuration.Get(configuration);
                if (gec != null)
                {
                    if (data.Id == "INSTANCES")
                    {
                        var instances = (List<Instance>)data.Data02;

                        var events = GeneratedEvent.Process(configuration, instances);

                        // Send List of GeneratedEventItems to other Plugins
                        SendGeneratedEvents(events);
                    }
                }
            }
        }
        public void GetSentData(EventData data)
        {
            if (data != null)
            {
                switch (data.Id)
                {
                    case "INSTANCE_DATA":

                        var instances = (List<Instance>)data.Data02;

                        List<CycleData> cycles = ProcessCycles(instances);
                        if (cycles != null && cycles.Count > 0)
                        {
                            SendCycleData(cycles);
                        }

                        break;
                }
            }
        }
Beispiel #10
0
        public void GetSentData(EventData data)
        {
            if (data != null && deviceInfo != null)
            {
                switch (data.Id)
                {
                    // Add Custom Device Data Class to DeviceInfo object
                    case "ADD_DEVICE_DATA": AddData(data); break;

                    // Get Cycle Data
                    //case "CYCLES": UpdateCycleData(data); break;

                    // Get Device Availability
                    case "DEVICE_AVAILABILITY": UpdateDeviceAvailability(data); break;

                    // Get Generated Event Item data
                    case "GENERATED_EVENTS": UpdateGeneratedEvents(data); break;

                    // Get Status Data
                    case "MTCONNECT_STATUS": UpdateMTConnectStatus(data); break;

                    // Get OEE Values
                    case "OEE": UpdateOee(data); break;

                    // Get Override Values
                    case "OVERRIDE_ITEMS": UpdateOverrideData(data); break;

                    // Get Parts Values
                    case "PARTS": UpdatePartCount(data); break;

                    // Get Server Stopped
                    case "SERVER_STOPPED": UpdateServerStopped(data); break;

                    // Get Snapshot Data
                    case "SNAPSHOTS": UpdateSnapshots(data); break;

                    // Server User Changed
                    case "USER_LOGIN": UpdateUserLogin(data); break;
                }
            }
        }
Beispiel #11
0
 private void ShowDeviceManagerRequested(EventData data)
 {
     if (data != null && data.Id != null)
     {
         if (data.Id == "SHOW_DEVICE_MANAGER")
         {
             DeviceManager_DeviceList_Open();
         }
     }
 }
Beispiel #12
0
        private void ShowEditDeviceRequested(EventData data)
        {
            if (data != null && data.Id != null)
            {
                if (data.Id == "SHOW_EDIT_DEVICE" && data.Data01 != null && data.Data01.GetType() == typeof(DeviceDescription))
                {
                    var device = (DeviceDescription)data.Data01;

                    DeviceManager_EditDevice_Open(device);
                }
            }
        }
Beispiel #13
0
        private void SendEventData(EventData data)
        {
            LoadDevicesRequested(data);
            ShowDeviceManagerRequested(data);
            ShowEditDeviceRequested(data);
            ShowRequested(data);

            if (deviceListPage != null) deviceListPage.GetSentData(data);

            foreach (var tabHeader in TabHeaders)
            {
                Dispatcher.BeginInvoke(new Action(() =>
                {
                    if (tabHeader.Page != null)
                    {
                        if (tabHeader.Page.PageContent != null && tabHeader.Page.PageContent != data.Sender)
                        {
                            tabHeader.Page.PageContent.GetSentData(data);
                        }
                    }
                }), System.Windows.Threading.DispatcherPriority.Background, new object[] { });
            }
        }
 void GetProbeData(EventData data)
 {
     if (data != null && data.Id != null && data.Data02 != null)
     {
         if (data.Id.ToLower() == "mtconnect_probe_dataitems")
         {
             var dataItems = (List<DataItem>)data.Data02;
             probeData = dataItems;
             if (Loaded) LoadCollectedItems(dataItems);
         }
     }
 }
 void UpdateLoggedInChanged(EventData data)
 {
     if (data != null)
     {
         if (data.Id == "USER_LOGIN")
         {
             if (data.Data01 != null) currentUser = (UserConfiguration)data.Data01;
         }
         else if (data.Id == "USER_LOGOUT")
         {
             currentUser = null;
         }
     }
 }
        private void SendCurrentUser(IPage page)
        {
            var data = new EventData(this);

            if (currentUser != null)
            {
                data.Id = "USER_LOGIN";
                data.Data01 = currentUser;
            }
            else
            {
                data.Id = "USER_LOGOUT";
            }

            page.GetSentData(data);
        }
 public SendDataInfo(IClientPlugin plugin, EventData data)
 {
     Plugin = plugin;
     Data = data;
 }
        public void GetSentData(EventData data)
        {
            if (data != null && data.Id == "USER_LOGIN")
            {
                if (data.Data01.GetType() == typeof(UserConfiguration))
                {
                    _userConfiguration = (UserConfiguration)data.Data01;
                }
            }

            if (data != null && data.Id == "USER_LOGOUT")
            {
                _userConfiguration = null;
            }

            if (data != null && data.Id == "STATUS_STATUS" && data.Data02 != null && data.Data02.GetType() == typeof(Data.StatusInfo))
            {
                Dispatcher.BeginInvoke(new Action(() =>
                {
                    string uniqueId = data.Data01.ToString();
                    if (Device != null && Device.UniqueId == uniqueId)
                    {
                        var info = (Data.StatusInfo)data.Data02;

                        UpdateDeviceInfo(info);
                    }
                }), System.Windows.Threading.DispatcherPriority.Background, new object[] { });
            }

            if (data != null && data.Id == "STATUS_CONTROLLER" && data.Data02 != null && data.Data02.GetType() == typeof(Data.ControllerInfo))
            {
                Dispatcher.BeginInvoke(new Action(() =>
                {
                    string uniqueId = data.Data01.ToString();
                    if (Device != null && Device.UniqueId == uniqueId)
                    {
                        var info = (Data.ControllerInfo)data.Data02;

                        UpdateDeviceInfo(info);
                    }
                }), System.Windows.Threading.DispatcherPriority.Background, new object[] { });
            }

            if (data != null && data.Id == "STATUS_HOURS" && data.Data02 != null && data.Data02.GetType() == typeof(List<Data.HourInfo>))
            {
                Dispatcher.BeginInvoke(new Action(() =>
                {
                    string uniqueId = data.Data01.ToString();
                    if (Device != null && Device.UniqueId == uniqueId)
                    {
                        var info = (List<Data.HourInfo>)data.Data02;

                        UpdateDeviceInfo(info);
                    }
                }), System.Windows.Threading.DispatcherPriority.Background, new object[] { });
            }

            if (data != null && data.Id == "STATUS_TIMERS" && data.Data02 != null && data.Data02.GetType() == typeof(Data.TimersInfo))
            {
                Dispatcher.BeginInvoke(new Action(() =>
                {
                    string uniqueId = data.Data01.ToString();
                    if (Device != null && Device.UniqueId == uniqueId)
                    {
                        var info = (Data.TimersInfo)data.Data02;

                        UpdateDeviceInfo(info);
                    }
                }), System.Windows.Threading.DispatcherPriority.Background, new object[] { });
            }

            if (data != null && data.Id == "STATUS_OEE" && data.Data02 != null && data.Data02.GetType() == typeof(TrakHound.API.Data.OeeInfo))
            {
                Dispatcher.BeginInvoke(new Action(() =>
                {
                    string uniqueId = data.Data01.ToString();
                    if (Device != null && Device.UniqueId == uniqueId)
                    {
                        var info = (Data.OeeInfo)data.Data02;

                        UpdateDeviceInfo(info);
                    }
                }), System.Windows.Threading.DispatcherPriority.DataBind, new object[] { });
            }
        }
Beispiel #19
0
        /// <summary>
        /// Page has sent a message requesting to be shown as a tab
        /// de_d.id = 'show'
        /// de_d.data01 = Configuration
        /// de_d.data02 = Page (IPage)
        /// de_d.data03 = [Optional] Alternate Title
        /// de_d.data04 = [Optional] Tag
        /// </summary>
        /// <param name="de_d"></param>
        private void ShowRequested(EventData data)
        {
            if (data != null)
            {
                if (data.Id == "SHOW")
                {
                    if (data.Data02 != null)
                    {
                        if (typeof(IPage).IsAssignableFrom(data.Data02.GetType()))
                        {
                            var page = (IPage)data.Data02;

                            string title = page.Title;

                            ImageSource img = null;
                            if (page.Image != null) img = new BitmapImage(page.Image);

                            string tag = null;

                            if (data.Data03 != null) title = data.Data03.ToString();
                            if (data.Data04 != null) tag = data.Data04.ToString();

                            AddTab(page, title, img, tag);
                        }
                    }
                }
            }
        }
        public void GetSentData(EventData data)
        {
            Dispatcher.BeginInvoke(new Action<EventData>(UpdateLoggedInChanged), System.Windows.Threading.DispatcherPriority.DataBind, new object[] { data });
            Dispatcher.BeginInvoke(new Action<EventData>(UpdateDevicesLoading), System.Windows.Threading.DispatcherPriority.Normal, new object[] { data });

            Dispatcher.BeginInvoke(new Action<EventData>(UpdateDeviceAdded), System.Windows.Threading.DispatcherPriority.DataBind, new object[] { data });
            Dispatcher.BeginInvoke(new Action<EventData>(UpdateDeviceUpdated), System.Windows.Threading.DispatcherPriority.DataBind, new object[] { data });
            Dispatcher.BeginInvoke(new Action<EventData>(UpdateDeviceRemoved), System.Windows.Threading.DispatcherPriority.DataBind, new object[] { data });
        }
        /// <summary>
        /// Plugin has sent a DataEvent_Data object to other plugins
        /// </summary>
        /// <param name="de_d"></param>
        private void Plugin_SendData(EventData data)
        {
            foreach (var config in PluginConfigurations)
            {
                if (config.Enabled)
                {
                    var plugin = Plugins.Find(x =>
                        x.Title == config.Name &&
                        x.ParentPlugin == config.Parent &&
                        x.ParentPluginCategory == config.Category
                        );
                    if (plugin != null && plugin != data.Sender)
                    {
                        var sendDataInfo = new SendDataInfo(plugin, data);

                        ThreadPool.QueueUserWorkItem(new WaitCallback(ProcessSendData), sendDataInfo);
                    }
                }
            }

            SendEventData(data);
        }
        /// <summary>
        /// Load a Device from a local path
        /// </summary>
        /// <param name="path">Path to the file to load</param>
        /// <returns>Boolean whether load was successful</returns>
        private bool LoadDevice(string path)
        {
            bool result = false;

            // Get Configuration from path
            var config = DeviceConfiguration.Read(path);
            if (config != null)
            {
                if (currentUser != null)
                {
                    result = TrakHound.API.Devices.Update(currentUser, config);
                }
                // If not logged in Read from File in 'C:\TrakHound\'
                else
                {
                    result = DeviceConfiguration.Save(config);
                }

                if (result)
                {
                    // Send message that device was added
                    var data = new EventData(this);
                    data.Id = "DEVICE_ADDED";
                    data.Data01 = new DeviceDescription(config);
                    SendData?.Invoke(data);
                }
            }

            return result;
        }
        public void GetSentData(EventData data)
        {
            if (autoDetectPage != null) autoDetectPage.GetSentData(data);
            if (manualPage != null) manualPage.GetSentData(data);
            if (loadFromFilePage != null) loadFromFilePage.GetSentData(data);

            UpdateLoggedInChanged(data);
        }
 void UpdateDeviceAdded(EventData data)
 {
     if (data != null)
     {
         if (data.Id == "DEVICE_ADDED" && data.Data01 != null)
         {
             Devices.Add((DeviceDescription)data.Data01);
         }
     }
 }
 private void SendPageData(EventData data)
 {
     SendData?.Invoke(data);
 }
 void UpdateDevicesLoading(EventData data)
 {
     if (data != null)
     {
         if (data.Id == "DEVICES_LOADING")
         {
             ClearDevices();
         }
     }
 }
 public void GetSentData(EventData data)
 {
     GetProbeData(data);
 }
        void UpdateDeviceUpdated(EventData data)
        {
            if (data != null)
            {
                if (data.Id == "DEVICE_UPDATED" && data.Data01 != null)
                {
                    var device = (DeviceDescription)data.Data01;

                    int i = Devices.ToList().FindIndex(x => x.UniqueId == device.UniqueId);
                    if (i >= 0)
                    {
                        Devices.RemoveAt(i);
                        Devices.Insert(i, device);
                    }
                }
            }
        }
 public void GetSentData(EventData data)
 {
 }
Beispiel #30
0
 private void LoadDevicesRequested(EventData data)
 {
     if (data != null && data.Id != null)
     {
         if (data.Id == "LOAD_DEVICES")
         {
             LoadDevices();
         }
     }
 }