Пример #1
0
        public void RemoveIOConnectionsInPlan(string planName)
        {
            //IO address currently related to plan "planName": ConnectorPath removed
            var itemsToRemove = ListOfIOConnections.Where(b =>
                                                          b.GetPlanName().Equals(planName, StringComparison.OrdinalIgnoreCase)).ToList();

            foreach (var itemToRemove in itemsToRemove)
            {
                ListOfIOConnections.Remove(itemToRemove);
            }
        }
Пример #2
0
        public void RemoveInvalidIOConnections(string planName, string usedIOAddressesInPlan)
        {
            var itemsToCheck = ListOfIOConnections.Where(b =>
                                                         b.ConnectorPath.Length > 0 && b.GetPlanName().Equals(planName, StringComparison.OrdinalIgnoreCase)).ToList();

            string[] arrayUsedIOAddressesInPlan = usedIOAddressesInPlan.Split(new char[] { '|' });
            foreach (var item in itemsToCheck)
            {
                if (!arrayUsedIOAddressesInPlan.Contains <string>(item.Address.UniqueID))
                {
                    item.ConnectorPath = string.Empty;

                    // set dirty flag
                    Dirty = true;
                }
            }
        }
Пример #3
0
        public void RemoveIOConnection(string uniqueID, string connectorPath)
        {
            //lsu 20120410: comparing TargetConnector instead of ConnectorPath.
            //              After allowing moving block over page border, the ConnectorPath of margin connector may change (page number)
            int    iStart          = connectorPath.LastIndexOf('\\', connectorPath.LastIndexOf('\\') - 1);
            string targetConnector = connectorPath.Substring(iStart + 1, connectorPath.Length - 1 - iStart).Trim();

            //lsu 20120524: uniqueness can be assured with plan name
            iStart = connectorPath.IndexOf('\\');
            int    iEnd     = connectorPath.IndexOf('(', iStart + 1);
            string planName = connectorPath.Substring(iStart + 1, iEnd - iStart - 2).Trim();

            var itemsToRemove = ListOfIOConnections.Where(a =>
                                                          a.ConnectorPath.Equals(connectorPath, StringComparison.OrdinalIgnoreCase)).ToList();

            foreach (var item in itemsToRemove)
            {
                ListOfIOConnections.Remove(item);
            }
        }
Пример #4
0
        public bool SetHWConfigFile(string fileName)
        {
            if (proxyOfHWConfig == null)
            {
                return(false);
            }
            if (string.IsNullOrEmpty(fileName))
            {
                return(false);
            }

            try
            {
                IOAddressList newIOAddressList = proxyOfHWConfig.ParseHWConfigFile(fileName);
                Dictionary <string, IOAddress> newIOAddressDic = newIOAddressList.ToDictionary();
                IOAddress[] listOfAvailableIOAddress           = ListOfAvailableIOAddress.ToArray <IOAddress>();

                foreach (var ioAddress in listOfAvailableIOAddress)
                {
                    if (newIOAddressDic.ContainsKey(ioAddress.UniqueID))
                    { // still exist
                        IOAddress newAddress = newIOAddressDic[ioAddress.UniqueID];

                        newIOAddressDic.Remove(ioAddress.UniqueID);

                        if (ListOfAvailableIOAddress.InsertNewIOAddress(newAddress))
                        {
                            if (IOAddressChanged != null && IsAddressUsed(ioAddress.UniqueID))
                            {
                                IOAddressChanged(newAddress.ToString() + " is updated.");
                            }
                        }
                    }
                    else
                    { // removed
                        ListOfAvailableIOAddress.Remove(ioAddress);

                        if (IOAddressChanged != null && IsAddressUsed(ioAddress.UniqueID))
                        {
                            IOAddressChanged(ioAddress.ToString() + " is not valid any more.");
                        }

                        // remove connection(s) of this IOAddress(by UniqueID)
                        var connections = ListOfIOConnections.Where(a =>
                                                                    a.Address.UniqueID == ioAddress.UniqueID);
                        foreach (var conn in connections)
                        {
                            ListOfIOConnections.Remove(conn);
                        }
                    }
                }

                //add new IO addresses into the list
                foreach (var rest in newIOAddressDic.Values)
                {
                    ListOfAvailableIOAddress.InsertNewIOAddress(rest);
                }

                return(true);
            }
            catch (Exception ee)
            {
                Trace.WriteLine("###[" + ee.Message + "]; Exception : " + ee.Source);
                Trace.WriteLine("###" + ee.StackTrace);
            }

            return(false);
        }