コード例 #1
0
        #pragma warning restore
        #endregion fields & pins

        //called when data for any output pin is requested
		public void Evaluate(int SpreadMax)
		{
			if (!FTeensy.IsChanged && !FWire.IsChanged && !FStripe.IsChanged) return;
			
			SpreadMax = FTeensy.SliceCount;
			FOrderedStripe.SliceCount = FID.SliceCount = SpreadMax;

			Message m = new Message();
			for (int i = 0; i < SpreadMax; i++) {
				FID[i].SliceCount = 0;
				FOrderedStripe[i].SliceCount = 0;
				
				string id = (string)FTeensy[i]["start"][0];

				while (id != "none") {
//					FLogger.Log(LogType.Debug, id);
					FID[i].Add(id);

					var stripes = 
						from s in FStripe
						where s["ID"][0].Equals(id)
						select s;
					
					FOrderedStripe[i].Add(stripes.First());
					
					var result = 
						from w in FWire
						where w["end"][0].Equals(id) // wires are somehow reversed. sorry 
						select w;				
					
					if (result.Count() == 0) {
						id = "none";
					}
					else {
						Message next = result.First();
						id = (string) next["start"][0];
					}
				}
					
			}
			
			FID.Flush();

			
			
			
			FOrderedStripe.Flush();
			
		}
コード例 #2
0
ファイル: Message.cs プロジェクト: michael-burk/Stimmen
        public static Message FromOSC(Stream stream, string messagePrefix = "OSC", int contractAddress = 1)
        {
            MemoryStream ms = new MemoryStream();
            stream.Position = 0;
            stream.CopyTo(ms);
            byte[] bytes = ms.ToArray();
            int start = 0;
            OSCBundle bundle = OSCBundle.Unpack(bytes, ref start, (int)stream.Length);

            Message message = new Message();

            //			yet unsupported:
            //			Message.TimeStamp = DateTime.FromFileTime(bundle.getTimeStamp());

            foreach (OSCMessage m in bundle.Values) {
                SpreadList sl = new SpreadList();
                sl.AssignFrom(m.Values); // does not clone implicitly

                string oldAddress = m.Address;
                while (oldAddress.StartsWith("/")) oldAddress = oldAddress.Substring(1);
                while (oldAddress.EndsWith("/")) oldAddress = oldAddress.Substring(0, oldAddress.Length-1);

                string[] address = oldAddress.Split('/');

                contractAddress = address.Length > contractAddress ? contractAddress : address.Length - ((messagePrefix.Trim() == "")? 1 : 0);
                string attribName = "";
                for (int i = address.Length - contractAddress ; i < address.Length; i++)
                {
                    attribName += ".";
                    attribName += address[i];
                    address[i] = "";
                }
                attribName = attribName.Substring(1);

                string messageAddress = "";
                foreach (string part in address) {
                    if (part.Trim() != "") messageAddress += "."+part;
                }
                if (messagePrefix.Trim() == "") message.Address = messageAddress.Substring(1);
                    else message.Address = messagePrefix + messageAddress;

                message[attribName] = sl;

            }
            return message;
        }
コード例 #3
0
ファイル: Message.cs プロジェクト: michael-burk/Stimmen
        public object Clone()
        {
            Message m = new Message();
            m.Address = Address;
            m.TimeStamp = TimeStamp;

            foreach (string name in MessageData.Keys) {
                SpreadList list = MessageData[name];
                m.Add(name, list.Clone());

                // really deep cloning
                try {
                    for(int i =0;i<list.Count;i++) {
                        list[i] = ((ICloneable)list[i]).Clone();
                    }
                } catch (Exception err) {
                    err.ToString(); // no warning
                    // not cloneble. so keep it
                }
            }

            return m;
        }