示例#1
0
 public void CloneFrom(VizChannel source)
 {
     if (color == 0)
     {
         color = source.color;
     }
     if (myName.Length == 0)
     {
         ChangeName(source.Name);
     }
     if (this.parentVisualization == null)
     {
         this.parentVisualization = source.parentVisualization;
     }
     SubType  = source.SubType;
     SubParam = source.SubParam;
     if (output.deviceType == DeviceType.None)
     {
         output.deviceType = source.output.deviceType;
         output.circuit    = source.output.circuit;
         output.network    = source.output.network;
         output.unit       = source.output.unit;
     }
     for (int c = 0; color < 5; color++)
     {
         colors[color] = source.colors[c];
     }
     LED = source.LED;
 }
示例#2
0
 public void CloneTo(VizChannel destination)
 {
     if (destination.color == 0)
     {
         destination.color = color;
     }
     if (destination.Name.Length == 0)
     {
         destination.ChangeName(myName);
     }
     if (destination.parentVisualization == null)
     {
         destination.parentVisualization = this.parentVisualization;
     }
     destination.SubType  = SubType;
     destination.SubParam = SubParam;
     if (destination.output.deviceType == DeviceType.None)
     {
         destination.output.deviceType = output.deviceType;
         destination.output.circuit    = output.circuit;
         destination.output.network    = output.network;
         destination.output.unit       = output.unit;
     }
     for (int c = 0; c < 5; c++)
     {
         destination.colors[c] = colors[c];
     }
     destination.LED = LED;
 }
示例#3
0
		} // end Clear Sequence

		public VizChannel ParseVizChannel(string lineIn)
		{
			VizChannel vch = new VizChannel("");
			//vch.SetParentViz(this);
			vch.SetIndex(VizChannels.Count);
			VizChannels.Add(vch);
			vch.Parse(lineIn);
			return vch;
		}
示例#4
0
        public IMember Clone(string newName)
        {
            // See Also: Clone(), CopyTo(), and CopyFrom()
            VizChannel vch = new VizChannel(newName, utils.UNDEFINED);

            //vch.myCentiseconds = myCentiseconds;
            //vch.myIndex = myIndex;
            //vch.VizID = VizID;
            //vch.myAltVizID = myAltVizID;
            vch.imSelected = imSelected;
            vch.color      = color;
            vch.output     = output.Clone();
            vch.SubType    = SubType;
            vch.SubParam   = SubParam;
            vch.LED        = LED;
            for (int c = 0; c < 5; c++)
            {
                vch.colors[c] = colors[c];
            }
            return(vch);
        }
