public static ReturnCode Take( DataReader reader, ref object[] data, ref SampleInfo[] sampleInfos, int maxSamples, SampleStateKind sampleStates, ViewStateKind viewStates, InstanceStateKind instanceStates) { ReturnCode result = ReturnCode.Ok; using (DataReaderMarshaler marshaler = new DataReaderMarshaler(data, sampleInfos, ref maxSamples, ref result)) { if (result == ReturnCode.Ok) { result = Gapi.FooDataReader.take( reader.GapiPeer, marshaler.dataValuesPtr, marshaler.sampleInfosPtr, maxSamples, sampleStates, viewStates, instanceStates); marshaler.CopyOut(ref data, ref sampleInfos); } } return result; }
public void SetDetailItem(SampleInfo newDetailItem) { if (currentSample != newDetailItem) { currentSample = newDetailItem; // Update the view ConfigureView (); } }
public DataReaderMarshaler(object[] dataValues, SampleInfo[] sampleInfos, ref int maxSamples, ref ReturnCode result) { dataValueHandle = GCHandle.Alloc(dataValues, GCHandleType.Normal); dataValuesPtr = GCHandle.ToIntPtr(dataValueHandle); dataValuesPtrCache = dataValuesPtr; sampleInfoHandle = GCHandle.Alloc(sampleInfos, GCHandleType.Normal); sampleInfosPtr = GCHandle.ToIntPtr(sampleInfoHandle); sampleInfosPtrCache = sampleInfosPtr; result = validateParameters(dataValues, sampleInfos, ref maxSamples); }
public void CopyOut(ref object[] dataValues, ref SampleInfo[] sampleInfos) { if (dataValueHandle.Target != dataValues) { dataValues = dataValueHandle.Target as object[]; } if (sampleInfoHandle.Target != sampleInfos) { sampleInfos = sampleInfoHandle.Target as SampleInfo[]; } }
public void SetSample(SampleInfo sample) { if (sample != null) { this.sample = sample; string localHtmlUrl = Path.Combine (NSBundle.MainBundle.BundlePath, "Support/" + sample.CSharpSourceCodeFile); if (webView != null) { webView.LoadRequest (new NSUrlRequest (new NSUrl (localHtmlUrl, false))); webView.ScalesPageToFit = false; } } }
public override void on_data_available(DataReader reader) { var bytes = new Bytes(); var info = new SampleInfo(); reader.take_next_sample_untyped(bytes, info); if (bytes.value != null) { var args = new DataReceivedArgs { Data = new ArraySegment <byte>(bytes.value, bytes.offset, bytes.length), SessionID = info.instance_handle }; Received.Invoke(this, args); } }
/// <summary> /// Start Receiving /// </summary> static void StartReceive() { _stopReceive = false; //while (!_stopReceive) //{ var msg = new FDM[5]; var sampleInfo = new SampleInfo[5]; //InstanceHandle[] InstanceHandles = null; //FDMDATAReader.GetMatchedSubscriptions(ref InstanceHandles); //MessageBox.Show("Matched: " + InstanceHandles.GetLength(0)); LivelinessChangedStatus aliveStatus = null; var returnCode = fdmDataReader.GetLivelinessChangedStatus(ref aliveStatus); ErrorHandler.checkStatus(returnCode, "FDM SUB : Get liveliness"); if (aliveStatus.AliveCount > 0) { // FDM is on IsAlive = true; } else { // FDM is off IsAlive = false; } //Register FDMDATA (pre-allocating resources for it) //InstanceHandle cmdHandle = FDMDATAReader.RegisterInstance(msg); //MessageBox.Show("Data Sent: Start: " + msg.Start); // Take Data from FDM and populate into temporary MSG array ReturnCode status = fdmDataReader.Take(ref msg, ref sampleInfo); ErrorHandler.checkStatus(status, "Unable to Read : FDMDATA"); //Console.WriteLine(status.ToString()); // Copy only latest data to FdmData variable if some Data has been read if (status == ReturnCode.Ok) { fdmData = msg[0]; } Thread.Sleep(10); //} }
public void TestTakeNextSample() { PublicationBuiltinTopicData data = default; SampleInfo infos = new SampleInfo(); ReturnCode ret = _dr.TakeNextSample(ref data, infos); Assert.AreEqual(ReturnCode.NoData, ret); DomainParticipant otherParticipant = AssemblyInitializer.Factory.CreateParticipant(AssemblyInitializer.RTPS_DOMAIN); Assert.IsNotNull(otherParticipant); otherParticipant.BindRtpsUdpTransportConfig(); TestStructTypeSupport support = new TestStructTypeSupport(); string typeName = support.GetTypeName(); ReturnCode result = support.RegisterType(otherParticipant, typeName); Assert.AreEqual(ReturnCode.Ok, result); var topic = otherParticipant.CreateTopic(TestContext.TestName, typeName); Assert.IsNotNull(topic); var publisher = otherParticipant.CreatePublisher(); Assert.IsNotNull(publisher); DataWriterQos dwQos = TestHelper.CreateNonDefaultDataWriterQos(); dwQos.Ownership.Kind = OwnershipQosPolicyKind.SharedOwnershipQos; DataWriter dataWriter = publisher.CreateDataWriter(topic, dwQos); Assert.IsNotNull(dataWriter); Thread.Sleep(500); ret = _dr.TakeNextSample(ref data, infos); Assert.AreEqual(ReturnCode.Ok, ret); TestHelper.TestNonDefaultPublicationData(data); ret = otherParticipant.DeleteContainedEntities(); Assert.AreEqual(ReturnCode.Ok, ret); ret = AssemblyInitializer.Factory.DeleteParticipant(otherParticipant); Assert.AreEqual(ReturnCode.Ok, ret); }
private async void SamplesListView_ItemClick(object sender, AdapterView.ItemClickEventArgs e) { var sampleName = string.Empty; try { // Call a function to clear existing credentials. ClearCredentials(); // Get the clicked item. SampleInfo item = _listSampleItems[e.Position]; // Download any offline data before showing the sample. if (item.OfflineDataItems != null) { // Show the waiting dialog. ProgressDialog mDialog = new ProgressDialog(this) { Indeterminate = true }; mDialog.SetMessage("Downloading Data"); mDialog.Show(); // Begin downloading data. await DataManager.EnsureSampleDataPresent(item); // Hide the progress dialog. mDialog.Dismiss(); } // Each sample is an Activity, so locate it and launch it via an Intent. var newActivity = new Intent(this, item.SampleType); // Start the activity. StartActivity(newActivity); } catch (Exception ex) { AlertDialog.Builder bldr = new AlertDialog.Builder(this); var dialog = bldr.Create(); dialog.SetTitle("Unable to load " + sampleName); dialog.SetMessage(ex.Message); dialog.Show(); } }
private async void OnItemTapped(object sender, ItemTappedEventArgs e) { // Call a function to clear existing credentials. ClearCredentials(); try { // Get the selected sample. SampleInfo item = (SampleInfo)e.Item; // Load offline data before showing the sample. if (item.OfflineDataItems != null) { // Show the wait page. await Navigation.PushModalAsync(new WaitPage { Title = item.SampleName }, false); #if WINDOWS_UWP // Workaround for bug with Xamarin Forms UWP. await Task.WhenAll( Task.Delay(100), DataManager.EnsureSampleDataPresent(item) ); #else // Wait for the sample data download. await DataManager.EnsureSampleDataPresent(item); #endif // Remove the waiting page. await Navigation.PopModalAsync(false); } // Get the sample control from the selected sample. var sampleControl = (ContentPage)SampleManager.Current.SampleToControl(item); // Create the sample display page to show the sample and the metadata. SamplePage page = new SamplePage(sampleControl, item); // Show the sample. await Navigation.PushAsync(page, true); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Exception occurred on OnItemTapped. Exception = " + ex); } }
protected void InitFields(DataRow rowInfo) { this.code = rowInfo["Code"].ToString().Trim(); this.UserId = TengDa._Convert.StrToInt(rowInfo["UserId"].ToString(), -1); this.ovenStationId = TengDa._Convert.StrToInt(rowInfo["OvenStationId"].ToString(), -1); this.location = rowInfo["Location"].ToString().Trim(); this.bakingStartTime = TengDa._Convert.StrToDateTime(rowInfo["BakingStartTime"].ToString(), Common.DefaultTime); this.bakingStopTime = TengDa._Convert.StrToDateTime(rowInfo["BakingStopTime"].ToString(), Common.DefaultTime); this.inOvenTime = TengDa._Convert.StrToDateTime(rowInfo["InOvenTime"].ToString(), Common.DefaultTime); this.outOvenTime = TengDa._Convert.StrToDateTime(rowInfo["OutOvenTime"].ToString(), Common.DefaultTime); this.isFinished = TengDa._Convert.StrToBool(rowInfo["IsFinished"].ToString(), false); this.isUploaded = TengDa._Convert.StrToBool(rowInfo["IsUploaded"].ToString(), true); this.scanTime = TengDa._Convert.StrToDateTime(rowInfo["ScanTime"].ToString(), Common.DefaultTime); this.temperature = TengDa._Convert.StrToFloat(rowInfo["Temperature"].ToString(), -1); this.vacuum = TengDa._Convert.StrToFloat(rowInfo["Vacuum"].ToString(), -1); this.sampleInfo = (SampleInfo)Enum.Parse(typeof(SampleInfo), rowInfo["SampleInfo"].ToString()); this.Id = TengDa._Convert.StrToInt(rowInfo["Id"].ToString(), -1); }
/// <summary> /// 根据样本编号获取当天样本信息 /// </summary> /// <param name="sampleNum"></param> /// <param name="sampleCreateTime"></param> /// <returns></returns> public SampleInfo GetSample(int sampleNum, DateTime sampleCreateTime) { SampleInfo sampleInfo = new SampleInfo(); try { Hashtable ht = new Hashtable(); ht.Add("sampleNum", sampleNum); ht.Add("sampleCreateTime", sampleCreateTime.Date); sampleInfo = ism_SqlMap.QueryForObject("WorkAreaApplyTask.GetSample", ht) as SampleInfo; } catch (Exception e) { LogInfo.WriteErrorLog("GetSample(int sampleNum, DateTime sampleCreateTime)==" + e.ToString(), Module.WorkingArea); } return(sampleInfo); }
public override void Write(short[] samples, long count) { long writeCount = 0; for (int i = 0; i < count; i++) { if (i >= samples.Length) { break; } var sample = BitConverter.GetBytes(samples[i]); _encoder.Write(sample, 0, sample.Length); writeCount++; } SampleInfo = new SampleInfo((int)(SampleInfo.SampleCount + writeCount), SampleInfo.ChannelCount, SampleInfo.SampleRate); }
private static void PrintCoheretSetInfo(SampleInfo info) { // The coherent_set_info in the SampleInfo is only present if the sample is // part of a coherent set. We therefore need to check if it is present // before accessing any of the members var setInfo = info.CoherentSetInfo; if (setInfo != null) { var complete = setInfo.IncompleteCoherentSet ? "an incomplete" : "a complete"; var sn = setInfo.GroupCoherentSetSequenceNumber; Console.WriteLine($"The following sample is part of {complete} group coherent set with SN {sn}:"); } else { Console.WriteLine("The following sample is not part of a coherent set:"); } }
public static ReturnCode validateParameters(object[] dataValues, SampleInfo[] sampleInfos, ref int maxSamples) { // Determine current length. int length = (dataValues == null ? 0 : dataValues.Length); // 1st Check: arrays should both be null, or have equal length. if (dataValues != null && sampleInfos != null && dataValues.Length != sampleInfos.Length) return ReturnCode.PreconditionNotMet; // 2nd Check: maxSamples <= length. if (length > 0 && maxSamples > length) return ReturnCode.PreconditionNotMet; // 3rd Check: In case maxSamples == Length.Unlimited, make maxSamples equal to available length. if (maxSamples == Length.Unlimited && length > 0) maxSamples = length; return ReturnCode.Ok; }
private async void DownloadSample(NSIndexPath indexPath) { _statusLabel.Text = "Downloading sample data..."; SampleInfo sample = _samples[indexPath.Row]; try { await DataManager.EnsureSampleDataPresent(sample); } catch (Exception exception) { Debug.WriteLine(exception); new UIAlertView("Error", "Download canceled", (IUIAlertViewDelegate)null, "OK", null).Show(); } finally { _statusLabel.Text = "Data downloaded: " + sample.SampleName; } }
private SampleInfo GetSampleInfo(MTConnect.Headers.MTConnectStreamsHeader header, DeviceConfiguration config) { var result = new SampleInfo(); //Get Sequence Number to use ----------------------- long first = header.FirstSequence; if (!startFromFirst) { first = header.LastSequence; startFromFirst = true; } else if (lastInstanceId == agentInstanceId && lastSequenceSampled > 0 && lastSequenceSampled >= header.FirstSequence) { first = lastSequenceSampled; } else if (first > 0) { // Increment some sequences since the Agent might change the first sequence // before the Sample request gets read // (should be fixed in Agent to automatically read the first 'available' sequence // instead of returning an error) first += 20; } result.From = first; // Get Last Sequence Number available from Header long last = header.LastSequence; // Calculate Sample count long sampleCount = last - first; if (sampleCount > MaxSampleCount) { sampleCount = MaxSampleCount; last = first + MaxSampleCount; } result.Count = sampleCount; return(result); }
private async void DownloadNow_Clicked(object sender, RoutedEventArgs e) { try { SetStatusMessage("Downloading sample data", true); SampleInfo sample = (SampleInfo)((Button)sender).Tag; await DataManager.EnsureSampleDataPresent(sample); } catch (Exception exception) { Debug.WriteLine(exception); MessageBox.Show("Couldn't download data for that sample"); } finally { SetStatusMessage("Ready", false); } }
private async void Download_Now_Click(object sender, RoutedEventArgs e) { try { SetStatusMessage("Downloading sample data", true); SampleInfo sample = (SampleInfo)((Button)sender).Tag; await DataManager.EnsureSampleDataPresent(sample); } catch (Exception exception) { System.Diagnostics.Debug.WriteLine(exception); await new MessageDialog("Couldn't download data for that sample", "Error").ShowAsync(); } finally { SetStatusMessage("Ready", false); } }
public void Insert(SampleInfo sampleInfo) { db.Open(); string query = "INSERT INTO [dbo].[Sample] " + "([ClientNo] " + ",[CompanyName] " + ",[Manager] " + ",[ResponsiblePerson] " + ",[ContactNo] " + ",[Member] " + ",[Address] " + ",[IsOnlineVoting] " + ",[Email] " + ",[RelationShip] " + ",[Asset] " + ",[liability] " + ",[CreateDate] " + ",[CreateUser] " + ",[UpdateDate] " + ",[UpdateUser]) " + "VALUES " + "(@ClientNo " + ",@CompanyName " + ",@Manager " + ",@ResponsiblePerson " + ",@ContactNo " + ",@Member " + ",@Address " + ",@IsOnlineVoting " + ",@Email " + ",@RelationShip " + ",@Asset " + ",@liability " + ",@CreateDate " + ",@CreateUser " + ",@UpdateDate " + ",@UpdateUser) "; db.Execute(query, sampleInfo); db.Close(); }
public SampleInfo QuerySampleInfoByPosAndPanel(string strMethodName, string[] paramInfos) { SampleInfo sampleInfo = new SampleInfo(); try { Hashtable ht = new Hashtable(); ht.Add("PanelNum", paramInfos[0]); ht.Add("SamplePos", paramInfos[1]); ht.Add("starttime", DateTime.Now.Date); ht.Add("endtime", DateTime.Now.AddDays(1).Date); sampleInfo = ism_SqlMap.QueryForObject("WorkAreaApplyTask." + strMethodName, ht) as SampleInfo; } catch (Exception e) { LogInfo.WriteErrorLog("QuerySampleInfoByPosAndPanel(string strMethodName, string[] paramInfos)==" + e.ToString(), Module.WorkingArea); } return(sampleInfo); }
public override async void RowSelected(UITableView tableView, NSIndexPath indexPath) { try { // Call a function to clear existing credentials ClearCredentials(); _sample = _data[indexPath.Row]; if (_sample.OfflineDataItems != null) { // Create a cancellation token source. var cancellationTokenSource = new CancellationTokenSource(); // Show progress overlay var bounds = UIScreen.MainScreen.Bounds; _loadPopup = new LoadingOverlay(bounds, cancellationTokenSource); _controller.ParentViewController.View.Add(_loadPopup); // Ensure data present await DataManager.EnsureSampleDataPresent(_sample, cancellationTokenSource.Token); // Hide progress overlay _loadPopup.Hide(); } var control = (UIViewController)SampleManager.Current.SampleToControl(_sample); control.NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIImage.FromBundle("InfoIcon"), UIBarButtonItemStyle.Plain, ViewSampleReadme); _controller.NavigationController.PushViewController(control, true); } catch (OperationCanceledException) { _loadPopup.Hide(); _controller.TableView.DeselectRow(indexPath, true); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public void Insert(SampleInfo sampleInfo) { db.Open(); string query = @" INSERT INTO [dbo].[Sample] ([SampleNo] ,[SampleText] ,[SampleTextarea] ,[SampleRadioButton] ,[Email] ,[Relationship] ,[Asset] ,[Liability] ,[SampleDate] ,[CreateUser] ,[UpdateDate] ,[UpdateUser] ,[SampleTime]) VALUES (@SampleNo ,@SampleText ,@SampleTextarea ,@SampleRadioButton ,@Email ,@Relationship ,@Asset ,@Liability ,@SampleDate ,@CreateUser ,@UpdateDate ,@UpdateUser ,@SampleTime) "; db.Execute(query, sampleInfo); db.Close(); }
/* * Saves only volume values < 64 * */ private void SaveAllArrayValuesToFile() { SaveValuesInSampleInfo(); IniWrapper iniWrapper = new IniWrapper(xrnsFile, true); string iniFolder = Path.GetDirectoryName(iniWrapper.IniPath); if (Directory.Exists(iniFolder) == false) { Directory.CreateDirectory(iniFolder); } File.Delete(iniWrapper.IniPath); for (int ci = 0; ci < instrumentsInfo.Length; ci++) { for (int si = 0; si < instrumentsInfo[ci].SampleInfo.Length; si++) { //int volume = (int)volumeArray[ci][si]; //if (volume < 64) // iniWrapper.SaveDefaultVolumeSample(ci, si, volume); //if (oldSamplesFreq[ci][si] != samplesFreq[ci][si]) // iniWrapper.SaveNewFreqSample(ci, si, samplesFreq[ci][si]); SampleInfo sampleInfo = instrumentsInfo[ci].SampleInfo[si]; if (sampleInfo.Volume < 64) { iniWrapper.SaveDefaultVolumeSample(ci, si, sampleInfo.Volume); } if (Int32.Parse(sampleInfo.SampleFreq) != sampleInfo.SampleFreqOriginal) { iniWrapper.SaveNewFreqSample(ci, si, sampleInfo.SampleFreq); } } } }
public void TestGetKeyValue() { // Call GetKeyValue with HandleNil ParticipantBuiltinTopicData data = default; SampleInfo info = new SampleInfo(); ReturnCode ret = _dr.GetKeyValue(ref data, InstanceHandle.HandleNil); Assert.AreEqual(ReturnCode.BadParameter, ret); DomainParticipantQos qos = new DomainParticipantQos(); qos.UserData.Value = new byte[] { 0x42 }; DomainParticipant otherParticipant = AssemblyInitializer.Factory.CreateParticipant(AssemblyInitializer.RTPS_DOMAIN, qos); Assert.IsNotNull(otherParticipant); otherParticipant.BindRtpsUdpTransportConfig(); Assert.IsTrue(_participant.WaitForParticipants(1, 20_000)); Assert.IsTrue(otherParticipant.WaitForParticipants(1, 20_000)); // Get the for an existing instance ret = _dr.ReadNextSample(ref data, info); Assert.AreEqual(ReturnCode.Ok, ret); Assert.AreEqual(1, data.UserData.Value.Count); Assert.AreEqual(0x42, data.UserData.Value.First()); ParticipantBuiltinTopicData aux = default; ret = _dr.GetKeyValue(ref aux, info.InstanceHandle); Assert.AreEqual(ReturnCode.Ok, ret); for (int i = 0; i < 3; i++) { Assert.AreEqual(data.Key.Value[i], aux.Key.Value[i]); } ret = otherParticipant.DeleteContainedEntities(); Assert.AreEqual(ReturnCode.Ok, ret); ret = AssemblyInitializer.Factory.DeleteParticipant(otherParticipant); Assert.AreEqual(ReturnCode.Ok, ret); }
public void TestLookupInstance() { TopicBuiltinTopicData data = default; SampleInfo info = new SampleInfo(); DomainParticipant otherParticipant = AssemblyInitializer.Factory.CreateParticipant(AssemblyInitializer.INFOREPO_DOMAIN); Assert.IsNotNull(otherParticipant); otherParticipant.BindTcpTransportConfig(); TestStructTypeSupport support = new TestStructTypeSupport(); string typeName = support.GetTypeName(); ReturnCode result = support.RegisterType(otherParticipant, typeName); Assert.AreEqual(ReturnCode.Ok, result); TopicQos qos = TestHelper.CreateNonDefaultTopicQos(); var topic = otherParticipant.CreateTopic(TestContext.TestName, typeName, qos); Assert.IsNotNull(topic); Thread.Sleep(500); ReturnCode ret = _dr.ReadNextSample(ref data, info); Assert.AreEqual(ReturnCode.Ok, ret); Assert.AreEqual(typeName, data.TypeName); Assert.IsNotNull(data.Key); TestHelper.TestNonDefaultTopicData(data); // Lookup for an existing instance var handle = _dr.LookupInstance(data); Assert.AreNotEqual(InstanceHandle.HandleNil, handle); ret = otherParticipant.DeleteContainedEntities(); Assert.AreEqual(ReturnCode.Ok, ret); ret = AssemblyInitializer.Factory.DeleteParticipant(otherParticipant); Assert.AreEqual(ReturnCode.Ok, ret); }
internal static void CopyOut(IntPtr from, ref SampleInfo to) { // Use a tmp object because the Time structs are different. UserLayerSampleInfo tmp = new UserLayerSampleInfo(); Marshal.PtrToStructure(from, tmp); to.SampleState = tmp.SampleState; to.ViewState = tmp.ViewState; to.InstanceState = tmp.InstanceState; to.DisposedGenerationCount = tmp.DisposedGenerationCount; to.NoWritersGenerationCount = tmp.NoWritersGenerationCount; to.SampleRank = tmp.SampleRank; to.GenerationRank = tmp.GenerationRank; to.AbsoluteGenerationRank = tmp.AbsoluteGenerationRank; to.SourceTimestamp.OsTimeW = tmp.SourceTimestamp; to.InstanceHandle = tmp.InstanceHandle; to.PublicationHandle = tmp.PublicationHandle; to.ValidData = tmp.ValidData; to.ReceptionTimestamp.OsTimeW = tmp.ReceptionTimestamp; }
private async void SetupSample() { // Get the sample type. Type sampleType = GetType().GetTypeInfo().Assembly .GetTypes().First(type => type.GetTypeInfo().GetCustomAttributes().OfType <SampleAttribute>().Any()); // Populate the metadata for the sample. SampleInfo sample = new SampleInfo(sampleType); // Update the title now that it is known. this.Title = sample.SampleName; // Download offline data if necessary. if (sample.OfflineDataItems != null) { await DataManager.EnsureSampleDataPresent(sample); } // Show the sample. this.Content = (UserControl)Activator.CreateInstance(sample.SampleType); }
public static bool IsLoan( DataReader reader, ref object[] data, ref SampleInfo[] sampleInfos) { GCHandle tmpGCHandleData = GCHandle.Alloc(data, GCHandleType.Normal); IntPtr dataValuesPtr = GCHandle.ToIntPtr(tmpGCHandleData); GCHandle tmpGCHandleInfo = GCHandle.Alloc(sampleInfos, GCHandleType.Normal); IntPtr sampleInfosPtr = GCHandle.ToIntPtr(tmpGCHandleInfo); byte result = Gapi.FooDataReader.is_loan( reader.GapiPeer, dataValuesPtr, sampleInfosPtr); tmpGCHandleData.Free(); tmpGCHandleInfo.Free(); return result != 0; }
public void OnDataAvailable(IDataReader entityInterface) { var topicAdmin = (DataReader <T>)entityInterface; var messages = new T[0]; var infos = new SampleInfo[0]; if (QueryCondition == null) { topicAdmin.Read(ref messages, ref infos, Length.Unlimited, SampleStateKind.NotRead, ViewStateKind.Any, InstanceStateKind.Any); } else { // Take with a condition topicAdmin.TakeWithCondition(ref messages, ref infos, QueryCondition); } int msgNo = 0; foreach (T msg in messages) { if (!infos[msgNo++].ValidData) { continue; } lastMessageReceived = msg; OnMessageReceived(lastMessageReceived); } if (snapshot && messages.Length == 0 && lastMessageReceived != null && !lastMessageReceived.Equals(default(T))) { OnBufferEmpty(); lastMessageReceived = default(T); } topicAdmin.ReturnLoan(ref messages, ref infos); }
private SampleChannel loadChannel(SampleInfo info, Func <string, SampleChannel> getSampleFunction) { SampleChannel ch = null; if (info.Namespace != null) { ch = getSampleFunction($"Gameplay/{info.Namespace}/{info.Bank}-{info.Name}"); } // try without namespace as a fallback. if (ch == null) { ch = getSampleFunction($"Gameplay/{info.Bank}-{info.Name}"); } if (ch != null) { ch.Volume.Value = info.Volume / 100.0; } return(ch); }
public TaskInfoForSamplePanelInfo QueryTaskInfoForSamplePanel(string strMethodName, string[] paramInfos) { // 1.获取样本编号、样本状态、样本类型 SampleInfo sampleInfo = myBatis.QuerySampleInfoByPosAndPanel("QuerySampleInfoByPosAndPanel", paramInfos); // 2.获取检测项目信息 List <SampleResultInfo> lstSampleResultInfo = new List <SampleResultInfo>(); lstSampleResultInfo = myBatis.QueryProjectResultBySampleNum(strMethodName, new string[] { sampleInfo.SampleNum.ToString(), sampleInfo.CreateTime.ToShortDateString() }); TaskInfoForSamplePanelInfo taskInfoForSamPanel = new TaskInfoForSamplePanelInfo(); taskInfoForSamPanel.SampleNum = sampleInfo.SampleNum; taskInfoForSamPanel.SampleState = sampleInfo.SampleState; taskInfoForSamPanel.SampleType = sampleInfo.SampleType; taskInfoForSamPanel.SamplePos = string.Format("{0}-{1}", sampleInfo.PanelNum, sampleInfo.SamplePos); List <SampleResultInfo> lstTaskResInfos = new List <SampleResultInfo>(); foreach (SampleResultInfo taskInfo in lstSampleResultInfo) { SampleResultInfo s = new SampleResultInfo(); s.ConcResult = taskInfo.ConcResult; s.ProjectName = taskInfo.ProjectName; Hashtable ht = new Hashtable(); ht.Add("SampleNum", taskInfo.SampleNum); ht.Add("DateTime", taskInfo.SampleCreateTime); ht.Add("ProjectName", taskInfo.ProjectName); ht.Add("SampleType", sampleInfo.SampleType); s.UnitAndRange = myBatis.QueryUnitAndRangeByProject("QueryUnitAndRangeByProject", ht); lstTaskResInfos.Add(s); } taskInfoForSamPanel.InspectInfos = XmlUtility.Serializer(typeof(List <SampleResultInfo>), lstTaskResInfos); return(taskInfoForSamPanel); }
private async Task SelectSample(SampleInfo selectedSample) { // Call a function to clear existing credentials ClearCredentials(); SampleManager.Current.SelectedSample = selectedSample; try { if (selectedSample.OfflineDataItems != null) { CancellationTokenSource cancellationSource = new CancellationTokenSource(); // Show the waiting page SamplePageContainer.Content = new WaitPage(cancellationSource); SamplePageContainer.Visibility = Visibility.Visible; SampleSelectionGrid.Visibility = Visibility.Collapsed; // Wait for offline data to complete await DataManager.EnsureSampleDataPresent(selectedSample, cancellationSource.Token); } // Show the sample SamplePageContainer.Content = new SamplePage(); SamplePageContainer.Visibility = Visibility.Visible; SampleSelectionGrid.Visibility = Visibility.Collapsed; } catch (Exception exception) { // Failed to create new instance of the sample. SamplePageContainer.Visibility = Visibility.Collapsed; SampleSelectionGrid.Visibility = Visibility.Visible; CategoriesTree.SelectionMode = muxc.TreeViewSelectionMode.None; await new MessageDialog(exception.Message).ShowAsync(); CategoriesTree.SelectionMode = muxc.TreeViewSelectionMode.Single; } }
private async void ShowSample(SampleInfo item) { // Clear Credentials foreach (Credential cred in AuthenticationManager.Current.Credentials) { AuthenticationManager.Current.RemoveCredential(cred); } try { // Load offline data before showing the sample. if (item.OfflineDataItems != null) { // Show the wait page. await Navigation.PushModalAsync(new WaitPage { Title = item.SampleName }, false); // Wait for the sample data download. await DataManager.EnsureSampleDataPresent(item); // Remove the waiting page. await Navigation.PopModalAsync(false); } // Get the sample control from the selected sample. var sampleControl = (ContentPage)SampleManager.Current.SampleToControl(item); // Create the sample display page to show the sample and the metadata. SamplePage page = new SamplePage(sampleControl, item); // Show the sample. await Navigation.PushAsync(page, true); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Exception occurred on OnItemTapped. Exception = " + ex); } }
//排序交叉配血 public void SortCrossMatching() { //把生理盐水同一排序 var slys_tem_list = action_list.Where(item => item.GetGelStep().GetLiquidInfo() != null && item.GetGelStep().GetLiquidInfo().IsSlys).ToList(); for (int i = 1; i < slys_tem_list.Count; i++) { slys_tem_list[i].GetGelStep().StepIndex = slys_tem_list[0].GetGelStep().StepIndex; } //交叉配血合并(按献血员排序) List <List <SampleInfo> > sort_list = new List <List <SampleInfo> >(); for (int i = 0; i < samples_barcode.Count; i++) { var samplev_info = ResManager.getInstance().GetSampleInfo(samples_barcode[i]); var samplek_info = ResManager.getInstance().GetSampleInfo(volunteers_barcode[i]); if (samplev_info == null) { samplev_info = new SampleInfo(samples_barcode[i], -1, 0); } if (samplek_info == null) { samplek_info = new SampleInfo(volunteers_barcode[i], -1, 0); } sort_list.Add(new List <SampleInfo>()); sort_list[sort_list.Count - 1].Add(samplek_info); sort_list[sort_list.Count - 1].Add(samplev_info); } sort_list = sort_list.OrderBy(p => p[0].Index).ToList(); samples_barcode.Clear(); volunteers_barcode.Clear(); foreach (var item in sort_list) { volunteers_barcode.Add(item[0].Barcode); samples_barcode.Add(item[1].Barcode); } }
private async Task SelectSample(SampleInfo selectedSample) { if (selectedSample == null) { return; } SampleManager.Current.SelectedSample = selectedSample; DescriptionContainer.DataContext = selectedSample; // Call a function to clear any existing credentials from AuthenticationManager ClearCredentials(); try { if (selectedSample.OfflineDataItems != null) { // Show waiting page SampleContainer.Content = new WPF.Viewer.WaitPage(); // Wait for offline data to complete await DataManager.EnsureSampleDataPresent(selectedSample); } // Show the sample SampleContainer.Content = SampleManager.Current.SampleToControl(selectedSample); SourceCodeContainer.LoadSourceCode(); } catch (Exception exception) { // failed to create new instance of the sample SampleContainer.Content = new WPF.Viewer.ErrorPage(exception); } CategoriesRegion.Visibility = Visibility.Collapsed; SampleContainer.Visibility = Visibility.Visible; }
protected override async void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); // Get the sample type. Type sampleType = GetType().GetTypeInfo().Assembly .GetTypes().First(type => type.GetTypeInfo().GetCustomAttributes().OfType <SampleAttribute>().Any()); // Populate the metadata for the sample. SampleInfo sample = new SampleInfo(sampleType); // Download offline data if necessary. if (sample.OfflineDataItems != null) { await DataManager.EnsureSampleDataPresent(sample); } var newActivity = new Intent(this, sample.SampleType); StartActivity(newActivity); }
public virtual void ReaderCopy(Gapi.gapi_Seq samples, Gapi.gapi_readerInfo readerInfo) { int samplesToRead = 0; IntPtr dataSampleBuf = IntPtr.Zero; if (samples != null) { samplesToRead = (int) samples._length; dataSampleBuf = samples._buffer; } // Restore GCHandle types from IntPtr types. GCHandle tmpGCHandleData = GCHandle.FromIntPtr(readerInfo.data_buffer); object[] sampleDataArray = tmpGCHandleData.Target as object[]; GCHandle tmpGCHandleInfo = GCHandle.FromIntPtr(readerInfo.info_buffer); SampleInfo[] sampleInfoArray = tmpGCHandleInfo.Target as SampleInfo[]; if (sampleDataArray == null || sampleDataArray.Length != samplesToRead) { // Initialize the arrays using recycled elements of the pre-allocated ones. object[] targetData = SampleReaderAlloc(samplesToRead); initObjectSeq(sampleDataArray, targetData); sampleDataArray = targetData; SampleInfo[] targetSampleInfo = new SampleInfo[samplesToRead]; initObjectSeq(sampleInfoArray, targetSampleInfo); sampleInfoArray = targetSampleInfo; // Point the GCHandle types to the newly allocated arrays. tmpGCHandleData.Target = sampleDataArray; tmpGCHandleInfo.Target = sampleInfoArray; } // copy the data into our sampleDataArray and sampleInfoArray IntPtr samplePtr; object sampleObj; int cursor = 0; for (int i = 0; i < samplesToRead; i++) { // Copy the samples. samplePtr = ReadIntPtr(dataSampleBuf, cursor + offset_data); sampleObj = sampleDataArray[i]; CopyOut(samplePtr, ref sampleObj, 0); sampleDataArray[i] = sampleObj; // Copy the sample info SampleInfoMarshaler.CopyOut(dataSampleBuf, ref sampleInfoArray[i], cursor + offset_sampleInfo); cursor += dataSampleSize; } }
/// <summary> /// /// </summary> /// <param name="TOCnode"></param> /// <param name="tree"></param> /// <param name="level"></param> private void FillSampleListIntern(XmlNode TOCnode, TreeNodeCollection nodes) { // Loop through all XML nodes int nodeID = 0; XmlNode node = TOCnode.FirstChild; while(node != null) { if(node.Name == "TOCNode") { // Add node into the tree nodeID = nodes.Add(new TreeNode(node.Attributes["Title"].Value)); // Add all child nodes FillSampleListIntern(node, nodes[nodeID].Nodes); } else if(node.Name == "SampleConfig") { // Add node into the tree nodeID = nodes.Add(new TreeNode(node["Title"].InnerText)); // Create sample information object if(node["SampleControl"] != null) { SampleInfo sampleInfo = new SampleInfo(); sampleInfo.sampleControl = node["SampleControl"].InnerText; sampleInfo.path = node.Attributes["Path"].Value; if(node["Keywords"] != null) sampleInfo.keywords = node["Keywords"].InnerText; if(node["ShortBlurb"] != null) sampleInfo.shortBlurb = node["ShortBlurb"].InnerText; if(node["Thumbnail"] != null) sampleInfo.thumbnail = node["Thumbnail"].InnerText; if(node["Title"] != null) sampleInfo.title = node["Title"].InnerText; // Fill info pages list XmlNode nodeInfoPages = node["InfoPages"]; if(nodeInfoPages != null && nodeInfoPages.HasChildNodes) { XmlNode nodeInfo = nodeInfoPages.FirstChild; while(nodeInfo != null) { if(nodeInfo.Name == "InfoPage") { InfoPage newInfoPage = new InfoPage(); newInfoPage.title = nodeInfo.Attributes["Title"].Value; newInfoPage.data = nodeInfo.InnerText; sampleInfo.infoPages.Add(newInfoPage); } nodeInfo = nodeInfo.NextSibling; } } // Fill keywords array XmlNode nodeKeywords = node["Keywords"]; if(nodeKeywords != null && nodeKeywords.HasChildNodes) { XmlNode nodeInfo = nodeKeywords.FirstChild; while(nodeInfo != null) { if(nodeInfo.Name == "Keyword") { IndexInfo indexInfo = new IndexInfo(); indexInfo.SampleInfo = sampleInfo; indexInfo.Key = nodeInfo.InnerText.Trim(); // Check if string has a sub index separated with comma int commaIndex = indexInfo.Key.IndexOf(','); if(commaIndex > 0) { indexInfo.SubKey = indexInfo.Key.Substring(commaIndex + 1).Trim(); indexInfo.Key = indexInfo.Key.Substring(0, commaIndex).Trim(); } this.indexInfoList.Add(indexInfo); } nodeInfo = nodeInfo.NextSibling; } } // Add sample information to the tree node nodes[nodeID].Tag = sampleInfo; // Set node image int imageIndex = 2; if(sampleInfo.infoPages != null && sampleInfo.infoPages.Count == 1) { InfoPage infoPage = (InfoPage)sampleInfo.infoPages[0]; if(infoPage.title == "Gallery") { // Set Gallery list image imageIndex = 3; } else if(infoPage.title == "Overview") { // Set Gallery list image imageIndex = 4; } } nodes[nodeID].ImageIndex = imageIndex; nodes[nodeID].SelectedImageIndex = imageIndex; } } // Get next node node = node.NextSibling; } }
public SampleInfo(SampleInfo info) { batch = info.batch; index = info.index; barcode = info.barcode; }
/// <summary> /// Loads sample. /// </summary> /// <param name="sampleInfo">Sample information.</param> private void LoadSample(SampleInfo sampleInfo) { this.tabControlSample.SuspendLayout(); this.panelContent.SuspendLayout(); this.SuspendLayout(); UserControl userControl = null; userControl = (UserControl)Assembly.GetEntryAssembly().CreateInstance(this.samplesNamespace + "." + sampleInfo.sampleControl); // Save current sample path this.CurrentSampleInfo = sampleInfo; this.CurrentSamplePath = this.applicationPath + "\\"; this.CurrentSamplePath += sampleInfo.path; // Make sure sample tab is the first one if(this.tabControlSample.TabPages[0].Text != "Sample") { for(int index = 0; index < this.tabControlSample.TabPages.Count; index++) { if(this.tabControlSample.TabPages[index].Text == "Sample") { this.tabControlSample.TabPages.SetTabIndex(this.tabControlSample.TabPages[index], 0); break; } } } // Hide/show sample tab control tabControlSample.TabPages[0].Hidden = (userControl == null); // Load selected user control if(userControl != null) { // Scale control if(this.scaleRatioX != 1f || this.scaleRatioY != 1f) { userControl.Scale(this.scaleRatioX, this.scaleRatioY); } userControl.AutoScroll = true; userControl.Dock = System.Windows.Forms.DockStyle.Fill; userControl.Size = new Size(800, 600); userControl.TabIndex = 0; if(this.tabControlSample.TabPages[0].Controls.Count > 0) { int count = this.tabControlSample.TabPages[0].Controls[0].Controls.Count; for (int i = (count-1); i >= 0; i-- ) { Control control = this.tabControlSample.TabPages[0].Controls[0].Controls[i]; if (control != null) { control.Dispose(); } } this.tabControlSample.TabPages[0].Controls[0].Dispose(); } this.tabControlSample.TabPages[0].Controls.Add(userControl); } // Check if tabs can be resused. for(int index = 1; index < this.tabControlSample.TabPages.Count; index++) { bool reuse = false; // Check if tab name matches one of the required names foreach(InfoPage infoPage in sampleInfo.infoPages) { if(infoPage.title == this.tabControlSample.TabPages[index].Text) { reuse = true; break; } } // Remove tab control if cannot be reused if(!reuse) { // If tab contains the IE ActiveX control - move it into the form if(this.tabControlSample.TabPages[index].Controls[0] == this.panelWebBrowser) { this.panelWebBrowser.Visible = false; this.Controls.Add(this.panelWebBrowser); } this.tabControlSample.TabPages.Remove(this.tabControlSample.TabPages[index]); --index; } } // Add new pages into the tab control int tabIndex = 1; foreach(object obj in sampleInfo.infoPages) { InfoPage infoPage = (InfoPage)obj; // Skip sample placeholder if(infoPage.title == "Sample") { continue; } // check if we can use reused tab VerticalTabPage tabPage = null; for(int index = 0; index < this.tabControlSample.TabPages.Count; index++) { if(infoPage.title == this.tabControlSample.TabPages[index].Text) { tabPage = this.tabControlSample.TabPages[index]; // Adjust tab control index if(tabIndex != index) { this.tabControlSample.TabPages.SetTabIndex(tabPage, tabIndex); } } } // Add a new tab if(tabPage == null) { tabControlSample.TabPages.Insert(tabIndex, infoPage.title); tabPage = tabControlSample.TabPages[tabIndex]; } tabPage.Font = new Font("Arial", 9); // Load info text from file string infoFileName = this.applicationPath + "\\" + sampleInfo.path + "\\" + infoPage.data; infoFileName = infoFileName.ToUpper(); StreamReader sr = new StreamReader(infoFileName); string infoText = sr.ReadToEnd(); sr.Close(); // Apply color syntax hilighting SourceCodeToRtf sourceConverter = null; bool rtfFormat = false; if(infoPage.title.ToUpper().IndexOf("C#") >= 0) { sourceConverter = new SourceCodeToRtf(); sourceConverter.LoadLanguageDefinition(this.applicationPath + "\\cs_langDef.xml"); } else if(infoPage.title.IndexOf("Visual Basic") >= 0) { sourceConverter = new SourceCodeToRtf(); sourceConverter.LoadLanguageDefinition(this.applicationPath + "\\vbnet_langDef.xml"); } // Convert source text using selected converter if(sourceConverter != null) { infoText = sourceConverter.Convert(infoText); rtfFormat = true; } // Check if RTF or IE ActiveX control should be created bool reusedControl = false; if(infoFileName.EndsWith(".HTM") || infoFileName.EndsWith(".HTML")) { // Check if control can be reused if(tabPage.Controls.Count > 0) { if(tabPage.Controls[0] == this.panelWebBrowser) { reusedControl = true; } else { tabPage.Controls.RemoveAt(0); } } // Add IE control into the tab if(!reusedControl) { this.panelWebBrowser.Visible = true; this.panelWebBrowser.Dock = DockStyle.Fill; tabPage.Controls.Add(this.panelWebBrowser); } webBrowser1.Navigate(infoFileName); } else { // Check if control can be reused RichTextBox richTextBox = null; if(tabPage.Controls.Count > 0) { if(tabPage.Controls[0] is RichTextBox) { reusedControl = true; richTextBox = (RichTextBox)tabPage.Controls[0]; } else { if(tabPage.Controls[0] == this.panelWebBrowser) { this.panelWebBrowser.Visible = false; this.Controls.Add(this.panelWebBrowser); } else { tabPage.Controls.RemoveAt(0); } } } // Create rich-text control tabPage.DockPadding.Top = 10; tabPage.DockPadding.Left = 10; if(!reusedControl) { richTextBox = new RichTextBox(); richTextBox.BackColor = Color.White; richTextBox.BorderStyle = BorderStyle.None; richTextBox.Dock = DockStyle.Fill; richTextBox.ReadOnly = true; richTextBox.WordWrap = false; // Add rich-text control into the tab tabPage.Controls.Add(richTextBox); // Add context menu to the RTF control richTextBox.ContextMenu = this.contextMenuRTF; } // Set rich-text control text if(rtfFormat || infoFileName.EndsWith(".RTF")) { richTextBox.Rtf = infoText; if(infoFileName.EndsWith(".RTF")) richTextBox.WordWrap = true; // Note: setting text the second time to solve image drawing issue richTextBox.Rtf = infoText; } else { richTextBox.Text = infoText; } } ++tabIndex; } // Check and set sample tab index tabIndex = 0; foreach(object obj in sampleInfo.infoPages) { // Check if it's a sample placeholder InfoPage infoPage = (InfoPage)obj; if(infoPage.title == "Sample") { // Position the Sample tab if(tabIndex > 0) { VerticalTabPage page = this.tabControlSample.TabPages[0]; this.tabControlSample.TabPages.RemoveAt(0); this.tabControlSample.TabPages.Insert(tabIndex, page); } break; } ++tabIndex; } // Always make first tab visible this.tabControlSample.SelectedIndex = 0; this.tabControlSample.TabPages[0].Invalidate(); // Set sample title labelSampleTitle.Text = sampleInfo.shortBlurb; // Resume layout this.tabControlSample.ResumeLayout(false); this.panelContent.ResumeLayout(false); this.ResumeLayout(false); // IVOR: I made these changes so the labels that have their text set to // Verdana will interpret "\n". Also all the other controls will have their // colors set to black. if (userControl != null) { foreach (Control control in userControl.Controls) { Label label = control as Label; if (label != null && label.Font.Name == "Verdana") { // IVOR: Take care of all line breaks label.Text = label.Text.Replace("\\n", "\n"); } else { // IVOR: Make the font color black control.ForeColor = Color.Black; } } } }
private SampleInfo GetSampleInfo(Streams header, DeviceConfiguration config) { var result = new SampleInfo(); //Get Sequence Number to use ----------------------- long first = header.FirstSequence; if (!startFromFirst) { first = header.LastSequence; startFromFirst = true; } else if (lastInstanceId == agentInstanceId && lastSequenceSampled > 0 && lastSequenceSampled >= header.FirstSequence) { first = lastSequenceSampled; } else if (first > 0) { // Increment some sequences since the Agent might change the first sequence // before the Sample request gets read // (should be fixed in Agent to automatically read the first 'available' sequence // instead of returning an error) first += 20; } result.From = first; // Get Last Sequence Number available from Header long last = header.LastSequence; // Calculate Sample count long sampleCount = last - first; if (sampleCount > MaxSampleCount) { sampleCount = MaxSampleCount; last = first + MaxSampleCount; } result.Count = sampleCount; return result; }
public static ReturnCode ReadWithCondition( DataReader reader, ref object[] data, ref SampleInfo[] sampleInfos, int maxSamples, IReadCondition condition) { ReturnCode result = ReturnCode.Ok; using (DataReaderMarshaler marshaler = new DataReaderMarshaler(data, sampleInfos, ref maxSamples, ref result)) { if (result == ReturnCode.Ok) { result = Gapi.FooDataReader.read_w_condition( reader.GapiPeer, marshaler.dataValuesPtr, marshaler.sampleInfosPtr, maxSamples, ((ReadCondition)condition).GapiPeer); marshaler.CopyOut(ref data, ref sampleInfos); } } return result; }
/// <summary> /// Initializes a new <see cref="SampleViewModel"/> object. /// </summary> /// <param name="sampleInfo"></param> public SampleViewModel(SampleInfo sampleInfo) { this.sampleInfo = sampleInfo; }
public static ReturnCode TakeNextSample( DataReader reader, ref object data, ref SampleInfo sampleInfo) { //ReturnCode result = Gapi.FooDataReader.take_next_sample( // reader.GapiPeer, // ref data, // ref sampleInfo); return ReturnCode.Unsupported; }