示例#1
0
        public void SaveFile()
        {
            // Format data

            string headerLine = "#" + Headers[0] + ',' + Headers[1] + '/';

            List <string> formattedLines = new List <string>()
            {
                headerLine
            };

            foreach (List <object> record in Data)
            {
                formattedLines.Add((string)record[0] + ',' + ((string)record[1]).TrimEnd().TrimEnd(',') + '/');
            }

            if (fileType == FileType.PCK)
            {
                MainDataModel.SavePCKLST(formattedLines);
            }
            else
            {
                MainDataModel.SavePRKLST(formattedLines);
            }
        }
        private void InitializeBaseData()
        {
            // Initialize

            if (fileType == FileType.BMP)
            {
                Headers = new List <string>()
                {
                    "From", "Loc Min", "Loc Max", "Dest Min", "Dest Max", "Route Min", "Route Max"
                };
                Descriptions = new List <string>()
                {
                    "Location of a vehicle to be bumped",
                    "Location of another vehicle to signal bump (min)",
                    "Location of another vehicle to signal bump (max)",
                    "Destination of another vehicle to signal bump (min)",
                    "Destination of another vehicle to signal bump (max)",
                    "Route of another vehicle to signal bump (min)",
                    "Route of another vehicle to signal bump (max)",
                };
            }
            else
            {
                Headers = new List <string>()
                {
                    "From", "Loc Min", "Loc Max", "Dest Min", "Dest Max",
                };
                Descriptions = new List <string>()
                {
                    "Location of a vehicle to be assigned to job",
                    "Location of another vehicle that is closer (min)",
                    "Location of another vehicle that is closer (max)",
                    "Destination of another vehicle that is closer (min)",
                    "Destination of another vehicle that is closer (max)",
                };
            }

            // Read Data
            Data = new ObservableCollection <List <object> >();
            List <List <string> > strData = fileType == FileType.BMP ? MainDataModel.ReadBMPAGV() : MainDataModel.ReadCLSAGV();

            foreach (List <string> strList in strData)
            {
                Data.Add(new List <object>(strList));
            }

            if (Data.Count == 0)
            {
                Data.Add(new List <object>()
                {
                    "0", "0", "0", "0", "0"
                });
                if (fileType == FileType.BMP)
                {
                    Data[0].AddRange(new object[] { "0", "0" });
                }
            }
        }
 public void SaveData()
 {
     if (pndatr == FileType.PND)
     {
         MainDataModel.SavePNDDEFConfig(Fields.ToArray());
     }
     else
     {
         MainDataModel.SaveATRDEFConfig(Fields.ToArray());
     }
 }
        public void SaveFile()
        {
            // Format data

            string headerLine = "#";

            foreach (string s in Headers)
            {
                headerLine += s + ',';
            }

            headerLine  = headerLine.TrimEnd(',');
            headerLine += '/';

            List <string> formattedLines = new List <string>()
            {
                headerLine
            };

            foreach (List <object> record in Data)
            {
                string line = "";
                foreach (string s in record)
                {
                    line += s + ',';
                }

                line  = line.TrimEnd(',');
                line += '/';

                formattedLines.Add(line);
            }

            for (int i = formattedLines.Count - 1; i >= 0; i--)
            {
                if (formattedLines[i][0] == '0')
                {
                    formattedLines.RemoveAt(i);
                }
            }

            if (fileType == FileType.BMP)
            {
                MainDataModel.SaveBMPAGV(formattedLines);
            }
            else
            {
                MainDataModel.SaveCLSAGV(formattedLines);
            }
        }
