public Task <Enums.FehlerT> Connect(LightingConsole console, CPacket initPacket = null) { Console = console; SKMSync sync = new SKMSync(Steckbrief, SKMType); return(SendPacketAsync(sync)); }
public override byte[] GetDataToSend(LightingConsole console) => new ByteBuffer() .Write((int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds) // Time .Write((short)1) // Count .Write((short)1) // Flags .Write(GetEventInteger(console)) // Event Int .ToArray();
public override IEnumerable <byte[]> GetData(LightingConsole console) => Make( entries, 200, CountShort, (buf, _) => buf.Write(console.BdstNo).Write(subCmd).Write((short)dstReg), (e, buf) => buf.Write(e.FixtureId).WriteShort(e.ParId).Write((short)(e.Value << 8)) );
public override IEnumerable <byte[]> GetData(LightingConsole console) => Make( entries, 230, CountShort, (buf, total) => buf.Write(console.BdstNo).Write((short)0).Write((short)(total + 230 > entries.Length ? 1 : 0)), (sk, buf) => buf.Write(sk.Number).Write((short)-2).Write((short)(sendRange ? 0x0001 : 0)) );
public override IEnumerable <byte[]> GetData(LightingConsole console) => Make( commands, 2, CountShort, (buf, _) => buf.Write(console.BdstNo).Write((short)command), (entry, buf) => buf.Write(entry.Palkenn).Write(entry.Palno) );
public override IEnumerable <byte[]> GetData(LightingConsole console) => Make( entries, 80, CountShort, (buf, _) => buf.WriteShort(console.BdstNo).Write(0), (entry, buf) => buf.Write(entry.MailboxNo).Write(entry.Pad).Write(entry.Job).Write(entry.Par1).Write(entry.Par2) );
public override Enums.Response ProcessPacket(LightingConsole console, int type) { for (int i = Start; i < Start + Count; i++) { console.Stromkreise[i]?.SetDimmer(Data[i - Start]); } return(Enums.Response.OK); }
public override IEnumerable <byte[]> GetData(LightingConsole console) => Make( sks, 200, CountShort, (buf, _) => buf.Write(console.BdstNo).Write(subCmd).Write((short)dstReg), (par, buf) => buf.Write((short)par.Number).WriteShort(0).Write((short)(par.Intensity << 8)) );
public override Enums.Response ProcessPacket(LightingConsole console, int type) { foreach (BTastConfEntry entry in Entries) { console.TastenManager.Add(new Tasten.Taste(entry.Tastnr, entry.Name)); } return(Enums.Response.OK); }
public override Enums.Response ProcessPacket(LightingConsole console, int type) { //console.MLCParameters.Clear(); why tho foreach (ParDefData data in Data) { console.MLCParameters.Add(new Stromkreise.ML.MlcParameter(data.Parno, data.DispMode, data.ParName)); } return(Enums.Response.OK); }
public async Task <FehlerT[]> ExecuteAsync(LightingConsole console) { FehlerT[] fehler = new FehlerT[Steps.Count]; for (int i = 0; i < Steps.Count; i++) { fehler[i] = await Steps[i].ExecuteAsync(console); } return(fehler); }
public void StartAndBlock(LightingConsole console, Action preQ) { string cmd; this.PreQuery = preQ; while (!(cmd = Console.ReadLine()).Equals("end")) { Loop(cmd, console); } }
public void BlockThread(LightingConsole console) { ConsoleKeyInfo info; while ((info = Console.ReadKey(true)).Key != ConsoleKey.Escape) { Macro macro = Macros.Find((x) => x.Key == info.Key); macro?.Execute(console); } }
public override Enums.Response ProcessPacket(LightingConsole console, int type) { if (!console.Paletten.TryGetValue(Enums.GetEnum <MlPal.Flag>(Mlpaltype), out List <MlPal> list)) { return(Enums.Response.BadCmd); } Handle(list, console); return(Enums.Response.OK); }
public void HandleFunction(CFunction func, LightingConsole console) { switch (func.Name) { case "s": { //expected 2 args if (func.Arguments.Count != 2 || !(func.Arguments[0] is CFunction)) { throw new ArgumentException("Expected two Arguments"); } CFunction f = func.Arguments[0] as CFunction; int index = int.Parse(func.Arguments[1].Text); Type t = RegisteredInstanceTypes.Find((x) => x.Name.Equals(f.Name)); if (t is null) { throw new NullReferenceException("Could not find Type"); } ConstructorInfo constructor = t.GetConstructors()[index]; ParameterInfo[] infos = constructor.GetParameters(); object[] args = new object[infos.Length]; for (int i = 0; i < infos.Length; i++) { args[i] = CreateParameters(f.Arguments[i], infos[i]); } object instance = constructor.Invoke(args); PreQuery?.Invoke(); console.QueryAsync(instance as CPacket).Wait(); break; } case "i": { if (func.Arguments.Count != 2) { throw new ArgumentException("Expected two Arguments"); } ushort num = ushort.Parse(func.Arguments[0].Text); byte intensity = byte.Parse(func.Arguments[1].Text); SK sk = console.Stromkreise[num]; sk.Intensity = intensity; PreQuery?.Invoke(); console.QueryAsync(new FixParDimmer(Enums.FixParDst.Current, sk)).Wait(); break; } } }
public override Enums.Response ProcessPacket(LightingConsole console, int type) { //Apply to SK SK sk = console.Stromkreise[Fixture]; if (sk == null) { return(Enums.Response.BadCmd); } if (type == 160 /* SKMON_MLPAR_REMOVE */) { sk.Parameters.Clear(); return(Enums.Response.OK); } // load MLCParams foreach (SelParData par in Parameters) { MlcParameter mlcParameter = console.MLCParameters.Find(x => x.Number == par.Parno); if (mlcParameter == null) { MlcParameter parameter = new MlcParameter(par.Parno, Enums.SelRangeDisp.Normal, par.Parname); console.MLCParameters.Add(parameter); //get info (not loaded yet) console.QueryAsync(new ParSelect(par.Parno)).ConfigureAwait(false); } else { mlcParameter.Name = par.Parname; } MlParameter param = sk.Parameters.Find(inc => inc.ParNo == par.Parno); if (param != null) { param.Value = (par.Val16 & 0xff00) >> 8; param.Display = par.Parval; param.PalName = par.Palname; param.Sk = sk; } else { param = new MlParameter(par.Parname, par.Parno, (par.Val16 & 0xff00) >> 8) { PalName = par.Palname, Display = par.Parname, Sk = sk }; sk.Parameters.Add(param); } } return(Enums.Response.OK); }
public override Enums.Response ProcessPacket(LightingConsole console, int type) { for (int i = 0; i < LampStates.Length /* =256 */; i++) { Taste taste = console.TastenManager.FindByNumber(i); if (taste != null) { taste.State = LampStates[i]; } } return(Enums.Response.OK); }
public override byte[] GetDataToSend(LightingConsole console) { ByteBuffer buffer = new ByteBuffer() .Write((int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds) .Write((short)events.Length).Write((short)1); // Flags (context) foreach (Event e in events) { buffer.Write(e.GetEventInteger(console)); } return(buffer.ToArray()); }
public override byte[] GetDataToSend(LightingConsole console) { byte[] steckbrief = new byte[10]; for (int i = 0; i < 10; i++) { steckbrief[i] = (flags & (1 << i)) != 0 ? (byte)1 : (byte)0; } steckbrief[0] = skmType; return (action == Action.BEGIN ? new ByteBuffer().Write((short)action).WriteShort(console.BdstNo).WriteShort(10).Write(steckbrief).ToArray() : new ByteBuffer().Write((short)action).WriteShort(console.BdstNo).WriteShort(0) /*count = 0 -> no array needed { .Write(steckbrief) } */.ToArray()); }
public static async Task <Enums.FehlerT> FunctionIntensity(LightingConsole console, Func <short, byte> func, params short[] sks) { return(await console.QueryAsync( new FixParUnsafe( sks, Enumerable .Range(0, sks.Length) .Select( index => func((short)index)) .ToArray() ) )); }
public override IEnumerable <byte[]> GetData(LightingConsole console) => Make(entries, 30, CountShort, (buf, _) => buf .Write(console.BdstNo) .Write(subcmd) .Write(editcmd), (entry, buf) => buf .Write(entry.Palkenn) .Write(entry.PalNo) .Write(entry.PalMask) .Write(entry.Param) .Write(entry.SKSelect) .Write(entry.Smode) .Write(entry.Text, 31) .Write((byte)0));
public override Enums.Response ProcessPacket(LightingConsole console, int type) { Vorstellung vst = console.Vorstellungen.Find(x => VstNum == x.Number); if (!(vst is null)) { return(Enums.Response.OK); } vst = new Vorstellung((ushort)VstNum); console.Vorstellungen.Add(vst); return(Enums.Response.OK); }
public override Enums.Response ProcessPacket(LightingConsole console, int type) { for (int i = Start; i < Start + Count; i++) { if (i >= console.Stromkreise.Length) { break; } SK reg = console.Stromkreise[i]; reg?.SetDimmer(Data[i - Start]); } return(Enums.Response.OK); }
public override byte[] GetDataToSend(LightingConsole console) { ByteBuffer buffer = new ByteBuffer().WriteShort(console.BdstNo).WriteShort(subCmd).WriteShort((short)(config?.Length ?? 0)); if (config == null) { return(buffer.ToArray()); } foreach (bool b in config) { buffer.WriteShort((short)(b ? 1 : 0)); } return(buffer.ToArray()); }
public void Execute(LightingConsole console, bool wait = false) { foreach (MacroStep step in Steps) { if (wait) { step.ExecuteAsync(console).Wait(); } else { step.ExecuteAsync(console).ConfigureAwait(false); } } }
public void Loop(string cmd, LightingConsole console) { CArgument a = ParseString(cmd); if (a is CText) { throw new Exception("No Function in Command"); } else { CFunction func = a as CFunction; HandleFunction(func, console); } }
public override byte[] GetDataToSend(LightingConsole console) { ByteBuffer buf = new ByteBuffer().Write(console.BdstNo).Write(SUB_CMD).Write((short)Dst); if (sks != null) { buf.WriteShort(1); sks.Sort((n1, n2) => { if (n1.Number > n2.Number) { return(-1); } return(n2.Number > n1.Number ? 1 : 0); }); // assume they are all on the same line buf.WriteShort(1); int ptr = 0; for (int i = 0; i < 512; i++) { if (sks.Count > ptr && sks[ptr].Number == i + 1) { buf.Write(sks[ptr].Intensity); ptr++; } else { buf.Write((byte)0); } } } else if (data != null) { buf.Write(data.Count); for (int i = 0; i < data.Count; i++) { buf.WriteShort((short)i); buf.Write(data[i]); } } else { buf.WriteShort(0); } return(buf.ToArray()); }
public override Enums.Response ProcessPacket(LightingConsole console, int type) { switch (Enums.GetEnum <Enums.Type>(type)) { case Enums.Type.AZ_IST: console.RegIST.Text = LineText; console.RegIST.Aw = Angewaehlt; break; case Enums.Type.AZ_ZIEL: console.RegZIEL.Text = LineText; console.RegZIEL.Aw = Angewaehlt; break; case Enums.Type.AZ_VOR: console.RegVOR.Text = LineText; console.RegVOR.Aw = Angewaehlt; break; default: throw new ArgumentException("type != AZ"); } return(Enums.Response.OK); }
public override IEnumerable <byte[]> GetData(LightingConsole console) { return(Make( infos.ToArray(), 200, CountShort, (buf, _) => buf.Write((short)console.Bedienstelle).Write((short)FixPar.ValueType.ABS).Write((short)Enums.FixParDst.Current), (par, buf) => { buf .Write(par.num) .WriteShort(0) .Write((short)(par.val << 8)); } )); }
public override IEnumerable <byte[]> GetData(LightingConsole console) { return(Make( infos.ToArray(), 200, CountShort, (buf, _) => buf.Write((short)console.Bedienstelle).Write((short)valueType).Write((short)dstReg), (par, buf) => { buf .Write(par.SkNum) .Write(par.Par) .Write((short)(par.Val << 8)); } )); }