Powershell output as boolean
Hello Scripting guys
Please prompt me. How i can get output as true or false, assume from Get-ADUser "j.maxi" or another cmdlet which outputs string, int, array?
This is very eash in PowerShell.
if(Get-ADUser "j.maxi" -ea 0){
'user found'
}else{
'user ot found'
The result of a get is always true or false by design. the same is tru if you want to save the result.
If($user=ADUser "j.maxi" -ea 0){
# process user
}else{
'user not found'
No need for any fancy stuff. This is builtin. It is a carryover from standard programming practices. We do this in C and C# all of the time. The makers of PowerShell liked it so they used it.
¯\_(ツ)_/¯
Similar Messages
-
[Forum FAQ] How to format and combine PowerShell outputs
Format the output with “Format-Table” and “Format-list”
Sometimes when we query Powershell cmdlet, we would get ellipses in the result, which is not desirable.
In this scenario, we can use the cmdlet “Format-Table” and “Format-list” to view the entire output:
Get-Service | where{$_.name -like "BrokerInfrastr*"}
Get-Service | where{$_.name -like "BrokerInfrastr*"}|Format-Table –AutoSize
Get-Service | where{$_.name -like "BrokerInfrastr*"}|Format-list
Figure 1: format powershell output
Please click to vote if the post helps you. This can be beneficial to other community members reading the thread.Thanks, this has been helpful. I have been trying to figure out how the PSObjects work.
I created a function that takes an object and creates a function to create PSObjects
Function Get-ObjectPropertiesFunction
[CmdletBinding()]
[OutputType([string])]
param
[Parameter(Mandatory=$true,
ValueFromPipeline=$false,
ValueFromPipelineByPropertyName=$false,
ValueFromRemainingArguments=$false,
Position=0,
ParameterSetName='Object')]
[ValidateNotNull()]
[ValidateNotNullOrEmpty()]
[Object]$Object
Begin
$Members=Get-Member -InputObject $Object
$ValidPropertyType = @{"{get;set;}"=$True;"{get;}"=$True;}
$ValidReturnType = @{"bool"=$True;"byte"=$True;"string"=$True;"string[]"=$True;
"int"=$True;"int16"=$True;"int32"=$True;"int64"=$True;
"uint"=$True;"uint16"=$True;"uint32"=$True;"uint64"=$True;
[string]$String=""
$String=$String+"Function Get-PSObjectPropertiesFromObject `n"
$String=$String+"{ `n"
$String=$String+" [CmdletBinding()] `n"
$String=$String+" [OutputType([PSObject[]])] `n"
$String=$String+" param `n"
$String=$String+" ( `n"
$String=$String+" [Parameter(Mandatory="+"$"+"true, `n"
$String=$String+" ValueFromPipeline="+"$"+"false, `n"
$String=$String+" ValueFromPipelineByPropertyName="+"$"+"false, `n"
$String=$String+" ValueFromRemainingArguments="+"$"+"false, `n"
$String=$String+" Position=0, `n"
$String=$String+" ParameterSetName='Object')] `n"
$String=$String+" [ValidateNotNull()] `n"
$String=$String+" [ValidateNotNullOrEmpty()] `n"
$String=$String+" [Object]"+"$"+"Object `n"
$String=$String+" ) `n"
$String=$String+" Begin `n"
$String=$String+" { `n"
$String=$String+" $"+"Output = New-Object PSObject -Property ([Ordered]@{ `n"
ForEach ($Member in $Members)
IF ($Member.MemberType -EQ "Property")
[string]$Name=$Member.Name
IF ($Name.Substring(1,1) -NE "_")
[String[]]$Definition=$Member.Definition.Split(" ")
[string]$PropertyType=$Definition[2]
IF ($ValidPropertyType[$PropertyType])
$ReturnType=$Definition[0]
if ($ValidReturnType[$ReturnType])
$String=$String+" $Name="+"$"+"Object.$Name `n"
$String=$String+" }) `n"
$String=$String+" $"+"Output `n"
$String=$String+" } `n"
$String=$String+"} `n"
$String
Here is the output from the above function for the WIN32_BootConfiguration class (Small Class)
$Class="Win32_BootConfiguration"
$Function=Get-ObjectPropertiesFunction (Get-WMIObject -Class $Class)
PS C:\>> $Function
Function Get-PSObjectPropertiesFromObject
[CmdletBinding()]
[OutputType([PSObject[]])]
param
[Parameter(Mandatory=$true,
ValueFromPipeline=$false,
ValueFromPipelineByPropertyName=$false,
ValueFromRemainingArguments=$false,
Position=0,
ParameterSetName='Object')]
[ValidateNotNull()]
[ValidateNotNullOrEmpty()]
[Object]$Object
Begin
$Output = New-Object PSObject -Property ([Ordered]@{
BootDirectory=$Object.BootDirectory
Caption=$Object.Caption
ConfigurationPath=$Object.ConfigurationPath
Description=$Object.Description
LastDrive=$Object.LastDrive
Name=$Object.Name
ScratchDirectory=$Object.ScratchDirectory
SettingID=$Object.SettingID
TempDirectory=$Object.TempDirectory
$Output
PS C:\>>
The function also works for other and more interesting classes like SQL Server.
PS C:\>>
$srv = New-Object Microsoft.SqlServer.Management.Smo.Server("(local)")
$db = New-Object Microsoft.SqlServer.Management.Smo.Database($srv, "AdventureWorks2012")
$Function=Get-ObjectPropertiesFunction $db
$Function
Function Get-PSObjectPropertiesFromObject
[CmdletBinding()]
[OutputType([PSObject[]])]
param
[Parameter(Mandatory=$true,
ValueFromPipeline=$false,
ValueFromPipelineByPropertyName=$false,
ValueFromRemainingArguments=$false,
Position=0,
ParameterSetName='Object')]
[ValidateNotNull()]
[ValidateNotNullOrEmpty()]
[Object]$Object
Begin
$Output = New-Object PSObject -Property ([Ordered]@{
ActiveConnections=$Object.ActiveConnections
AnsiNullDefault=$Object.AnsiNullDefault
AnsiNullsEnabled=$Object.AnsiNullsEnabled
AnsiPaddingEnabled=$Object.AnsiPaddingEnabled
AnsiWarningsEnabled=$Object.AnsiWarningsEnabled
ArithmeticAbortEnabled=$Object.ArithmeticAbortEnabled
AutoClose=$Object.AutoClose
AutoCreateStatisticsEnabled=$Object.AutoCreateStatisticsEnabled
AutoShrink=$Object.AutoShrink
AutoUpdateStatisticsAsync=$Object.AutoUpdateStatisticsAsync
AutoUpdateStatisticsEnabled=$Object.AutoUpdateStatisticsEnabled
AvailabilityGroupName=$Object.AvailabilityGroupName
BrokerEnabled=$Object.BrokerEnabled
CaseSensitive=$Object.CaseSensitive
ChangeTrackingAutoCleanUp=$Object.ChangeTrackingAutoCleanUp
ChangeTrackingEnabled=$Object.ChangeTrackingEnabled
ChangeTrackingRetentionPeriod=$Object.ChangeTrackingRetentionPeriod
CloseCursorsOnCommitEnabled=$Object.CloseCursorsOnCommitEnabled
Collation=$Object.Collation
ConcatenateNullYieldsNull=$Object.ConcatenateNullYieldsNull
DatabaseOwnershipChaining=$Object.DatabaseOwnershipChaining
DatabaseSnapshotBaseName=$Object.DatabaseSnapshotBaseName
DateCorrelationOptimization=$Object.DateCorrelationOptimization
DboLogin=$Object.DboLogin
DefaultFileGroup=$Object.DefaultFileGroup
DefaultFileStreamFileGroup=$Object.DefaultFileStreamFileGroup
DefaultFullTextCatalog=$Object.DefaultFullTextCatalog
DefaultSchema=$Object.DefaultSchema
EncryptionEnabled=$Object.EncryptionEnabled
FilestreamDirectoryName=$Object.FilestreamDirectoryName
HonorBrokerPriority=$Object.HonorBrokerPriority
ID=$Object.ID
IsAccessible=$Object.IsAccessible
IsDatabaseSnapshot=$Object.IsDatabaseSnapshot
IsDatabaseSnapshotBase=$Object.IsDatabaseSnapshotBase
IsDbAccessAdmin=$Object.IsDbAccessAdmin
IsDbBackupOperator=$Object.IsDbBackupOperator
IsDbDatareader=$Object.IsDbDatareader
IsDbDatawriter=$Object.IsDbDatawriter
IsDbDdlAdmin=$Object.IsDbDdlAdmin
IsDbDenyDatareader=$Object.IsDbDenyDatareader
IsDbDenyDatawriter=$Object.IsDbDenyDatawriter
IsDbManager=$Object.IsDbManager
IsDbOwner=$Object.IsDbOwner
IsDbSecurityAdmin=$Object.IsDbSecurityAdmin
IsDesignMode=$Object.IsDesignMode
IsFederationMember=$Object.IsFederationMember
IsFullTextEnabled=$Object.IsFullTextEnabled
IsLoginManager=$Object.IsLoginManager
IsMailHost=$Object.IsMailHost
IsManagementDataWarehouse=$Object.IsManagementDataWarehouse
IsMirroringEnabled=$Object.IsMirroringEnabled
IsParameterizationForced=$Object.IsParameterizationForced
IsReadCommittedSnapshotOn=$Object.IsReadCommittedSnapshotOn
IsSystemObject=$Object.IsSystemObject
IsUpdateable=$Object.IsUpdateable
IsVarDecimalStorageFormatEnabled=$Object.IsVarDecimalStorageFormatEnabled
LocalCursorsDefault=$Object.LocalCursorsDefault
MirroringPartner=$Object.MirroringPartner
MirroringPartnerInstance=$Object.MirroringPartnerInstance
MirroringRedoQueueMaxSize=$Object.MirroringRedoQueueMaxSize
MirroringRoleSequence=$Object.MirroringRoleSequence
MirroringSafetySequence=$Object.MirroringSafetySequence
MirroringTimeout=$Object.MirroringTimeout
MirroringWitness=$Object.MirroringWitness
Name=$Object.Name
NestedTriggersEnabled=$Object.NestedTriggersEnabled
NumericRoundAbortEnabled=$Object.NumericRoundAbortEnabled
Owner=$Object.Owner
PrimaryFilePath=$Object.PrimaryFilePath
QuotedIdentifiersEnabled=$Object.QuotedIdentifiersEnabled
ReadOnly=$Object.ReadOnly
RecursiveTriggersEnabled=$Object.RecursiveTriggersEnabled
TargetRecoveryTime=$Object.TargetRecoveryTime
TransformNoiseWords=$Object.TransformNoiseWords
Trustworthy=$Object.Trustworthy
TwoDigitYearCutoff=$Object.TwoDigitYearCutoff
UserName=$Object.UserName
Version=$Object.Version
$Output
PS C:\>> -
Hi
I'm looking for the best way to output data from my powershell.
Basically im running a ForEach loop and want to print different data
foreach ($line in $data){
Eg.
get-mailbox | select-object identity,emailaddresses
get-mailbox | format-table identity,emailaddresses
get-mailbox | format-table identity,emailaddresses -Autosize
The emailaddresses value is to long to display in my powershell window (eventhoug I have set the Width extremely long)
The output is displayed as
{smtp:jel@XXX, SMTP:jel@xxx, SIP:jel@xxx, smtp:Jere_Lain...
I would like to get the hole string
cannot get select-object or format-table to Work for me
Format-table is not good to use in my ForEach loop
is there any best practise how to output data in the powershell window in a foreach loop ?
Any input is apreciated.
Hi again
I will try to explain a bit more about what i'm trying to achieve.
I have a list of users
"usr01","usr2",usr3"
For each user I woul like to print to the console (or csv if not possible)
Display Name,WindowsEmailAddress,ExternalEmailAddress,EmailAddresses
User01,[email protected],usr01ext.maildomain.com,STMP:[email protected];sip:[email protected]:smtp:[email protected];smtp:[email protected]
User02,[email protected],usr02ext.maildomain.com,SMTP:[email protected];sip:[email protected]:smtp:[email protected];smtp:[email protected]
User03,[email protected],usr03ext.maildomain.com,SMTP:[email protected];sip:[email protected]:smtp:[email protected];smtp:[email protected]
Maby more or other object attribute i the future
The format above is a wish scenario, I don't have a fixed size on any attribute, they can vary much in length.
also the last part of the UPN can be different.
What is the best way to output the result
When using Array, I seem to get too much info out it adds @{attributename=attribute;attributename=attribute}
I can't get Write-host to output the result even using "`t" because I don´t have a fixed length.
Normally I would use | Select-Object attribute01,attribute02
But this prints the header each time it is run, and when using it in a foreach loop gives me a lot for headers.
should I go for Export-csv instead ?
Or is there a magig powershell comand I don't know about.
Hi again
I will try to explain a bit more about what i'm trying to achieve.
I have a list of users
"usr01","usr2",usr3"
For each user I woul like to print to the console (or csv if not possible)
Display Name,WindowsEmailAddress,ExternalEmailAddress,EmailAddresses
User01,[email protected],usr01ext.maildomain.com,STMP:[email protected];sip:[email protected]:smtp:[email protected];smtp:[email protected]
User02,[email protected],usr02ext.maildomain.com,SMTP:[email protected];sip:[email protected]:smtp:[email protected];smtp:[email protected]
User03,[email protected],usr03ext.maildomain.com,SMTP:[email protected];sip:[email protected]:smtp:[email protected];smtp:[email protected]
Maby more or other object attribute i the future
The format above is a wish scenario, I don't have a fixed size on any attribute, they can vary much in length.
also the last part of the UPN can be different.
What is the best way to output the result
When using Array, I seem to get too much info out it adds @{attributename=attribute;attributename=attribute}
I can't get Write-host to output the result even using "`t" because I don´t have a fixed length.
Normally I would use | Select-Object attribute01,attribute02
But this prints the header each time it is run, and when using it in a foreach loop gives me a lot for headers.
should I go for Export-csv instead ?
Or is there a magig powershell comand I don't know about.
Hi guys.
I have a question and do not know if you can
help me.
I do not know much about Powershell,
but I created a script that disables,
moves and changes the description of dismissed
enterprise users through the registration number
(POBOX in my case).
The question is would you like to generate a log
each time this script was executed,
stating whether or not the actions were
performed successfully.
Tested
with some examples I found on Technet
but did not work.
Does anyone havea hint howcan I includethis functionalityin my script?
$csvFile = ".\list.csv"
$disabledUsersOU = "<OU DESTINATION>"
Import-Csv $csvFile | ForEach {
$f = $_.POBox;
Get-ADUser -Filter {POBox -eq $f} | Disable-ADAccount
Get-ADUser -Filter {POBox -eq $f} | Set-ADUser -Description "Disable User Script v4"
Get-ADUser -Filter {POBox -eq $f} | Move-ADObject -TargetPath $disabledUsersOU
$user = Get-ADUser -Filter {POBox -eq $f} -Properties MemberOf
foreach ($group in ($user | Select-Object -ExpandProperty MemberOf))
Remove-ADGroupMember -Identity $group -Members $user -Confirm:$false
Thanks a lot.
David Soares MCTS:MBS - MCTS - MCITP
You could try something like this:
$csvFile = ".\list.csv"
$disabledUsersOU = "<OU DESTINATION>"
$Results = Import-Csv $csvFile | ForEach {
$f = $_.POBox;
Get-ADUser -Filter {POBox -eq $f} | Disable-ADAccount
Get-ADUser -Filter {POBox -eq $f} | Set-ADUser -Description "Disable User Script v4"
Get-ADUser -Filter {POBox -eq $f} | Move-ADObject -TargetPath $disabledUsersOU
$user = Get-ADUser -Filter {POBox -eq $f} -Properties MemberOf,Description,Enabled
foreach ($group in ($user | Select-Object -ExpandProperty MemberOf))
Remove-ADGroupMember -Identity $group -Members $user -Confirm:$false
$user = Get-ADUser $user -properties MemberOf,POBox,Description
New-Object PSObject -property @{User=$user.samaccountname;POBox=$user.POBox;Description=$user.Description;MemberOf=(($user | select -expand MemberOf) -join ",");Enabled=$user.Enabled;DN=$user.DistinguishedName}
$Results | Select User,POBox,Description,MemberOf,Enabled | Export-CSV ".\results.csv" -NoType
All I really added was to create New-Object for each user and each one gets included in $Results, which gets piped to a csv file. This way you can see what may or may not have succeeded. The alternative is to evaluate each of the values and compare
it to what you expect - if any of them are not what you would expect, then User = fail and instead of the new-object line and having all of the output go to $Results you could do:
Out-File ".\results.log" -InputObject "$($User.sAMAccountName) = FAIL" -append
(or PASS, or SUCCESS, or whatever works). The reason I provided the approach above is that you have a complete picture of the results.
The select in the last line orders the columns in the CSV, otherwise Powershell chooses the order and it isn't usually what you would like.
I hope this post has helped!
Output a boolean bit on gpib using VISA
The program that is being developed is to test a California Instruments power supply model 801RP.
The problem is with the function that switches the output of the power supply on and off, the command is "outp <boolean>".
The question I am raising, how can I send this command with a visa transfer over a gpib interface?
Hi,
Its as Dennis says,
Just send the string "outp 0" to set the output off and "outp 1" to set the output on.
If you have a boolean control, wire this to the boolean to numeric converter then use one of the string functions to concat or format the string with "outp ".
In fact there is a string function that provides a string output based on a boolean input.
Regards
Ray Farmer
Regards
Ray Farmer
I have a task to do, but I'm really newbie at Powershell and I don't really think that I can handle is by myself. Sorry for my english btw :p
The task is:
Letter directions and subdirections and:
-sort it growing by extensions and decreasing by nbame
-display the list with only small letters
-show contens of directions and subdirections
-show elements with attributes : directions, archive, not read only
- ask user the question whether would he like to remove all doc files and does what he says
-clean out powershell screen
-after all shows the list of docs files, saves it in .txt file and opens it in the foreground
I am not really sure if I explained it cleary. I've done in before in cmd, it looked like this:
@echo off
dir %1 /L /O-N /OE /4 /S /AD /AA /A-R /-C
echo "Do you want to remove doc files?"
CHOICE /C:TN /N /T:N,30 /M "Press Y to remove doc files, or press N keep it save."
if errorlevel 1 remove
if errorlevel 2 donotremove
:remove
cd %1
del /p *.doc
:donotremove
cls
dir %1 /B
dir %1 /B > result.txt
start result.txt
I would be grateful for your help.
Sorry but this is not something I asked for :/ As far i got something like this:
function Get-ScriptDirectory
$Invocation = (Get-Variable MyInvocation -Scope 1).Value
Split-Path $Invocation.MyCommand.Path
$path = Get-ScriptDirectory
Get-ChildItem $path -Recurse -Include *doc, *.docx | Sort-Object Name -Descending | Sort Extension
function GetInfo {
Write-Host "Press Y and hit enter to remove .docx files or press N and hit enter to keep it save."
$a = Read-Host
IF ($a -eq "Y")
Remove-Item $path\*.docx
Remove-Item $path\*.doc
Write-Host "Removed"
cls
ELSEIF ($a -eq "N")
Write-Host "Not removed"
cls
ELSE
Write-Host "Wrong button"
GetInfo
GetInfo
Get-Childitem $path | Out-File $path\Result.txt
but I don't really know how to make it show directions, archive files and *.doc at once :/ + how to use lowercase on that list.
in order to demonstate you issue
You are asking for us to design a whoe solution for you by asking a shopping list of quesiions. That is not the purpose of this forum. Please ask a single quesition and provide a simple example to illustrate your issue.
By simplifying your issues you will aslo find it will make understanding your problem much easier.
¯\_(ツ)_/¯
Sync boolean data and clock outputs
Hi ppl.
I was hopping someone could help me with a sync problem:
a) I want to output a counter (pulse train) using the USB-6289 board internal counter (clock);
b) I want to output a boolean array (data);
c) The outputs should be in sync, and the 16-bit word should output in full;
I have got the a) and b) parts working, I believe, however the c) part, when I run the vi in continuous mode, the pulse train with the counter works fine, but the boolean
array just assumes the "1" value (I see this in my Logic Analyzer) and maintains this value throughout the whole time...What am I doing wrong in this part?
I have attached my vi and a printscreen of the boolean data and code.
Thanks in advance fot the reply.
Hardware: USB-8289
LabVIEW v8.5
Cheers
Attachments:
test1.vi 32 KB
untitled2.JPG 187 KB
1. Wire up your error wires.
2. Don't ever use Run Continuous. It is only there for debugging purposes. Put a while loop around your code and use a Stop button to stop the while loop. Any code that should happen only at the beginning such as creating tasks or clocks should occur before the while loop. Code that should occur on at the end such as clearing tasks should occur after the while loop.
3. Perhaps you want to use continuous samples rather than finite?
4. Look through all the DaqMX examples. There might be one that better describes how to link the timing of one task to another. I'm not an expert in DAQ, so I'm not sure if everything is set up properly.
Powershell scripts not writing it to output file
Hi,
Below is my script which loops through all sites and web in a site collection and if the particular web part is added in a page, it will give the page URL and it should be written to a output file.
function enumerateWebParts($Url)
$webApp = Get-SPWebApplication $Url #Get WebApplication URL
foreach($web in $webApp | Get-SPSite -Limit All | Get-SPWeb -Limit All) #foreach loop to iterate through all sites and webs of WebApplication
if ([Microsoft.SharePoint.Publishing.PublishingWeb]::IsPublishingWeb($web)) #Check if site is a publishing site
$pWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)
$pages = $pWeb.PagesList
foreach ($item in $pages.Items)
$fileUrl = $webUrl + "/" + $item.File.Url
$manager = $item.file.GetLimitedWebPartManager([System.Web.UI.WebControls.Webparts.PersonalizationScope]::Shared);
$wps = $manager.webparts
foreach ($type in $wps) #loop through each type found $wps
#Write-Host " type searching";
Write-Host $type.GetType().Name;
if ($type.GetType().Name -eq "RightMenu") #if webpart $type -like KWizCom select webpart object
Write-Host "found";
$wps | select-object @{Expression={$pWeb.Url};Label="Web URL"},@{Expression={$fileUrl};Label="Page URL"},DisplayTitle, IsVisible, @{Expression={$type};Label="Type"}
Write-Host $fileUrl;
$page=$pweb.Url+$fileUrl;
Write-Output $page;
else #if web is not a publishing site
$pages = $null
$pages = $web.Lists["Site Pages"]
if ($pages)
foreach ($item in $pages.Items)
$fileUrl = $webUrl + "/" + $item.File.Url
$manager = $item.file.GetLimitedWebPartManager([System.Web.UI.WebControls.Webparts.PersonalizationScope]::Shared);
$wps = $manager.webparts
foreach ($type in $wps)
if ($type.GetType().Name -eq "RightMenu")
$wps | select-object @{Expression={$Web.Url};Label="Web URL"},@{Expression={$fileUrl};Label="Page URL"},DisplayTitle, IsVisible, @{Expression={$type};Label="Type"}
Write-Host $fileUrl;
$page=$pweb.Url+$fileUrl;
Write-Output $page;
else
# Write-Host “… completed processing” $web
$row = enumerateWebParts(‘http://sptest.danfoss.net’) #call the enumerateWebParts function pass it the URL for the web application
I run the command through D:\RightMenu.ps1 | Out-File D:\RightMenu.txt
Aruna
Try
http://stackoverflow.com/questions/10340007/exporting-powershell-output-to-text-file
You can always redirect the output an exe to a file like so (even from cmd.exe):
powershell c:\test.ps1 > c:\test.log
Within PowerShell, you can also redirect individual commands to file
but in those cases you probably want to append to the log file rather
than overwrite it e.g.:
$logFile = 'c:\temp\test.log'
"Executing script $($MyInvocation.MyCommand.Path)" > $logFile
foreach ($proc in Get-Process) {
$proc.Name >> $logFile
"Another log message here" >> $logFile
If this helped you resolve your issue, please mark it Answered
How to output a checkbox in Smartform?
Does anybody know how to output a boolean as a checkbox in Smartform. I looked at the online help but found nothing about this. Thanks.
I found it out myself, in note 104272.
Thanks anyway.
Generate output based on the analysis of a input array
Hello!
I would appreciate some help with this:
- I have an input array X. It is a phase array, in other words, it has values from -pi to pi.
- I want to create digital pulses that match with certain values of phases in X. Example: If a value of X, in position "5", is -3*pi/2, i would like to generate , in the output array Y, a value of 1 in its position "5".
My problem here is that i am not being able to detect the position of the array where my condition is met. I tried to use a case structure and a for to do this, without success.
I hope i was clear enough, thank you very much.
Ok, now that i Got the phases, i have to generate the output. Knowing the period of the phases wave and the timing of a certain phase, i want to generate a digital output in a future time that falls in the specified phase. It's a closed-loop of stimulation. What i'm trying to do is this:
- First of all, I get the phases like Altenbach said.
- Then, i do the time calculus to predict time intervals that i would wait to generate my pulse, and that pulse should fall in the specified phase of the input waveform, since its a closed-loop system.
I'm attaching the current vi that i designed, and I appreciate any help.
The real trouble now is generate the output pulse/ boolean in the right time, with a duration of, i dont know, 10ms, just to make it work. something like this: _______| |________
<--10ms-->
Best Regards,
Attachments:
PLOT_SIGNAL_ALTERNATIVA.vi 67 KB
Hello all,
I'm currently working with Vivado HLS (2014.4) and am trying to generate an IP with has an generic amount of OUTputs.
For better explanation I've made an "block-image" (sort of) how it should look like when imported in Vivado (in a Block Design):
So it gets an array of booleans (preferable generic!) and splits it into "sizeof(bool[])" output signals.
What I mean with generic is showed in the following picture:
This is the "utility vector logic"-IP from Vivado. There you can set, if double-clicked, the parameter "CSIZE" which directly sets the size of in- and output arrays to CSIZE.
I'm trying to achieve something similar:
I want to Input an array "in[CSIZE]" and split it into CSIZE output wires!
Best would be if i would be able to set the parameter CSIZE of my synthesized IP in Vivado, the way it's done in the "utility vector logic" - IP through the Properties menu.
1) Is this even possible with High Level Synthesis?
2) If not: Is it possible with a fixed size input array (like in[5]) and then manually set the number of output wires to e.g. 5?
3) If this is too isn't possible: How does is work to output a boolean array ("Res[9:0]") like it's done in the "utility vector logic"-IP?
3.1) Which directives would i have to use to achieve this goal?
Because right now, I don't know how to output a boolean array as signal (it always changes to memory, or if implemented as Pointer it's no output (it's on the left side)
It should look something like this (analog to "utility vector logic"):
where in and out are boolean ports.
Preferable the size of the in- and output array is generic and settable in the Vivado properties menu (like mentioned in the example above)!
4) Could you give me according c++ code snippets to solve my problems and to achieve my goal?
My goal is to connect multiple own IP's (theirs clock) with the multiple output ports of the generated IP above (therefore multiple outputs).
I'm grateful for every answer I get!
Thank You very much!
Best regards,
Tilo
Hi
You can't use VHLS to get an IP with parameters;
To be optimal, a change of parameter would need the generated RTL to change, and at the moment, if you wanted to change your IP then you need to rerun C-synthesis. In other words, VHLS doesn't generate IPs with parameters.
For the other question , check the use or array partition complete;
Be aware that outputs have a valid driven interface by default - that's because the outputs may not be valid at every clock cycle when the IP is running.
An example of what you described might be this clock divider that generates N outputs where gen_clk[i] is input clock divided by (M/rate[i])
const unsigned int n_outputs = 5;
void top(unsigned int M, unsigned int rate[n_outputs], bool gen_clk[n_outputs]) {
#pragma HLS array_partition variable=rate complete dim=0
#pragma HLS array_partition variable=gen_clk complete dim=0
#pragma HLS interface ap_none port=gen_clk
#pragma HLS pipeline
unsigned int i;
static unsigned int counter[n_outputs];
static bool int_clk[n_outputs];
for(i=0;i<n_outputs;i++) {
// pipeline (II=1) at top level makes this loop unrolled
bool clk_enable = counter[i]>M;
int_clk[i] ^= clk_enable;
counter[i] = clk_enable ? counter[i]-M: counter[i]+rate[i];
gen_clk[i] = int_clk[i];
but be aware that the tool tells you clearly:
@W [RTGEN-101] Port 'gen_clk_0' with mode 'ap_none' may require an associated data valid signal to correctly communicate with other blocks or a test bench; automatic C/RTL co-simulation may not be able to verify such a port.
In IPI you may not be able to integrate this as the outputs are not decorated as being of type "clocks".
I hope this helps.
Does anyone know how to output to a text file.
I've got a ticket machine and when a button is pressed at the final step i want it to output a boolean variable to a text file, preferably to the desktop
this is a simple .swf which i have created.
ok so i'm a bit new to flash, any help would be much appreciated as i've never used the save method.
i've got the boolean variable: flag,
and i want to output it's value to a text file when i press the taketheticket button:
this is was i have so far
function taketheticket(event:MouseEvent):void
trace("the change is " + flag);
gotoAndStop(8);
Using GetFormattedValue with Boolean Array to create ReportText
What is the C (printf) style format for outputting a Boolean array?
I currently use to get
Step.Result.ReportText = Locals.Outlets.GetFormattedValue("",0,"",False,"\n")
Outlet State
Status:
Done
Module Time:
1.6116278
False
True
False
False
False
False
False
False
I would like to format the output to show:
Outlet State
Status:
Done
Module Time:
1.6116278
OFF
ON
OFF
OFF
OFF
OFF
OFF
OFF
Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
If you don't hate time zones, you're not a real programmer.
"You are what you don't automate"
Inplaceness is synonymous with insidiousness
Hi Phillip,
interresting question, because the c-style doesnt know a datatype "boolean".
So i am quite sure there is no support.
You can do a simple workaround by using twice SearchAndReplace to rename True and False
in the same expression
Hope that helps
Juergen
=s=i=g=n=a=t=u=r=e= Click on the Star and see what happens :-) =s=i=g=n=a=t=u=r=e=
Attachments:
Example.seq 5 KB
Generate output values based on contexts
Queue 1 :
contextchange
mat_name1
contextchange
mat_name2
contextchange
mat_name3
contextchange
mat_name4
contextchange
Queue 2: ( output from Boolean AND)
contextchange
true
contextchange
true
true
contextchange
true
true
true
contextchange
false
true
contextchange
Based on the 2 Queues, I shud get the following output :
contextchange
mat_name1
contextchange ( based on 2 true values of the queue 2)
mat_name2
mat_name2
contextchange ( based on 3 true values of Queue 2)
mat_name3
mat_name3
mat_name3
contextchange ( based on 1 true value of Queue 2)
mat_name4 (because false ignore II ocurance)
how do I achieve this?
regards,
nikhil.
***each useful reply will be awarded***
Hi,
contextchange
true
contextchange
true
true
contextchange
true
true
true
contextchange
false
true
contextchange
remove false from the above context. then ur output will be
contextchange
true
contextchange
true
true
contextchange
true
true
true
contextchange
true
contextchange
now u can use UseoneAsmany.
chirag
Web Services and Powershell error: Method can not be reflected
I'm trying to use the VSM 9.1 Web Service API with Powershell, however when I run the New-WebServiceProxy cmdlet it throws an error, the inner exception being "Method InfraAPI.KnowledgeUpdate can not be reflected.", and as such I'm unable to proceed any further with development.
Here's the Powershell output:
PS C:\PS> new-webserviceproxy -uri http://vsmhost/dev/ServiceManager.svc?wsdl
New-WebServiceProxy : Exception has been thrown by the target of an invocation.
At line:1 char:20
+ new-webserviceproxy <<<< -uri http://vsmhost/dev/ServiceManager.svc?wsdl
+ CategoryInfo : NotSpecified: (:) [New-WebServiceProxy], TargetInvocationException
+ FullyQualifiedErrorId : System.Reflection.TargetInvocationException,Microsoft.PowerShell.Commands.NewWebServiceProxy
PS C:\PS> $error[0].exception.innerexception
Method InfraAPI.KnowledgeUpdate can not be reflected.
Any help with this would be greatly appreciated.
Hi Chris,
//-- Please read the following as my personal opinion only as it's based only on my own experience using VSM API. I may be wrong of course. --//
As far as I remember there was never a good decision to use VSM API through web service reference.
I had met some problems when referencing VSM services directly through web even using Visual Studio some years ago. Since then I don't use this method.
Recently I have tried to check VSM API services metadata with some soap tools and it appears that it is not completely WS-I compliant - something wrong with namespaces defining ResultSet elements as type of DataSet. Perhaps this is the reason why VSM web services does not work as expected when referencing them directly. Maybe something else...
So the solution, workaround actually, (provided by VMware by the way) is to generate InfraAPI class and use it in your project. So far no problems with this method and we are using VSM API quite a lot.
In any case, it could be really helpful if someone might submit this issue to Alemba to fix it permanently I guess.
Ok, let's go back to your question about using VSM API with PowerShell. I must admit you have really challenged me. It was not so simple but really interesting.
The only way I have made PowerShell working is this:
1. Extract VSM API services class to a file:
svcutil /t:code /language=c# /messageContract http://vsmhost/dev/ServiceManager.svc /out:InfraAPI.9.2.0.cs /config:InfraAPI.9.2.0.config
2. Compile the class to dll file:
csc /t:library /out:InfraAPI.9.2.0.dll InfraAPI.9.2.0.cs
3. Include and use this library in your ps script like this:
[System.Reflection.Assembly]::LoadFrom("C:\_DATA\__SM9\PowerShell\API\InfraAPI.9.2.0.dll")
[System.Reflection.Assembly]::LoadWithPartialName(“System.ServiceModel”)
$ws_hb = New-Object System.ServiceModel.BasicHttpBinding
$ws_hb.Name = "BasicHttpBinding_IServiceManager"
$ws_epa = New-Object System.ServiceModel.EndpointAddress("http://vsmhost/dev/servicemanager.svc")
$ws = New-Object ServiceManagerClient($ws_hb,$ws_epa)
$ws_login_in = New-Object LoginRequest("VSM_USER_NAME","VSM_USER_PASSWORD","VSM_DATABASE")
$ws_login_out = $ws.Login($ws_login_in)
$ws_login_out.sMessage
if($ws_login_out.Ret.value__ -eq 0){
"Session ID: " + $ws_login_out.sID
$ws_logout_in = New-Object LogoutRequest($ws_login_out.sID)
$ws.Logout($ws_logout_in).sMessage
Shoot your questions if you have any. And could you please let me know if this is working in your environment. Tx.
Regards, Gytis
Maybe you are looking for
-
Vista drivers problems Sound Blaster Audigy 2 ZS Noteb
First thing to do: haveyour systemchecked out, if windows says the hardware is failing there may really be something wrong with it. If the SB card works in an XP machine there may be a problem in the the PCI slot or controller on the motherboard, eit
-
SAP R/3 4.7 Fax Header settings.
SAP R/3 4.7 Fax Header settings. Sending fax from SAP Office, Workplace SBWP goes thru SCOT to faxserver and shows status in SOST in SAP which doesn't show this header page. When the fax gets sent it has a first page of an SAP fax header page that ju
-
Select query in Advanced SQL Filter
Hi All I am creating a shared filter and I need to write an sql statement for a column. Can I use string functions in the Advanced SQL Filter. My sql query is : select distinct "Exchange Rate"."Type" from "Credit" where substr(rtrim("Exchange Rate"."
-
Just what is getting backed up?
There was a time when I didn't need an external drive just for my iTunes library. It passed several weeks ago. I bought a 500GB external drive and moved my iTunes content there, via a firewire connection initially. Then there was a reconditioned Airp
-
Setting Page Items from SQL Query
Hi, </br></br> I am using "SQL Query (PL/SQL function body returning SQL query)" for a report. In the body of the sql query, after calling a function, I have the following statement: </br></br> APEX_UTIL.SET_SESSION_STATE( p_name => 'P13_MESSAGE', p_