示例#5
0
        public void InitializeBaseData()
        {
            // Initialize

            if (fileType == FileType.PCK)
            {
                Headers = new List <string>()
                {
                    "From", "Location List"
                };
                Descriptions = new List <string>()
                {
                    "Location of a vehicle to assign to a job",

                    "List of pick locations that the vehicle can be assigned to, separated by commas and ordered by priority." +
                    Environment.NewLine + Environment.NewLine +
                    "To specify a range, use a negative sign for the high loc (i.e. 100,-150 for locations 100 through 150)."
                };
            }
            else // PRK
            {
                Headers = new List <string>()
                {
                    "From", "Location List"
                };
                Descriptions = new List <string>()
                {
                    "Location of a vehicle to be parked",

                    "List of locations that the vehicle can park at, separated by commas and ordered by priority." +
                    Environment.NewLine + Environment.NewLine +
                    "To specify a range, use a negative sign for the high loc (i.e. 100,-150 for locations 100 through 150)."
                };
            }

            // Read Data
            Data = new ObservableCollection <List <object> >();
            List <List <string> > strData = fileType == FileType.PCK ? MainDataModel.ReadPCKLST() : MainDataModel.ReadPRKLST();

            foreach (List <string> strList in strData)
            {
                Data.Add(new List <object>(strList));
            }

            if (Data.Count == 0)
            {
                Data.Add(new List <object>(new object[] { "0", "0" }));
            }
        }
        public void InitializeData()
        {
            // Initialize

            Fields = new ObservableCollection <Field>(pndatr == FileType.PND ? MainDataModel.ReadPNDDEFConfig() : MainDataModel.ReadATRDEFConfig());
        }
        public void InitializeBaseData()
        {
            // Initialize

            #region Headers and Combo Values
            GroupHeaders = new List <string>()
            {
                "Name", "Write Together", "Update Rate", "Trace Mask", "Active"
            };
            GroupDescriptions = new List <string>()
            {
                "The name of the group. Must be unique per OPC server.",

                "\"yes\" indicates that when any item in the group changes," + Environment.NewLine +
                "all items in the group are to be written." + Environment.NewLine +
                "(optional; default is \"no\", i.e., each item is independent)",

                "The rate at which the items are polled, in ms." + Environment.NewLine +
                "(optional; default is \"0\", i.e., the fastest reasonable rate)",

                "log (halwr) reads, writes, and changes. (Ex: trace_mask=\"RWC\")",

                "The active state of the group. Active items are updated" + Environment.NewLine +
                "by the OPC server automatically, and we are notified of their" + Environment.NewLine +
                "changes. (optional; default is \"1\")"
            };

            ItemHeaders = new List <string>()
            {
                "Group", "Access Path", "ID", "Name", "Type", "Access", "Code", "Active"
            };
            ItemDescriptions = new List <string>()
            {
                "The group this item belongs to (see above)",

                "The path that the OPC server uses to find the physical device.",

                "The address on that device that this item refers to.",

                "Only used for logging; has no meaning to OPC.",

                "Used to determine if byte swapping is necessary; has no meaning to OPC." + Environment.NewLine +
                "(optional; must be \"default\" or \"string\".",

                "Used to restrict writing OPC items if they are inputs. Some OPC items" + Environment.NewLine +
                "(e.g., Opto inputs) can be written to without error, but then the GLOBAL" + Environment.NewLine +
                "representation no longer matches the device inputs. Value means read only" + Environment.NewLine +
                "(read), write only (write) or read and write (modify) permissions. (optional;" + Environment.NewLine +
                "must be \"read\", \"write\", or \"modify\". Default is \"modify\".",

                "Used to generate a mapping between OPC items and claimed/released mux in" + Environment.NewLine +
                "the system databases; has no meaning to OPC. Should be a decimal or hex" + Environment.NewLine +
                "value (if hex, prefix with \"0x\"). Optional.",

                "The active state of the item. This is only considered" + Environment.NewLine +
                "when the active state of the group is \"1\", and may be used to" + Environment.NewLine +
                "designate inactive items in an active group. (optional;" + Environment.NewLine +
                "default is \"1\")"
            };

            TypeValues   = new string[] { "default", "string" };
            AccessValues = new string[] { "read", "write", "modify" };

            #endregion

            GroupNames = new ObservableCollection <string>();
            ItemIDs    = new ObservableCollection <string>();
            ItemIDs.Add("NONE");

            OPCConnection = MainDataModel.ReadOPCMGR();

            Groups = new ObservableCollectionWithPropertyChanged <OPCGroup>(OPCConnection.Groups);
            foreach (OPCGroup g in Groups)
            {
                GroupNames.Add(g.name);
            }

            Groups.CollectionChanged += (s, e) =>
            {
                if (e.Action == NotifyCollectionChangedAction.Remove)
                {
                    GroupNames.RemoveAt(e.OldStartingIndex);
                }
                else if (e.Action == NotifyCollectionChangedAction.Add)
                {
                    GroupNames.Insert(e.NewStartingIndex, Groups[e.NewStartingIndex].name);
                }
                else // Property Changed
                {
                    int index = ((NotifyCollectionChangedEventArgs_WithPropertyChanged)e).Index;
                    GroupNames[index] = Groups[index].name;
                }
            };

            Items = new ObservableCollectionWithPropertyChanged <OPCItem>();
            foreach (OPCGroup g in Groups)
            {
                foreach (OPCItem i in g.Items)
                {
                    i.group = g.name;
                    Items.Add(i);
                    ItemIDs.Add(i.id);
                }
            }

            Items.CollectionChanged += (s, e) =>
            {
                if (e.Action == NotifyCollectionChangedAction.Remove)
                {
                    ItemIDs.RemoveAt(e.OldStartingIndex + 1);
                }
                else if (e.Action == NotifyCollectionChangedAction.Add)
                {
                    ItemIDs.Insert(e.NewStartingIndex + 1, Items[e.NewStartingIndex + 1].id);
                }
                else // Property Changed
                {
                    int index = ((NotifyCollectionChangedEventArgs_WithPropertyChanged)e).Index;
                    ItemIDs[index + 1] = Items[index].id;
                }
            };
        }
 public void SaveFile()
 {
     MainDataModel.SaveOPCMGR(OPCConnection);
 }
