I'm attempting to figure out how to do a MVC with a comport that has the ability to loop for my orb.
If I spawn a new thread, terminating may be a pain with an open com when a new request comes in.
Doing the time delay may be hard too. A Thread.sleep would sleep the entire thread. wonder if I could do a timer style event.
my head hurts from work.
code that I have so far:
private static string createPagerBurst(bool EnablePaging)
{
return "~" + Enums.GetName(Enums.TransmissionType.Pager) + ((EnablePaging) ? "F" : "T");
}
private static string createAnimationBurst(Animation animation)
{
return "~" + Enums.GetName(Enums.TransmissionType.Animation) + createFirstByte(animation) + createSecondByte(animation);
}
#region animation data
private static char createFirstByte(Animation animation)
{
return createFirstByte(animation.Color, animation.AnimationStyle);
}
private static char createFirstByte(int color, Enums.AnimationStyle animation)
{
return (Char)Math.Round((double)((color + (37 * (int)animation)) / 94) + 32);
}
private static char createSecondByte(Animation animation)
{
return createSecondByte(animation.Color, animation.AnimationStyle);
}
private static char createSecondByte(int color, Enums.AnimationStyle animation)
{
return (Char)Math.Round((double)((color + (37 * (int)animation)) % 94) + 32);
}
#endregion
public class Animation
{
public int Color
{
get { return _color; }
set { _color = value; }
}
private int _color;
public Enums.AnimationStyle AnimationStyle
{
get { return _animationStyle; }
set { _animationStyle = value; }
}
private Enums.AnimationStyle _animationStyle;
public int TimeDelay
{
get { return _timeDelay; }
set { _timeDelay = value; }
}
private int _timeDelay;
}
and Global.cs:
protected void Application_BeginRequest(Object sender, EventArgs e)
{
string[] requestDispatch = stripBlanks(Request.Url.LocalPath);
}
private static string[] stripBlanks(string localPath)
{
StringCollection sc = new StringCollection();
sc.AddRange(localPath.Split('/'));
for(int i = sc.Count - 1; i >= 0; i--)
if( string.IsNullOrEmpty(sc[i]) )
sc.RemoveAt(i);
string[] temp = new string[sc.Count];
sc.CopyTo(temp, 0);
return temp;
}