public LorImport(string filename)
{
var deserializer = new XmlSerializer(typeof(LMS.sequence));
LMS.sequence sequence;
using (TextReader textReader = new StreamReader(filename))
{
sequence = (LMS.sequence)deserializer.Deserialize(textReader);
}
this.eventPeriodInMilliseconds = 50;
this.effectsPerChannel = (int)(sequence.channels.Max(x => x.centiseconds) * 10 / this.eventPeriodInMilliseconds);
foreach (var channel in sequence.channels)
{
if (channel.deviceType != null &&channel.deviceType != "LOR")
{
log.Warn("Not supporting device type {0} yet", channel.deviceType);
continue;
}
var channelIdentity = new UnitCircuit(channel.unit, channel.circuit);
AddChannelData(channelIdentity, new ChannelData(channel.name));
var channelEffectData = new byte[this.effectsPerChannel];
for (int pos = 0; pos < this.effectsPerChannel; pos++)
{
long centiSeconds = pos * this.eventPeriodInMilliseconds / 10;
if (channel.effect != null)
{
foreach (var effect in channel.effect)
{
if (effect.startCentisecond > centiSeconds)
break;
if (centiSeconds >= effect.startCentisecond && centiSeconds < effect.endCentisecond)
{
channelEffectData[pos] = (byte)(short.Parse(effect.intensity) * 255 / 100);
break;
}
}
}
}
effectDataPerChannel[channelIdentity] = channelEffectData;
}
}