示例#9
0
        public void InitializeBaseData()
        {
            // Initialize

            Descriptions = new List <string>();
            Headers      = new List <string>();
            Data         = new ObservableCollection <List <object> >();
            Types        = new List <string>();
            ComboValues  = new List <List <string> >();

            // Read Data
            List <Field> fields = new List <Field>(fileType == FileType.PND ? MainDataModel.ReadPNDDEFConfig() : MainDataModel.ReadATRDEFConfig());

            foreach (Field f in fields)
            {
                Headers.Add(f.FieldName);
                Descriptions.Add(f.Description);
                Types.Add(f.Type);
                ComboValues.Add(f.ComboValues);
            }

            List <List <string> > records = fileType == FileType.PND ? MainDataModel.ReadPNDDEF() : MainDataModel.ReadATRDEF();

            foreach (List <string> strData in records)
            {
                if (strData.Count > Headers.Count)
                {
                    for (int i = Headers.Count; i < strData.Count; i++)
                    {
                        Headers.Add($"Unknown{i}");
                        Descriptions.Add($"Unknown{i}");
                        Types.Add("Text");
                    }
                }

                List <object> dataObjs = new List <object>(strData);

                for (int i = 0; i < strData.Count; i++)
                {
                    if (string.Equals(Types[i], "bool", StringComparison.OrdinalIgnoreCase))
                    {
                        dataObjs[i] = string.Equals(strData[i], "1", StringComparison.OrdinalIgnoreCase);
                    }
                }
                Data.Add(dataObjs);
            }

            if (Data.Count == 0)
            {
                List <object> dummyRecord = new List <object>();

                for (int i = 0; i < Headers.Count; i++)
                {
                    dummyRecord.Add(null);
                }

                Data.Add(dummyRecord);
            }

            Data.CollectionChanged += (s, e) => UpdateLocationIDs();

            if (fileType == FileType.PND)
            {
                LocationIDs = new List <int>();
                UpdateLocationIDs();
            }
        }
示例#10
0
        public void SaveFile()
        {
            int[] maxLengths = new int[Headers.Count];

            for (int i = 0; i < Headers.Count; i++)
            {
                maxLengths[i] = Headers[i].Length;
            }

            // Get data into unformatted lines
            List <List <string> > unformattedLines = new List <List <string> >();

            foreach (List <object> record in Data)
            {
                List <string> strList = new List <string>();

                foreach (object obj in record)
                {
                    if (obj is bool)
                    {
                        strList.Add((bool)obj ? "1" : "0");
                    }
                    else if (obj is string)
                    {
                        strList.Add((string)obj);
                    }
                    else
                    {
                        strList.Add("0");
                    }
                }

                for (int i = strList.Count; i < Headers.Count; i++)
                {
                    strList.Add("0");
                }

                unformattedLines.Add(strList);
            }

            // Find max lengths
            foreach (List <string> record in unformattedLines)
            {
                for (int i = 0; i < record.Count; i++)
                {
                    if (record[i].Length > maxLengths[i])
                    {
                        maxLengths[i] = record[i].Length;
                    }
                }
            }

            maxLengths[0]++; // First item should have 1 additional space to line up with header '#' character

            // Format data

            List <string> formattedLines = new List <string>();

            for (int i = 0; i < unformattedLines.Count; i++)
            {
                formattedLines.Add("");
                for (int j = 0; j < maxLengths.Length; j++)
                {
                    formattedLines[i] += unformattedLines[i][j].PadLeft(maxLengths[j]) + ',';
                }

                formattedLines[i] = formattedLines[i].TrimEnd(',') + '/';
            }

            string headerLine = "#";

            for (int i = 0; i < Headers.Count; i++)
            {
                headerLine += Headers[i].PadLeft(maxLengths[i] - 1) + ',';
            }

            headerLine = headerLine.TrimEnd(',') + '/';

            formattedLines.Insert(0, headerLine);

            if (fileType == FileType.PND)
            {
                MainDataModel.SavePNDDEF(formattedLines);
            }
            else
            {
                MainDataModel.SaveATRDEF(formattedLines);
            }
        }