internal void Load(BinaryReader br) { int ver = br.ReadInt32(); int count = br.ReadInt32(); lock (this) { while (count-- > 0) { string name = br.ReadString(); SoftCmd cmd = new SoftCmd(); cmd.Load(br); Cmds.Add(name, cmd); } count = br.ReadInt32(); while (count-- > 0) { ulong user = br.ReadUInt64(); Inbox inb = new Inbox(); inb.Load(br); Msgs.Add(user, inb); } ShowChanges = br.ReadBoolean(); count = br.ReadInt32(); while (count-- > 0) { string name = br.ReadString(); string value = br.ReadString(); Vars.Add(name, value); } SetLanguage(br.ReadString()); MusicChannel = ver >= 1 ? br.ReadString() : ""; CommandPrefix = ver >= 2 ? br.ReadString() : ">"; } }
internal IObservable <byte[]> RequestCmd(Cmds cmd, short len) { byte[] data = new byte[65]; data[1] = (byte)cmd; return(this.WriteData(data) .Retry(10) .Catch(delegate(SudDisconnectedException ex) { return Observable.Empty <bool>(); }) .Where(x => x) .SelectMany( this.ReadCmd(cmd, len) ) .Timeout(TimeSpan.FromSeconds(10), this.WriteData(data) .Catch(delegate(SudDisconnectedException ex) { return Observable.Empty <bool>(); }) .Where(x => x) .Do(x => log.Info("3 Timeout on cmd {0}", cmd)) .Retry(10).SelectMany( this.ReadCmd(cmd, len) )) .Catch <byte[], Exception>(x => { ; return Observable.Empty <byte[]>(); }) .Take(1)); }
public bool Creat() { Cmds.Clear(); string setting = allow + " ssid=\"" + Name + "\" key=" + Password; if (Name.Length > 0) { if (Password.Length < 8 || Password.Length > 12) { return(false); } Cmds.Add(setting); Cmds.Add(show); try { Runcmd(); //if (string.IsNullOrEmpty(IP)) //{ // IP = "192.168.196.1"; //} return(true); } catch (Exception) { return(false); } } else { throw new FormatException("The password length can not be less than 8 more than 12"); } }
private void InternalReadLoop() { while (true) { if (cancelInternalThread) { CloseDevice(); log.Info("Internal loop closed"); this.IsWorking = false; return; } byte[] data = this.ReadData(1000); UInt16 cmd = (UInt16)(data[1] << 0x08 | data[2]); if (data[1] == 0x88) { Cmds c = (Cmds)((byte)(cmd)); sudReadCmd.OnNext(new Tuple <Cmds, byte[]>(c, data.Skip(3).ToArray())); } else { if (cmd == 0x00) { CloseDevice(); this.IsWorking = false; log.Info("Internal loop closed"); return; } switch (cmd) { case 0x01: { SudReading rawReading = new SudReading(); rawReading.SetContent(data.Skip(3).Take(rawReading.Length).ToArray()); sudReading.OnNext(rawReading); break; } case 0x02: { SudLightMeter rawLightMeter = new SudLightMeter(); rawLightMeter.SetContent(data.Skip(3).Take(rawLightMeter.Length).ToArray()); lmReading.OnNext(rawLightMeter); break; } default: { break; } } } } }
public IObservable <byte[]> ReadCmd(Cmds cmd, short len) { return(sudReadCmd .Where(r => r.Item1 == cmd) .Timeout(new TimeSpan(0, 0, 10)) .Where(r => r != null) .Select(r => r.Item2.Take(len).ToArray() ).Catch <byte[], TimeoutException>(x => Observable.Empty <byte[]>())); }
internal IObservable <bool> ReadCmd(Cmds cmd) { return(sudReadCmd .Where(r => r.Item1 == cmd) .Timeout(new TimeSpan(0, 0, 10)) .Where(x => x != null && x.Item2 != null) .Select(r => (r.Item2[0] == 1) ).Catch <bool, TimeoutException>(x => Observable.Return <bool>(false))); }
private void Disallow() { string setting = disallow; Cmds.Clear(); Cmds.Add(setting); try { Runcmd(); } catch { } }
public ObservableCollection <Command> GetActionsCmds() { if (Cmds != null) { IEnumerable <Command> results = Cmds.Where(c => c.Type == "action"); return(new ObservableCollection <Command>(results)); } else { return(new ObservableCollection <Command>()); } }
public ObservableCollection <Command> GetVisibleCmds() { if (Cmds != null) { IEnumerable <Command> results = Cmds.Where(c => c.IsVisible == true && c.LogicalId != null); return(new ObservableCollection <Command>(results)); } else { return(new ObservableCollection <Command>()); } }
String MakeCmd(int id, Cmds cmd) { StringBuilder sb = new StringBuilder(); sb.Append(@"<input type=""hidden"" name=""id"" value=""" + id.ToString() + @"""> "); sb.Append(@"<input type=""hidden"" name=""cmd"" value=""" + ((int)cmd).ToString() + @""" > "); sb.Append(@"<input type=""hidden"" name=""key"" value=""" + Server.Instance.GetKey() + @"""> "); String tmp = sb.ToString();// " /?id=" + id.ToString() + "&" + "cmd=" + cmd.ToString(); return(tmp); }
private bool setWifiIP(string wifiAdapter, string ip) { string IPSetting = setIP1 + wifiAdapter + "\" static " + ip; Cmds.Clear(); Cmds.Add(IPSetting); try { Runcmd(); return(true); } catch (Exception) { return(false); } }
public AssIntellisenseViewModel() { try { Cmds = AssDocument.DocumentDictionary.Keys.ToList(); Cmds.Sort(); } catch (Exception) { MessageBox.Show("Ass document file lost."); Environment.Exit(-1); } RaisePropertyChanged("Cmds"); this.Index = 0; }
/// <summary> /// запрос актуального номера рулока. /// в качестве аргумента задается номер пользовательского сообщения /// </summary> public double reqActualNum(byte numUM) { bool isRec = false; double d = 0; int beginUm = 0; int dataCount = 0; Send(Cmds.getActualUmCmd(numUM)); isRec = Receive(ref readBuff); if (!(readBuff[2] == 0x9d)) { isRec = Receive(ref readBuff); } if (readBuff[1] == 0x04 && readBuff[2] == 0x9d) { dataCount = readBuff[4] - 2; beginUm = 8; } byte[] b = new byte[dataCount]; for (int i = 0; i < dataCount; i++) { b[i] = readBuff[beginUm + i]; } string s = System.Text.Encoding.UTF8.GetString(b); if (isRec) { d = Convert.ToDouble(s); } return(d); }
public bool StopAp() { string setting = stop; Cmds.Clear(); Cmds.Add(setting); try { Runcmd(); WiFiStatus = WiFiStatus.Stop; return(true); } catch { return(false); } }
public bool StartAp() { string setting = start; Cmds.Clear(); Cmds.Add(setting); try { Runcmd(); WiFiStatus = WiFiStatus.Running; return(true); } catch (Exception) { return(false); } }
private void button1_Click(object sender, EventArgs e) { //RF680_Connect.Math r = new RF680_Connect.Math(); //Console.WriteLine(r.Add(3, 5)); //Console.WriteLine( RF680_Connect.Cmds.HostGreet("Hallo")); logger.Info("´Button 1 klicked"); string IP = "141.79.224.84"; int port = 10001; _Client = new TcpClient(IP, port); _nwStream = _Client.GetStream(); // connect established _Receiver = new Receiver(_nwStream); // _Receiver.DataReceived += OnDataReceived; { // Greeting SendCmd(_nwStream, Cmds.HostGreet(id)); } }
public static Cmd GetCommand(Cmds instruction) { Cmd cmd = instruction switch { Cmds.moo => new Cmd0moo(), Cmds.mOo => new Cmd1mOo(), Cmds.moO => new Cmd2moO(), Cmds.mOO => new Cmd3mOO(), Cmds.Moo => new Cmd4Moo(), Cmds.MOo => new Cmd5MOo(), Cmds.MoO => new Cmd6MoO(), Cmds.MOO => new Cmd7MOO(), Cmds.OOO => new Cmd8OOO(), Cmds.MMM => new Cmd9MMM(), Cmds.OOM => new Cmd10OOM(), Cmds.oom => new Cmd11oom(), _ => throw new ArgumentOutOfRangeException() }; return(cmd); } }
static int Main(string[] args) { try { var config = new Config(); var cmds = new Cmds(config); if (cmds.Run(args)) { return 0; } else { return 1; } } catch (Exception ex) { Console.WriteLine("Unexpected error"); Console.WriteLine(ex.ToString()); return -1; } }
internal IObservable <TResult> ReadCmd <TResult>(Cmds cmd) where TResult : BaseField, new() { return(sudReadCmd .Where(r => r.Item1 == cmd ) .Timeout(new TimeSpan(0, 0, 10)) .Select(r => { TResult x = new TResult(); x.SetContent(r.Item2.Take(x.Length)); return x; } ) .Catch <TResult, Exception>(x => { log.Warn("Driver Fail CMD"); DriverFailure++; return Observable.Empty <TResult>(); }) .Take(1)); }
public override void OnStartLocalPlayer() { base.OnStartClient(); if (isLocalPlayer) { i = this; } if (isServer) { foreach (GameObject t in TileManager.instance.tileIDs) { int val = UnityEngine.Random.Range(0, 100); if (val > 90) { Cmds.i.CmdBuildRock(t); } else if (val > 70) { Cmds.i.CmdBuildTree(t); } } } }
internal IObservable <TReturn> RequestCmd <TReturn>(Cmds cmd, byte[] data) where TReturn : BaseField, new() { return(this.WriteData(data) .Catch(delegate(SudDisconnectedException ex) { return Observable.Empty <bool>(); }) .Retry(10) .Where(x => x) .SelectMany(x => this.ReadCmd <TReturn>(cmd)) .Timeout(TimeSpan.FromSeconds(10), this.WriteData(data) .Catch(delegate(SudDisconnectedException ex) { return Observable.Empty <bool>(); }) .Do(x => log.Info("1 Timeout on cmd {0}", cmd)) .Retry(10) .SelectMany( this.ReadCmd <TReturn>(cmd) ) ) .Take(1)); }
public Item(Cmds cmd, Json.Value json) { Cmd = cmd; Json = json; }
public Raw(Cmds cmd, Json.Value value) { Cmd = cmd; Value = value; }
public CmdItem(Cmds type, string name, CmdParamTypes[] paramList = null) { Type = type; Name = name; ParamList = paramList; }
public CmdItem(Cmds type, string name, CmdParamTypes paramType) { Type = type; Name = name; ParamList = new CmdParamTypes[] { paramType }; }
public override string ToString() => $"{Cmds.String(" ").PadRight(10)}\t{Help}";