static void Main(String[] args) { StateStore.Start("Start code"); BeagleBone.Initialize(SystemMode.DEFAULT, true); BBBPinManager.AddMappingPWM(BBBPin.P9_14); BBBPinManager.ApplyPinSettings(BBBPinManager.ApplicationMode.APPLY_IF_NONE); IPWMOutput OutA = PWMBBB.PWMDevice1.OutputA; OutA.SetFrequency(50); OutA.SetOutput(0f); OutA.SetEnabled(true); float t = 0.1f; while (t < .9f) { OutA.SetOutput(t); t += 0.0001f; } while (t > .1f) { OutA.SetOutput(t); t -= 0.0001f; } OutA.Dispose(); }
private TableSource CreateTableSource(TableInfo tableInfo, bool temporary) { lock (commitLock) { try { int tableId = NextTableId(); // Create the object. var storeSystem = StoreSystem; if (temporary) { storeSystem = tempStoreSystem; } var source = new TableSource(this, storeSystem, LargeObjectStore, tableId, tableInfo.TableName.FullName); source.Create(tableInfo); tableSources.Add(tableId, source); if (!temporary) { MarkUncommitted(tableId); StateStore.Flush(); } // And return it. return(source); } catch (IOException e) { throw new InvalidOperationException(String.Format("Unable to create source for table '{0}'.", tableInfo.TableName), e); } } }
public ImageViewModel( GrabService grabService, ZoomService zoomService, InspectService inspectService, StateStore stateStore, CoreConfig coreConfig, CancellationToken token) { StateStore = stateStore; _coreConfig = coreConfig; SubResults = new ObservableCollection <SubResultWrapper>(); BindingOperations.EnableCollectionSynchronization(SubResults, new object()); grabService.ImageGrabbed += ImageGrabbed; ZoomService = zoomService; ZoomFitCommand = new DelegateCommand(ZoomFit); ZoomInCommand = new DelegateCommand(ZoomIn); ZoomOutCommand = new DelegateCommand(ZoomOut); inspectService.Inspected += Inspected; _pipeLine = new SinglePipeLine <GrabInfo>(info => DrawImage(info), -1, true); _pipeLine.Run(token); }
public void SetStorage(object provider, object storeValue, System.Reflection.PropertyInfo pi, ResourceOperationContext context) { StateStore state = (StateStore)storeValue; var obj = pi.GetValue(provider); state.Restore(obj); }
public static void InitBeagleBone() { StateStore.Start("MainRover"); BeagleBone.Initialize(SystemMode.NO_HDMI, true); PinConfig(); Sensors = new List <ISensor>(); try { //Sensors.Add(new BNO055(I2CBBB.I2CBus2)); //Sensors.Add(new MTK3339(UARTBBB.UARTBus4)); } catch (Exception e) { Log.Output(Log.Severity.ERROR, Log.Source.SENSORS, "Failed to initalize sensors (gps and/or mag)"); Log.Exception(Log.Source.SENSORS, e); } /* * // Add back in when limit switch is complete * LimitSwitch Switch = new LimitSwitch(new DigitalInBBB(Pins.SteeringLimitSwitch)); * Switch.SwitchToggle += (object sender, LimitSwitchToggle e) => Console.WriteLine("PRESSED!"); * Sensors.Add(Switch); */ foreach (ISensor Sensor in Sensors) { if (Sensor is MTK3339) { previousCoords = ((MTK3339)Sensor).GetCoords(); } } }
internal TableSource CopySourceTable(TableSource tableSource, IIndexSet indexSet) { lock (commitLock) { try { // The unique id that identifies this table, int tableId = NextTableId(); var sourceName = tableSource.SourceName; // Create the object. var masterTable = new TableSource(this, StoreSystem, LargeObjectStore, tableId, sourceName); masterTable.CopyFrom(tableId, tableSource, indexSet); // Add to the list of all tables. tableSources.Add(tableId, masterTable); // Add this to the list of deleted tables, MarkUncommitted(tableId); // Commit this StateStore.Flush(); // And return it. return(masterTable); } catch (IOException e) { throw new Exception(String.Format("Unable to copy source table '{0}' because of an error.", tableSource.TableInfo.TableName), e); } } }
private void ReadVisibleTables() { lock (commitLock) { var tables = StateStore.GetVisibleList(); // For each visible table foreach (var resource in tables) { var tableId = resource.TableId; var sourceName = resource.SourceName; // TODO: add a table source type? // Load the master table from the resource information var source = LoadTableSource(tableId, sourceName); if (source == null) { throw new InvalidOperationException(String.Format("Table {0} was not found.", sourceName)); } source.Open(); tableSources.Add(tableId, source); } } }
static void Main(string[] args) { StateStore.Start("ArmMaster"); SetupBeagleboneAndPins(); SetupClient(); MotorControl.Initialize(); const int PacketSize = sizeof(byte) + sizeof(int) + sizeof(int) + sizeof(int) + sizeof(byte); Packet p = new Packet(0xD3, true); byte[] ID = new byte[1]; p.Data.Payload = new byte[PacketSize - 1]; for (; ;) { if (Slave.BytesAvailable() > 0) { Slave.Read(1, ID); while (Slave.BytesAvailable() < PacketSize - 1) { } Slave.Read(PacketSize, p.Data.Payload); p.Data.ID = ID[0]; Client.SendNow(p); } } }
public static IPViewModel GetIpCity(int IntIP) { if (IpCityStore != null) { var item = GetIpCityRecord(IntIP); if (item != null && item.CityId != 0) { var cityinfo = CityStore.get(item.CityId); if (cityinfo != null) { var stateinfo = StateStore.get(cityinfo.State); IPViewModel model = new IPViewModel(); model.Ip = Lib.Helper.IPHelper.FromInt(IntIP); model.City = cityinfo.CityName; if (stateinfo != null) { model.State = stateinfo.StateName; model.CountryCode = CountryCode.FromShort(stateinfo.Country); model.CountryName = CountryCode.GetCountryName(stateinfo.Country); } return(model); } } } return(GetIpCountry(IntIP)); }
internal void CommitToTables(IEnumerable <int> createdTables, IEnumerable <int> droppedTables) { // Add created tables to the committed tables list. foreach (int createdTable in createdTables) { // For all created tables, add to the visible list and remove from the // delete list in the state store. var t = GetTableSource(createdTable); var resource = new TableStateStore.TableState(t.TableId, t.SourceName); StateStore.AddVisibleResource(resource); StateStore.RemoveDeleteResource(resource.SourceName); } // Remove dropped tables from the committed tables list. foreach (int droppedTable in droppedTables) { // For all dropped tables, add to the delete list and remove from the // visible list in the state store. var t = GetTableSource(droppedTable); var resource = new TableStateStore.TableState(t.TableId, t.SourceName); StateStore.AddDeleteResource(resource); StateStore.RemoveVisibleResource(resource.SourceName); } try { StateStore.Flush(); } catch (IOException e) { throw new InvalidOperationException("IO Error: " + e.Message, e); } }
public void Delete() { lock (commitLock) { // We possibly have things to clean up. CleanUp(); // Go through and delete and close all the committed tables. foreach (var source in tableSources.Values) { source.Drop(); } // Delete the state file StateStore.Flush(); StoreSystem.CloseStore(stateStore); StoreSystem.DeleteStore(stateStore); // Delete the blob store if (LargeObjectStore != null) { StoreSystem.CloseStore(lobStore); StoreSystem.DeleteStore(lobStore); } //tableSources = null; IsClosed = true; } // Release the storage system. StoreSystem.Unlock(StateStoreName); }
/// <summary> /// Factory method to create the singleton instance /// </summary> /// <returns></returns> public static async Task Create() { if (Instance != null) { return; } var browserWindow = await Electron.WindowManager.CreateWindowAsync(new BrowserWindowOptions { Title = "ZX Spectrum IDE", Width = 1152, Height = 864, Show = true, Frame = false }); Instance = new AppWindow(browserWindow); browserWindow.OnReadyToShow += () => { Console.WriteLine("OnReadyToShow invoked"); browserWindow.Show(); }; browserWindow.OnFocus += () => StateStore.Dispatch(new AppGotFocusAction()); browserWindow.OnBlur += () => StateStore.Dispatch(new AppLostFocusAction()); browserWindow.OnRestore += () => StateStore.Dispatch(new RestoreWindowAction()); browserWindow.OnMaximize += () => StateStore.Dispatch(new MaximizeWindowAction()); browserWindow.OnMinimize += () => StateStore.Dispatch(new MinimizeWindowAction()); browserWindow.OnUnmaximize += () => StateStore.Dispatch(new RestoreWindowAction()); }
public static void InitBeagleBone() { StateStore.Start("MainRover"); BeagleBone.Initialize(SystemMode.NO_HDMI, true); PinConfig(); IPWMOutputConfig(); Sensors = new List <ISensor>(); try { //Sensors.Add(new BNO055(I2CBBB.I2CBus2)); //Sensors.Add(new MTK3339(UARTBBB.UARTBus4)); } catch (Exception e) { Log.Output(Log.Severity.ERROR, Log.Source.SENSORS, "Failed to initalize sensors (gps and/or mag)"); Log.Exception(Log.Source.SENSORS, e); } foreach (ISensor Sensor in Sensors) { if (Sensor is MTK3339) { previousCoords = ((MTK3339)Sensor).GetCoordinates(); } } }
static void Main(string[] Args) { ParseArgs(Args); StateStore.Start("SciRover"); Log.SetGlobalOutputLevel(Log.Severity.DEBUG); //Log.SetSingleOutputLevel(Log.Source.NETWORK, Log.Severity.DEBUG); Log.ErrorCodes = ScienceErrors.ERROR_CODES; Log.SystemNames = ScienceErrors.SYSTEMS; Log.Begin(); Log.ForceOutput(Log.Severity.INFO, Log.Source.OTHER, "Science Station - Rover Side"); Client.Start(IP, PortTCP, PortUDP, "SciRover"); BeagleBone.Initialize(SystemMode.DEFAULT, true); IOHandler = new IOHandler(); IOHandler.InitializeSystems(ApplyDevTree); ((Turntable)IOHandler.TurntableController).TargetAngle = 50; while (Console.KeyAvailable) { Console.ReadKey(); } // Clear previous keypresses Log.ForceOutput(Log.Severity.INFO, Log.Source.OTHER, "Press any key to exit."); while (!Console.KeyAvailable) { IOHandler.UpdateStates(); Thread.Sleep(20); } Environment.Exit(0); }
private void ReadDroppedTables() { lock (commitLock) { // The list of all dropped tables from the state file var tables = StateStore.GetDeleteList(); // For each visible table foreach (var resource in tables) { int tableId = resource.TableId; string tableName = resource.SourceName; // Load the master table from the resource information var source = LoadTableSource(tableId, tableName); // File wasn't found so remove from the delete resources if (source == null) { StateStore.RemoveDeleteResource(tableName); } else { source.Open(); // Add the table to the table list tableSources.Add(tableId, source); } } StateStore.Flush(); } }
public void GetModes_DefaultValue() { var store = new StateStore(); var result = store.GetModes(); Assert.Empty(result); }
protected override Tuple <Expression, Expression> GetDeSerializerExp(Expression codec) { // // long stateVar; // bool needToInit; ParameterExpression stateVarExp = StateStore.GetOrCreateStateVar( StateName, typeof(long), out needToInit); // // ++stateVar; // return stateVar; // Expression deltaExp = Expression.Block( Expression.PreIncrementAssign(stateVarExp), DebugValueExp(codec, stateVarExp, "MultFld ReadDelta"), stateVarExp); // // stateVar = codec.ReadSignedValue(); // return stateVar; // Expression initExp = needToInit ? Expression.Block( Expression.Assign(stateVarExp, ReadSignedValue(codec)), DebugValueExp(codec, stateVarExp, "MultFld ReadInit"), stateVarExp) : deltaExp; return(new Tuple <Expression, Expression>(initExp, deltaExp)); }
public void Close() { lock (commitLock) { CleanUp(); StoreSystem.SetCheckPoint(); // Go through and close all the committed tables. foreach (var source in tableSources.Values) { source.Close(false); } StateStore.Flush(); StoreSystem.CloseStore(stateStore); //tableSources = null; IsClosed = true; } // Release the storage system StoreSystem.Unlock(StateStoreName); if (LargeObjectStore != null) { StoreSystem.CloseStore(lobStore); } }
public SettingLightViewModel(LightControlService lightControlService, StateStore stateStore, CoreConfig coreConfig) { StateStore = stateStore; CoreConfig = coreConfig; _responseTimeout = CoreConfig.ReponseTimeout; OnCommand = new DelegateCommand(() => { lightControlService.SetValue(coreConfig.LightValues); lightControlService.LightOn(); }); OffCommand = new DelegateCommand(() => { lightControlService.LightOff(); }); var temp = new byte[coreConfig.LightNum]; if (coreConfig.LightValues != null) { Array.Copy(coreConfig.LightValues, temp, coreConfig.LightNum); } LightNum = coreConfig.LightNum; if (coreConfig.LightValues != null) { for (int i = 0; i < LightNum; i++) { _lightValues[i].Value = temp[i]; } } RefreshPorts(); BaudRates = new int[] { 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200 }; Parities = Enum.GetValues(typeof(Parity)).Cast <Parity>(); DataBits = new int[] { 5, 6, 7, 8 }; StopBits = Enum.GetValues(typeof(StopBits)).Cast <StopBits>(); RefreshCommand = new DelegateCommand(() => { RefreshPorts(); }); ConnectCommand = new DelegateCommand(() => { if (CoreConfig.LightSerialInfo != null) { lightControlService.Connect(); } }); DisconnectCommand = new DelegateCommand(() => { lightControlService.Disconnect(); }); }
public static void LoadCharts(ChartManager Charts) { string LeftListRaw = StateStore.GetOrCreate("GraphLeftSeries", string.Empty); string RightListRaw = StateStore.GetOrCreate("GraphRightSeries", string.Empty); AddSeries(LeftListRaw, Charts.Left); AddSeries(RightListRaw, Charts.Right); }
public IEnumerable <ITableSource> GetTableSources() { lock (commitLock) { var list = StateStore.GetVisibleList(); return(list.Select(x => GetTableSource(x.TableId))); } }
public void ItWorksWithoutUnregisteredController() { var store = new StateStore(); Assert.Throws <KeyNotFoundException>(() => { store.GetState <float>("NonExistingController"); }); }
public static void SaveCharts(ChartManager Charts) { string LeftListRaw = GetSeries(Charts.Left); string RightListRaw = GetSeries(Charts.Right); StateStore.Set("GraphLeftSeries", LeftListRaw); StateStore.Set("GraphRightSeries", RightListRaw); StateStore.Save(); }
public SettingViewModel(StateStore stateStore, CoreConfig coreConfig) { StateStore = stateStore; SaveCommand = new DelegateCommand(() => { File.WriteAllText("CoreConfig.json", JsonConvert.SerializeObject(coreConfig)); }); }
public void GetSensorStates_DefaultValue() { var socket = new Socket(1, "Klaus-Dieter"); var store = new StateStore(); var result = store.GetSensorStates(socket); Assert.Equal(new Dictionary <string, PowerStatus>(), result); }
public SettingCameraViewModel(GrabService grabService, StateStore stateStore, CoreConfig coreConfig) { CoreConfig = coreConfig; StateStore = stateStore; AutoValues = Enum.GetValues(typeof(ECameraAutoValue)).Cast <ECameraAutoValue>(); CameraInfos = grabService.GetDeviceInfos(); if (grabService.IsConnected()) { ParameterInfo = grabService.GetParameterInfo(); } grabService.ParameterChanged += (parameterInfo => { ParameterInfo = parameterInfo; }); RefreshCommand = new DelegateCommand(() => { CameraInfos = grabService.GetDeviceInfos(); }); ConnectCommand = new DelegateCommand(() => { if (CoreConfig.CameraInfo != null) { if (grabService.Connect(CoreConfig.CameraInfo)) { ParameterInfo = grabService.GetParameterInfo(); } } }); DisconnectCommand = new DelegateCommand(() => { grabService.Disconnect(); ParameterInfo = null; }); SetAutoCommand = new DelegateCommand <ECameraAutoType?>(type => { if (type == null) { return; } grabService.SetAuto(type.Value, ParameterInfo.AutoValues[type.Value]); }); SetTriggerModeCommand = new DelegateCommand(() => { grabService.SetTriggerMode(ParameterInfo.OnTriggerMode); }); }
public override async Task OnActivateAsync() { this.State = await StateStore.GetByIdAsync(GrainId); if (this.State == null) { IsNew = true; await InitState(); } }
public override void Dispose() { Store?.Dispose(); StateStore?.Dispose(); if (!(Path is null)) { Directory.Delete(Path, true); } }
public void Create(IEnumerable <ISystemFeature> features) { MinimalCreate(features); // Initialize the conglomerate system tables. SetupSystem(features); // Commit the state StateStore.Flush(); }
public void Create() { MinimalCreate(); // Initialize the conglomerate system tables. SetupSystem(); // Commit the state StateStore.Flush(); }
public KafkaSpout(Context ctx) { Context.Logger.Info("KafkaSpout constructor called"); this.ctx = ctx; if (Context.pluginType != SCPPluginType.SCP_NET_LOCAL) { zkAddr = GetZkAddr(); Console.Write("zookeeper address: " + zkAddr); stateStore = StateStore.Get(statPath, zkAddr); } Dictionary<string, List<Type>> outputSchema = new Dictionary<string, List<Type>>(); outputSchema.Add("mydefault", new List<Type>() { typeof(KafkaMeta) }); this.ctx.DeclareComponentSchema(new ComponentStreamSchema(null, outputSchema)); }
public TxGenerator(Context ctx) { Context.Logger.Info("TxGenerator constructor called"); this.ctx = ctx; // Declare Output schema Dictionary<string, List<Type>> outputSchema = new Dictionary<string, List<Type>>(); outputSchema.Add("default", new List<Type>() { typeof(Person) }); this.ctx.DeclareComponentSchema(new ComponentStreamSchema(null, outputSchema)); this.ctx.DeclareCustomizedSerializer(new CustomizedInteropJSONSerializer()); // Demo how to use StateStore in Tx topology to persistence some states // Get zookeeper address from storm conf, which is passed from java side zkAddr = GetZkAddr(); zkRoot = GetZkRoot(); stateStore = StateStore.Get(zkRoot + "/" + statPath, zkAddr); }