示例#5
0
		//public List<Prop> Props = new List<Prop>();

		public int ReadVisualizationFile(string existingFileName)
		{
			errorStatus = 0;
			string lineIn; // line read in (does not get modified)
			string xmlInfo = "";
			int li = utils.UNDEFINED; // positions of certain key text in the line
																//Track trk = new Track();
			// const string ERRproc = " in Visualization4:ReadVisualizationFile(";
			// const string ERRgrp = "), on Line #";
			// const string ERRitem = ", at position ";
			// const string ERRline = ", Code Line #";
			//SequenceType st = SequenceType.Undefined;
			string creation = "";
			DateTime modification;

			VizChannel lastVizChannel = null;
			//Prop lastProp = null;
			DrawObject lastDrawObject = null;

			Clear(true);

			info.file_accessed = File.GetLastAccessTime(existingFileName);
			info.file_created = File.GetCreationTime(existingFileName);
			info.file_saved = File.GetLastWriteTime(existingFileName);



			//try
			//{
			StreamReader reader = new StreamReader(existingFileName);

			// Check for items in the order from most likely item to least likely
			// Effects, Channels,  RGBchannels, Groups, Tracks...

			// Sanity Check #1A, does it have ANY lines?
			if (!reader.EndOfStream)
			{
				lineIn = reader.ReadLine();
				// Sanity Check #2, is it an XML file?
				li = lineIn.Substring(0, 6).CompareTo("<?xml ");
				if (li != 0)
				{
					errorStatus = 101;
				}
				else
				{
					xmlInfo = lineIn;
					// Sanity Check #1B, does it have at least 2 lines?
					if (!reader.EndOfStream)
					{
						lineIn = reader.ReadLine();
						// Sanity Check #3, is it a visualization?
						//li = lineIn.IndexOf(STARTvisualization);
						li = utils.ContainsKey(lineIn, STARTvisualization);
						if (li != 0)
						{
							errorStatus = 102;
						}
						else
						{
							info = new Info(null, lineIn);
							creation = info.createdAt;

							// Save this for later, as they will get changed as we populate the file
							modification = info.lastModified;
							info.filename = existingFileName;

							myName = Path.GetFileName(existingFileName);
							info.xmlInfo = xmlInfo;
							// Sanity Checks #4A and 4B, does it have a 'SaveFileVersion' and is it '14'
							//   (SaveFileVersion="14" means it cane from LOR Sequence Editor ver 4.x)
							if (info.saveFileVersion != 3)
							{
								errorStatus = 114;
							}
							else
							{
								// All sanity checks passed
								// * PARSE LINES
								while ((lineIn = reader.ReadLine()) != null)
								{
									lineCount++;
									//try
									//{
									//! DrawPoints
									//li = lineIn.IndexOf(STARTdrawPoint);
									li = utils.ContainsKey(lineIn, STARTdrawPoint);
									if (li > 0)
									{
										//TODO Save It!
									}
									else // Not a DrawPoint
									{
										//! DrawObjects
										//li = lineIn.IndexOf(STARTdrawObject);
										li = utils.ContainsKey(lineIn, STARTdrawObject);
										if (li > 0)
										{
										//TODO: Save it!	
										lastDrawObject = ParseDrawObject(lineIn);
										}
										else // Not a DrawObject
										{
											//! Viz Channel
											//li = lineIn.IndexOf(STARTvizChannel);
											li = utils.ContainsKey(lineIn, STARTvizChannel);
											if (li > 0)
											{
												lastVizChannel = ParseVizChannel(lineIn);
												lastVizChannel.Parent = lastDrawObject;
												if (lastDrawObject.redChannel == null)
												{
													if (lastVizChannel.VizID == 1)
													{
														lastDrawObject.subChannel = lastVizChannel;
													}
													else
													{
														// Error Condition, unexpected
														System.Diagnostics.Debugger.Break();
													}
												}
												else
												{
													if (lastDrawObject.grnChannel == null)
													{
														if (lastVizChannel.VizID == 2)
														{
															lastDrawObject.isRGB = true;
															lastDrawObject.redChannel.rgbChild = RGBchild.Red;
															lastDrawObject.grnChannel = lastVizChannel;
															lastDrawObject.grnChannel.rgbChild = RGBchild.Green;
														}
														else
														{
															// Error Condition
															System.Diagnostics.Debugger.Break();
														}
													}
													else
													{
														if (lastDrawObject.bluChannel == null)
														{
															if (lastVizChannel.VizID == 3)
															{
																lastDrawObject.bluChannel = lastVizChannel;
																lastDrawObject.bluChannel.rgbChild = RGBchild.Blue;
															}
															else
															{
																// Error Condition
																System.Diagnostics.Debugger.Break();
															}
														}
														else
														{
															// Error Condition
															System.Diagnostics.Debugger.Break();
														} // bluChannel null
													} // grnChannel null
												} // redChannel null
											} // Is it a Viz Channel? (or not?)
											else  // Not a Viz Channel
											{
												//! Samples
												//li = lineIn.IndexOf(STARTsample);
												li = utils.ContainsKey(lineIn, STARTsample);
												if (li > 0)
												{
													//TODO Save It!
											}
												else // Not a Sample
												{
													//! Assigned Channel Groups
													//li = lineIn.IndexOf(STARTassignedChannelsGroup);
													li = utils.ContainsKey(lineIn, STARTassignedChannelsGroup);
													if (li > 0)
													{
														//TODO Collect channels in group
													}
													else // Not an Assigned Channels Group
													{
														//! DrawPoint Groups
														//li = lineIn.IndexOf(STARTdrawPointsGroup);
														li = utils.ContainsKey(lineIn, STARTdrawPointsGroup);
														if (li > 0)
														{
															//TODO: Collect DrawPoints in group
														} // end if a track
														else // not a track
														{
														} // end Track (or not)
													} // end Track Items (or not)
												} // end ChannelGroup (or not)
											} // end RGBchannel (or not)
										} // end regular Channel (or not)
										} // end timing (or not)
										/*
							} // end 2nd Try
									catch (Exception ex)
									{
										StackTrace st = new StackTrace(ex, true);
										StackFrame sf = st.GetFrame(st.FrameCount - 1);
										string emsg = ex.ToString();
										emsg += ERRproc + existingFileName + ERRgrp + lineCount.ToString() + ERRitem + li.ToString();
										emsg += ERRline + sf.GetFileLineNumber();
#if DEBUG
										System.Diagnostics.Debugger.Break();
#endif
										utils.WriteLogEntry(emsg, utils.LOG_Error, Application.ProductName);
									} // end catch
									*/
								} // end while lines remain
							} // end SaveFileVersion = 14

							// Restore these to the values we captured when first reading the file info header
							info.createdAt = creation;
							info.lastModified = info.file_saved;
							dirty = false;
							//Members.ReIndex();
						} // end second line is sequence info
					} // end has a second line
				} // end first line was xml info
			} // end has a first line


			reader.Close();
			/*
		} // end try
			catch (Exception ex)
			{
				StackTrace st = new StackTrace(ex, true);
				StackFrame sf = st.GetFrame(st.FrameCount - 1);
				string emsg = ex.ToString();
				emsg += ERRproc + existingFileName + ERRgrp + "none";
				emsg += ERRline + sf.GetFileLineNumber();
#if DEBUG
				System.Diagnostics.Debugger.Break();
#endif
				utils.WriteLogEntry(emsg, utils.LOG_Error, Application.ProductName);
			} // end catch
			*/


			if (errorStatus <= 0)
			{
				info.filename = existingFileName;
				//! for debugging
				//string sMsg = summary();
				//MessageBox.Show(sMsg, "Summary", MessageBoxButtons.OK, MessageBoxIcon.Information);
			}

			return errorStatus;
		} // end ReadSequenceFile